From: Tony Cook Date: Mon, 10 Oct 2011 11:53:40 +0000 (+1100) Subject: [rt #71309] fix combine=0 fill color anti-aliasing X-Git-Tag: v0.85_02~26 X-Git-Url: http://git.imager.perl.org/imager.git/commitdiff_plain/7a98c44258fc1de05eab8ff856be1d96ed92c13e [rt #71309] fix combine=0 fill color anti-aliasing --- diff --git a/render.im b/render.im index e17da1cf..4f9bbd38 100644 --- a/render.im +++ b/render.im @@ -333,8 +333,8 @@ i_render_fill(i_render *r, i_img_dim x, i_img_dim y, i_img_dim width, } else if (*src) { for (ch = 0; ch < im->channels; ++ch) { - IM_WORK_T work = (destc->channel[ch] * (IM_SAMPLE_MAX - *src) - + srcc->channel[ch] * *src) / IM_SAMPLE_MAX; + IM_WORK_T work = (destc->channel[ch] * (255 - *src) + + srcc->channel[ch] * *src) / 255.0; destc->channel[ch] = IM_LIMIT(work); } } diff --git a/t/t20fill.t b/t/t20fill.t index e060b0fa..bdf57252 100644 --- a/t/t20fill.t +++ b/t/t20fill.t @@ -1,6 +1,6 @@ #!perl -w use strict; -use Test::More tests => 156; +use Test::More tests => 157; use Imager ':handy'; use Imager::Fill; @@ -638,6 +638,34 @@ SKIP: } } +{ # RT 71309 + my $fount = Imager::Fountain->simple(colors => [ '#804041', '#804041' ], + positions => [ 0, 1 ]); + my $im = Imager->new(xsize => 40, ysize => 40); + $im->box(filled => 1, color => '#804040'); + my $fill = Imager::Fill->new + ( + combine => 0, + fountain => "linear", + segments => $fount, + xa => 0, ya => 0, + xb => 40, yb => 40, + ); + $im->polygon(fill => $fill, + points => + [ + [ 0, 0 ], + [ 40, 20 ], + [ 20, 40 ], + ] + ); + # the bug magnified the differences between the source and destination + # color, blending between the background and fill colors here only allows + # for those 2 colors in the result. + # with the bug extra colors appeared along the edge of the polygon. + is($im->getcolorcount, 2, "only original and fill color"); +} + sub color_close { my ($c1, $c2) = @_;