]> git.imager.perl.org - imager.git/commitdiff
- an opacity fill based on a fountain fill would segfault when
authorTony Cook <tony@develop=help.com>
Sun, 20 Jun 2010 09:33:28 +0000 (09:33 +0000)
committerTony Cook <tony@develop=help.com>
Sun, 20 Jun 2010 09:33:28 +0000 (09:33 +0000)
   filling an 8-bit/sample image.

Changes
fills.c
t/t20fill.t

diff --git a/Changes b/Changes
index ffba59756c9e9fd969d0d54a96a9796e927b7618..a2c1d73d210137696382d1f4096908131397ce6f 100644 (file)
--- a/Changes
+++ b/Changes
@@ -6,6 +6,9 @@ Imager 0.75
  - use PERL_NO_GET_CONTEXT to slightly improve performance on threaded
    perls (not measured)
 
+ - an opacity fill based on a fountain fill would segfault when
+   filling an 8-bit/sample image.
+
 Imager 0.74 - 7 May 2010
 ===========
 
diff --git a/fills.c b/fills.c
index 5ca4293473184e3f6bce8b06b30bc1180bab18a6..0e8f41790ecd1a6f1113d91d41244c0e0b3a070f 100644 (file)
--- a/fills.c
+++ b/fills.c
@@ -563,6 +563,11 @@ i_new_fill_opacity(i_fill_t *base_fill, double alpha_mult) {
   fill->other_fill = base_fill;
   fill->alpha_mult = alpha_mult;
 
+  if (!base_fill->f_fill_with_color) {
+    /* base fill only does floating, so we only do that too */
+    fill->base.f_fill_with_color = NULL;
+  }
+
   return &fill->base;
 }
 
index 1a680f50c7046f8b4521b2e164451e9c5b12f264..5508d51e11bf692765590e1fdc27e5dd1ca11f78 100644 (file)
@@ -1,6 +1,6 @@
 #!perl -w
 use strict;
-use Test::More tests => 153;
+use Test::More tests => 156;
 
 use Imager ':handy';
 use Imager::Fill;
@@ -608,6 +608,32 @@ SKIP:
     is_color3($im->getpixel(x => 0, y => 0), 255, 255, 255,
              "check for correct colour");
   }
+
+  {
+    require Imager::Fountain;
+    my $fount = Imager::Fountain->new;
+    $fount->add(c1 => "FFFFFF"); # simple white to black
+    # base fill is a fountain
+    my $base_fill = Imager::Fill->new
+      (
+       fountain => "linear",
+       segments => $fount,
+       xa => 0, 
+       ya => 0,
+       xb => 100,
+       yb => 100,
+      );
+    ok($base_fill, "made fountain fill base");
+    my $op_fill = Imager::Fill->new
+      (
+       type => "opacity",
+       other => $base_fill,
+       opacity => 0.5,
+      );
+    ok($op_fill, "made opacity fountain fill");
+    my $im = Imager->new(xsize => 100, ysize => 100);
+    ok($im->box(fill => $op_fill), "draw with it");
+  }
 }
 
 sub color_close {