Set padding pixels to black.
This commit is contained in:
parent
b008cccb95
commit
085dc2861c
24
rotation.cpp
24
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue