mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 09:39:15 +00:00
Implement 180 and 270
This commit is contained in:
@@ -56,8 +56,27 @@ fn rotate(width: usize, height: usize, rotate: usize) {
|
||||
}
|
||||
}
|
||||
}
|
||||
180 => std::process::abort(),
|
||||
270 => std::process::abort(),
|
||||
180 => {
|
||||
for i in 0..num_pixels {
|
||||
*out_b.get_mut(num_pixels - 1 - i).unwrap_hard() = *in_b.get(i).unwrap_hard();
|
||||
}
|
||||
}
|
||||
270 => {
|
||||
let new_width = height;
|
||||
let new_height = width;
|
||||
for y_start in (0..height).step_by(TILE_SIZE) {
|
||||
for x_start in (0..width).step_by(TILE_SIZE) {
|
||||
for y in y_start..(y_start + TILE_SIZE).min(height) {
|
||||
for x in x_start..(x_start + TILE_SIZE).min(width) {
|
||||
let new_x = y;
|
||||
let new_y = new_height - 1 - x;
|
||||
*out_b.get_mut(new_y * new_width + new_x).unwrap_hard() =
|
||||
*in_b.get(y * width + x).unwrap_hard();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => std::process::abort(),
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user