[][src]Function raster::transform::rotate

pub fn rotate(src: &mut Image, degree: i32, bg: Color) -> RasterResult<()>

Rotate an image clockwise. Negate the degrees to do a counter-clockwise rotation. Background color can be any color.

Note: If you look closely, the quality for arbitrary angles is not very good due to the simple sampling algorithm. The 90, 180, and 270 angles looks fine because no pixels are lost. This will be fixed in the future with a better sampling algorithm.

Examples

Rotate 45 degrees with a black background color:

use raster::{transform, Color};

//...

let mut image = raster::open("tests/in/sample.png").unwrap();
transform::rotate(&mut image, 45, Color::rgb(0,0,0)).unwrap();
raster::save(&image, "tests/out/test_transform_rotate_45.png").unwrap();

Rotate 45 degrees counter-clockwise with a red background color:

use raster::{transform, Color};

//...

let mut image = raster::open("tests/in/sample.png").unwrap();
transform::rotate(&mut image, -45, Color::rgb(252,145,145)).unwrap();
raster::save(&image, "tests/out/test_transform_rotate_45cc.png").unwrap();