From e3e0d3c20aa499f04ec9a762e2d6e1fa574698db Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Fri, 4 Jul 2014 00:34:06 +0200 Subject: [PATCH] Fix first rotated tile on each row. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first tile on each row seemed to be missing values. This was due to the ‘continue’ statement that would prevent src_rotated_point to be incremented properly. --- TODO.md | 2 +- rotation.cpp | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/TODO.md b/TODO.md index c2f70b1..5c7f8c5 100644 --- a/TODO.md +++ b/TODO.md @@ -21,4 +21,4 @@ [ ] Image borders # Bugs -[ ] first tile on each row is missing +[X] first tile on each row is missing diff --git a/rotation.cpp b/rotation.cpp index e912f07..d641a3c 100644 --- a/rotation.cpp +++ b/rotation.cpp @@ -786,18 +786,16 @@ rotate(TiledImage const& src, double angle) DPoint src_rotated_point(rot_origin_in_src.x + x_index * src_delta_x.x + y_index * src_delta_y.x, rot_origin_in_src.y + x_index * src_delta_x.y + y_index * src_delta_y.y); - for (unsigned int i = 0; i < W; ++i, ++x_index) + for (unsigned int i = 0; i < W; ++i) { unsigned int const rot_index = (j * W + i) * 3; - Point const rot_point(x_index, y_index); - if (src_rotated_point.x < 0 || src_rotated_point.x > src.width - || src_rotated_point.y < 0 || src_rotated_point.y > src.height) - continue; - - rotate_pixel(src, - src_rotated_point, - rotated->tiles[rot_tile_index], rot_index); + if (src_rotated_point.x >= 0 && src_rotated_point.x < src.width + && src_rotated_point.y >= 0 && src_rotated_point.y < src.height) + { + rotate_pixel(src, src_rotated_point, + rotated->tiles[rot_tile_index], rot_index); + } src_rotated_point.x += src_delta_x.x; src_rotated_point.y += src_delta_x.y;