]> git.imager.perl.org - imager.git/commitdiff
flood_fill() wouldn't fill the right side of a single scan-line fill area.
authorTony Cook <tony@develop=help.com>
Sun, 19 Sep 2010 00:31:51 +0000 (00:31 +0000)
committerTony Cook <tony@develop=help.com>
Sun, 19 Sep 2010 00:31:51 +0000 (00:31 +0000)
Changes
draw.c
t/t21draw.t

diff --git a/Changes b/Changes
index 1295d465bedbdb44a591d0e877c07c516720fc69..416427c7c48e068e7b804aa863249f24cc7f6cf7 100644 (file)
--- a/Changes
+++ b/Changes
@@ -16,6 +16,10 @@ Bug fixes:
  - from _01: look for missing file support test files in the right
    places.
 
+ - flood_fill() wouldn't fill the right side of a single scan-line
+   fill area.
+   Thanks to Nicolas Roggli for reporting this.
+
 Imager 0.77_01 - 13 Sep 2010
 ==============
 
diff --git a/draw.c b/draw.c
index 93ae7ab0622e521abcb1ab59901bd96e3fd59d52..0dfd75783b78503f7dcf994c6bc1a1f9b7931d2f 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -1650,6 +1650,8 @@ i_flood_fill_low(i_img *im,int seedx,int seedy,
   ltx = i_lspan(im, seedx, seedy, seed, cmpfunc);
   rtx = i_rspan(im, seedx, seedy, seed, cmpfunc);
   for(tx=ltx; tx<=rtx; tx++) SET(tx, seedy);
+  bxmin = ltx;
+  bxmax = rtx;
 
   ST_PUSH(ltx, rtx, ltx, rtx, seedy+1,  1);
   ST_PUSH(ltx, rtx, ltx, rtx, seedy-1, -1);
index ac86f1cab5ea57e5babf8596971662ff0bd11288..28b62bbb74cc16e04f8c7aab906d37229ae14350 100644 (file)
@@ -1,8 +1,8 @@
 #!perl -w
 use strict;
-use Test::More tests => 244;
+use Test::More tests => 250;
 use Imager ':all';
-use Imager::Test qw(is_color3);
+use Imager::Test qw(is_color3 is_image);
 use constant PI => 3.14159265358979;
 
 init_log("testout/t21draw.log",1);
@@ -295,6 +295,21 @@ my $white = '#FFFFFF';
   }
 }
 
+{ # flood_fill wouldn't fill to the right if the area was just a 
+  # single scan-line
+  my $im = Imager->new(xsize => 5, ysize => 3);
+  ok($im, "make flood_fill test image");
+  ok($im->line(x1 => 0, y1 => 1, x2 => 4, y2 => 1, color => "white"),
+     "create fill area");
+  ok($im->flood_fill(x => 3, y => 1, color => "blue"),
+     "fill it");
+  my $cmp = Imager->new(xsize => 5, ysize => 3);
+  ok($cmp, "make test image");
+  ok($cmp->line(x1 => 0, y1 => 1, x2 => 4, y2 => 1, color => "blue"),
+     "synthezied filled area");
+  is_image($im, $cmp, "flood_fill filled horizontal line");
+}
+
 malloc_state();
 
 unless ($ENV{IMAGER_KEEP_FILES}) {