diff --git a/rotation.cpp b/rotation.cpp index ea17a61..128165d 100644 --- a/rotation.cpp +++ b/rotation.cpp @@ -388,7 +388,20 @@ Image* rotate(Image const& src, double angle) { Point src_rotated_point = src_rotated_origin; - for (int x = 0; x < width; ++x) + int const left_padding = padding_table[y]; + int const right_padding = padding_table[height - 1 - y]; + int const core_pixels = width - left_padding - right_padding; + + // Left padding + for (int x = 0; x < left_padding; ++x, ++buffer_index) + { + // Set to black value + buffer[buffer_index] = 0; + src_rotated_point += qdx; + } + + // Body + for (int x = 0; x < core_pixels; ++x, ++buffer_index) { if (src_rotated_point.x >= 0 && src_rotated_point.x < src_qwidth && src_rotated_point.y >= 0 && src_rotated_point.y < src_qheight) @@ -400,8 +413,15 @@ Image* rotate(Image const& src, double angle) } src_rotated_point += qdx; - buffer_index += 1; // pixel_size } + + // Right padding + for (int x = 0; x < right_padding; ++x, ++buffer_index) + { + // Set to black value + buffer[buffer_index] = 0; + } + src_rotated_origin += qdy; }