[aseprite] 95/196: Fix crash on image_scale_tpl() and rotsprite_image()

Tobias Hansen thansen at moszumanska.debian.org
Wed Apr 20 18:50:06 UTC 2016


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 14262c270c0407dd892d96455e0cf866f5ab1ce8
Author: David Capello <davidcapello at gmail.com>
Date:   Tue Mar 22 17:05:45 2016 -0300

    Fix crash on image_scale_tpl() and rotsprite_image()
---
 src/doc/algorithm/rotate.cpp    | 14 ++++++++++----
 src/doc/algorithm/rotsprite.cpp |  4 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/doc/algorithm/rotate.cpp b/src/doc/algorithm/rotate.cpp
index 6f29b56..4f8d8d2 100644
--- a/src/doc/algorithm/rotate.cpp
+++ b/src/doc/algorithm/rotate.cpp
@@ -47,16 +47,22 @@ static void image_scale_tpl(
 {
   LockImageBits<ImageTraits> dst_bits(dst, gfx::Rect(dst_x, dst_y, dst_w, dst_h));
   typename LockImageBits<ImageTraits>::iterator dst_it = dst_bits.begin();
+  fixed x;
+  fixed y = itofix(src_y);
+  fixed dx = fixdiv(itofix(src_w-1), itofix(dst_w-1));
+  fixed dy = fixdiv(itofix(src_h-1), itofix(dst_h-1));
 
   for (int v=0; v<dst_h; ++v) {
+    x = itofix(src_x);
     for (int u=0; u<dst_w; ++u) {
-      color_t src_color =
-        get_pixel_fast<ImageTraits>(src,
-                                    src_w*(src_x+u)/dst_w,
-                                    src_h*(src_y+v)/dst_h);
+      ASSERT(dst_it != dst_bits.end());
+      color_t src_color = get_pixel_fast<ImageTraits>(src, fixtoi(x), fixtoi(y));
       *dst_it = blend(*dst_it, src_color);
       ++dst_it;
+
+      x = fixadd(x, dx);
     }
+    y = fixadd(y, dy);
   }
 }
 
diff --git a/src/doc/algorithm/rotsprite.cpp b/src/doc/algorithm/rotsprite.cpp
index 76bc491..152d0cb 100644
--- a/src/doc/algorithm/rotsprite.cpp
+++ b/src/doc/algorithm/rotsprite.cpp
@@ -176,8 +176,8 @@ void rotsprite_image(Image* bmp, const Image* spr, const Image* mask,
   int xmax = MAX(x1, MAX(x2, MAX(x3, x4)));
   int ymin = MIN(y1, MIN(y2, MIN(y3, y4)));
   int ymax = MAX(y1, MAX(y2, MAX(y3, y4)));
-  int rot_width = xmax - xmin + 1;
-  int rot_height = ymax - ymin + 1;
+  int rot_width = xmax - xmin;
+  int rot_height = ymax - ymin;
 
   int scale = 8;
   base::UniquePtr<Image> bmp_copy(Image::create(bmp->pixelFormat(), rot_width*scale, rot_height*scale, buf[0]));

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list