diff --git a/codecs/rotate/rotate.rs b/codecs/rotate/rotate.rs index 73317eea..5db4d10b 100644 --- a/codecs/rotate/rotate.rs +++ b/codecs/rotate/rotate.rs @@ -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(), } } diff --git a/codecs/rotate/rotate.wasm b/codecs/rotate/rotate.wasm index 9977d58f..6774a3b4 100755 Binary files a/codecs/rotate/rotate.wasm and b/codecs/rotate/rotate.wasm differ