the image.
sub flood_fill {
my $self = shift;
my %opts = ( color=>Imager::Color->new(255, 255, 255), @_ );
-
+ my $rc;
unless (exists $opts{'x'} && exists $opts{'y'}) {
$self->{ERRSTR} = "missing seed x and y parameters";
return undef;
return;
}
}
- i_flood_cfill($self->{IMG}, $opts{'x'}, $opts{'y'}, $opts{fill}{fill});
+ $rc = i_flood_cfill($self->{IMG}, $opts{'x'}, $opts{'y'}, $opts{fill}{fill});
}
else {
my $color = _color($opts{'color'});
$self->{ERRSTR} = $Imager::ERRSTR;
return;
}
- i_flood_fill($self->{IMG}, $opts{'x'}, $opts{'y'}, $color);
+ $rc = i_flood_fill($self->{IMG}, $opts{'x'}, $opts{'y'}, $color);
}
-
- $self;
+ if ($rc) { $self; } else { $self->{ERRSTR} = $self->_error_as_msg(); return (); }
}
sub setpixel {
-void
+undef_int
i_flood_fill(im,seedx,seedy,dcol)
Imager::ImgRaw im
int seedx
int seedy
Imager::Color dcol
-void
+undef_int
i_flood_cfill(im,seedx,seedy,fill)
Imager::ImgRaw im
int seedx
#define INSIDE(x,y) ((!btm_test(btm,x,y) && ( i_gpix(im,x,y,&cval),i_ccomp(&val,&cval,channels) ) ))
-void
-i_flood_fill(i_img *im,int seedx,int seedy,i_color *dcol) {
+undef_int
+i_flood_fill(i_img *im, int seedx, int seedy, i_color *dcol) {
int lx,rx;
int y;
xsize = im->xsize;
ysize = im->ysize;
+ if (seedx < 0 || seedx >= xsize ||
+ seedy < 0 || seedy >= ysize) {
+
+ i_push_error(0, "Seed pixel outside of image");
+ return 0;
+ }
+
+
btm = btm_new(xsize,ysize);
st = llist_new(100,sizeof(struct stack_element*));
btm_destroy(btm);
mm_log((1, "DESTROY\n"));
llist_destroy(st);
+ return 1;
}
static struct i_bitmap *
return btm;
}
-void
+undef_int
i_flood_cfill(i_img *im, int seedx, int seedy, i_fill_t *fill) {
int bxmin, bxmax, bymin, bymax;
struct i_bitmap *btm;
int x, y;
int start;
+
+ if (seedx < 0 || seedx >= im->xsize ||
+ seedy < 0 || seedy >= im->ysize) {
+ i_push_error(0, "Seed pixel outside of image");
+ return 0;
+ }
+
+
btm = i_flood_fill_low(im, seedx, seedy, &bxmin, &bxmax, &bymin, &bymax);
if (im->bits == i_8_bits && fill->fill_with_color) {
}
btm_destroy(btm);
+ return 1;
}
void i_poly_aa (i_img *im,int l,double *x,double *y,i_color *val);
void i_poly_aa_cfill(i_img *im,int l,double *x,double *y,i_fill_t *fill);
-void i_flood_fill (i_img *im,int seedx,int seedy,i_color *dcol);
+undef_int i_flood_fill (i_img *im,int seedx,int seedy,i_color *dcol);
+undef_int i_flood_cfill(i_img *im, int seedx, int seedy, i_fill_t *fill);
+
/* image processing functions */