fix handling of yoff for untransformed image based fills
authorTony Cook <tony@develop-help.com>
Fri, 19 Oct 2012 11:54:34 +0000 (22:54 +1100)
committerTony Cook <tony@develop-help.com>
Fri, 19 Oct 2012 11:54:34 +0000 (22:54 +1100)
fills.c
t/t20fill.t

diff --git a/fills.c b/fills.c
index 795f7cd88e93886dc30cb318701f1c8454f2ca0b..932e44f3e0ffcd7c6af6646a5e4cb0ad4a64aa44 100644 (file)
--- a/fills.c
+++ b/fills.c
@@ -856,7 +856,7 @@ fill_image(i_fill_t *fill, i_img_dim x, i_img_dim y, i_img_dim width,
       }
       else if (f->yoff) {
         ry += ix * f->yoff;
-        iy = ry / f->src->xsize;
+        iy = ry / f->src->ysize;
       }
       rx -= ix * f->src->xsize;
       ry -= iy * f->src->ysize;
index bdf57252fb3709af167641ccc92f7df19008b73d..c809f12780d8bd55c93fcf9c64f89f3e4a12c676 100644 (file)
@@ -1,6 +1,6 @@
 #!perl -w
 use strict;
-use Test::More tests => 157;
+use Test::More tests => 165;
 
 use Imager ':handy';
 use Imager::Fill;
@@ -666,6 +666,35 @@ SKIP:
   is($im->getcolorcount, 2, "only original and fill color");
 }
 
+SKIP:
+{
+  # the wrong image dimension was used for adjusting vs yoff,
+  # producing uncovered parts of the output image
+  my $tx = Imager->new(xsize => 30, ysize => 20);
+  ok($tx, "create texture image")
+    or diag "create texture image", Imager->errstr;
+  $tx or skip "no texture image", 7;
+  ok($tx->box(filled => 1, color => "ff0000"), "fill texture image")
+    or diag "fill texture image", $tx->errstr;
+  my $cmp = Imager->new(xsize => 100, ysize => 100);
+  ok($cmp, "create comparison image")
+    or diag "create comparison image: ", Imager->errstr;
+  $cmp or skip "no comparison image", 5;
+  ok($cmp->box(filled => 1, color => "FF0000"), "fill compare image")
+    or diag "fill compare image: ", $cmp->errstr;
+  my $im = Imager->new(xsize => 100, ysize => 100);
+  ok($im, "make test image")
+    or diag "make test image: ", Imager->errstr;
+  $im or skip "no test image", 3;
+  my $fill = Imager::Fill->new(image => $tx, yoff => 10);
+  ok($fill, "make xoff=10 image fill")
+    or diag "make fill: ", Imager->errstr;
+  $fill or skip "no fill", 2;
+  ok($im->box(fill => $fill), "fill test image")
+    or diag "fill test image: ", $im->errstr;
+  is_image($im, $cmp, "check test image");
+}
+
 sub color_close {
   my ($c1, $c2) = @_;