better error handling
authorTony Cook <tony@develop=help.com>
Mon, 10 Sep 2001 10:50:24 +0000 (10:50 +0000)
committerTony Cook <tony@develop=help.com>
Mon, 10 Sep 2001 10:50:24 +0000 (10:50 +0000)
handle combining modes for non-transparent colors

Imager.pm
fills.c

index 9469fa81f2fbf01ccdfe00d5e410da1338820140..0f63fa7dfe7688448bfde6d721fa0c45bb511bbb 100644 (file)
--- a/Imager.pm
+++ b/Imager.pm
@@ -1625,7 +1625,10 @@ sub box {
     unless (UNIVERSAL::isa($opts{fill}, 'Imager::Fill')) {
       # assume it's a hash ref
       require 'Imager/Fill.pm';
-      $opts{fill} = Imager::Fill->new(%{$opts{fill}});
+      unless ($opts{fill} = Imager::Fill->new(%{$opts{fill}})) {
+        $self->{ERRSTR} = $Imager::ERRSTR;
+        return undef;
+      }
     }
     i_box_cfill($self->{IMG},$opts{xmin},$opts{ymin},$opts{xmax},
                 $opts{ymax},$opts{fill}{fill});
diff --git a/fills.c b/fills.c
index 06cbeb0a5666727aed2498aa1699e6d4ca4f5cb4..d91fb9804c86edc65d5e220d8c86217f35664dd0 100644 (file)
--- a/fills.c
+++ b/fills.c
@@ -221,7 +221,7 @@ i_new_fill_solidf(i_fcolor *c, int combine) {
   int ch;
   i_fill_solid_t *fill = mymalloc(sizeof(i_fill_solid_t));
   
-  if (combine && c->channel[3] < 1.0) {
+  if (combine) {
     *fill = base_solid_fill_comb;
     i_get_combine(combine, &fill->base.combine, &fill->base.combinef);
   }
@@ -250,7 +250,7 @@ i_new_fill_solid(i_color *c, int combine) {
   int ch;
   i_fill_solid_t *fill = mymalloc(sizeof(i_fill_solid_t));
 
-  if (combine && c->channel[3] < 255) {
+  if (combine) {
     *fill = base_solid_fill_comb;
     i_get_combine(combine, &fill->base.combine, &fill->base.combinef);
   }
@@ -561,7 +561,7 @@ i_new_hatch_low(i_color *fg, i_color *bg, i_fcolor *ffg, i_fcolor *fbg,
   fill->bg = bg ? *bg : fcolor_to_color(fbg);
   fill->ffg = ffg ? *ffg : color_to_fcolor(fg);
   fill->fbg = fbg ? *fbg : color_to_fcolor(bg);
-  if (combine && (fill->ffg.channel[0] < 1 || fill->fbg.channel[0] < 1)) {
+  if (combine) {
     i_get_combine(combine, &fill->base.combine, &fill->base.combinef);
   }
   else {