diff --git a/rotation.cpp b/rotation.cpp index aa3ee57..6b232c4 100644 --- a/rotation.cpp +++ b/rotation.cpp @@ -340,15 +340,13 @@ void rotate_pixel(Image const& src, int const src_y = src_rotated_point.y >> q_pow; // Bilinear interpolation - unsigned int const src_index_1 = (src_y * src.width + src_x) * src.pixel_size; - unsigned int const src_index_2 = src_index_1 + src.pixel_size; - unsigned int const src_index_3 = src_index_1 + src.pixel_size * src.width; - unsigned int const src_index_4 = src_index_3 + src.pixel_size; + unsigned int const src_index_1 = src_y * src.width + src_x; + unsigned int const src_index_3 = src_index_1 + src.width; pvalue_t const src_tl = src.buffer[src_index_1]; - pvalue_t const src_tr = src.buffer[src_index_2]; + pvalue_t const src_tr = src.buffer[src_index_1 + 1]; pvalue_t const src_bl = src.buffer[src_index_3]; - pvalue_t const src_br = src.buffer[src_index_4]; + pvalue_t const src_br = src.buffer[src_index_3 + 1]; unsigned int const x_delta = (src_rotated_point.x >> (q_pow - q_inter_pow)) & mask; unsigned int const y_delta = (src_rotated_point.y >> (q_pow - q_inter_pow)) & mask; @@ -402,7 +400,7 @@ Image* rotate(Image const& src, double angle) round_if_very_small(src_delta_y.x); round_if_very_small(src_delta_y.y); - // Quantized position on a grid + // Quantized position on a 1024x1024 grid int const q_pos_pow = 10; int const q_pos = 1 << q_pos_pow;