pub fn rotate_90_clockwise(height: usize, width: usize, vector: Vec<u8>) -> Vec<u8> {
    let (new_width, _new_height) = (height, width);
    let mut output_image = vec![0; vector.len()];

    for y in 0..height {
        for x in 0..width {
            let (new_x, new_y) = (new_width - 1 - y, x);
            let input_pixel = y * width + x;
            let output_pixel = new_y * new_width + new_x;
            for z in 0..3 {
                output_image[output_pixel * 3 + z] = vector[input_pixel * 3 + z];
            }
        }
    }

    output_image
}
/// Rotates image 90 degrees clockwise.
Rotates image 90 degrees clockwise.
Rotates image 90 degrees clockwise .
pub fn rotate_90_clockwise(height: usize, width: usize, vector: Vec<u8>) -> Vec<u8> {
    let (new_width, _new_height) = (height, width);
    let mut output_image = vec![0; vector.len()];
    for y in 0..height {
        for x in 0..width {
            let (new_x, new_y) = (new_width - 1 - y, x);
            let input_pixel = y * width + x;
            let output_pixel = new_y * new_width + new_x;
            for z in 0..3 {
                output_image[output_pixel * 3 + z] = vector[input_pixel * 3 + z];
            }
        }
    }
    output_image
}
pub fn rotate_90_clockwise ( height : usize , width : usize , vector : Vec < u8 > ) -> Vec < u8 > { let ( new_width , _new_height ) = ( height , width ) ; let mut output_image = vec ! [ 0 vector len ( ) ] ; for y in 0 .. height { for x in 0 .. width { let ( new_x , new_y ) = ( new_width - 1 - y , x ) ; let input_pixel = y * width + x ; let output_pixel = new_y * new_width + new_x ; for z in 0 .. 3 { output_image [ output_pixel * 3 + z ] = vector [ input_pixel * 3 + z ] ; } } } output_image }
Rotates image 90 degrees clockwise.
Rotates image 90 degrees clockwise .
height
usize
width
usize
vector
Vec<u8>
height
usize
width
usize
vector
Vec<u8>