Permalink
Browse files

- mixing qtype scaling now sets all channels of a pixel to zero if

   the pixel has zero coverage (zero alpha).  This should produce more
   compressible output files.
   http://rt.cpan.org/Ticket/Display.html?id=32324
  • Loading branch information...
1 parent 07d9c63 commit 2757bad050d6a50f125b1e553eec784be1257db6 Tony Cook committed Apr 1, 2008
Showing with 34 additions and 2 deletions.
  1. +5 −0 Changes
  2. +23 −0 scale.im
  3. +6 −2 t/t40scale.t
View
@@ -62,6 +62,11 @@ Bug fixes:
parameters.
http://rt.cpan.org/Ticket/Display.html?id=29937
+ - mixing qtype scaling now sets all channels of a pixel to zero if
+ the pixel has zero coverage (zero alpha). This should produce more
+ compressible output files.
+ http://rt.cpan.org/Ticket/Display.html?id=32324
+
Imager 0.62 - 10 December 2007
===========
View
@@ -178,6 +178,17 @@ i_scale_mixing(i_img *src, int x_out, int y_out) {
xscale_row[x].channel[ch] = IM_LIMIT(val);
}
}
+ else {
+ /* rather than leaving any color data as whatever was
+ originally in the buffer, set it to black. This isn't
+ any more correct, but it gives us more compressible
+ image data.
+ RT #32324
+ */
+ for (ch = 0; ch < alpha_chan; ++ch) {
+ xscale_row[x].channel[ch] = 0;
+ }
+ }
xscale_row[x].channel[alpha_chan] = IM_LIMIT(accum_row[x].channel[alpha_chan]+0.5);
}
}
@@ -275,6 +286,12 @@ IM_SUFFIX(horizontal_scale)(IM_COLOR *out, int out_width,
out[out_x].channel[ch] = IM_LIMIT(val);
}
}
+ else {
+ for (ch = 0; ch < alpha_chan; ++ch) {
+ /* See RT #32324 (and mention above) */
+ out[out_x].channel[ch] = 0;
+ }
+ }
out[out_x].channel[alpha_chan] = IM_LIMIT(IM_ROUND(accum[alpha_chan]));
}
else {
@@ -315,6 +332,12 @@ IM_SUFFIX(horizontal_scale)(IM_COLOR *out, int out_width,
out[out_x].channel[ch] = IM_LIMIT(val);
}
}
+ else {
+ for (ch = 0; ch < alpha_chan; ++ch) {
+ /* See RT #32324 (and mention above) */
+ out[out_x].channel[ch] = 0;
+ }
+ }
out[out_x].channel[alpha_chan] = IM_LIMIT(IM_ROUND(accum[alpha_chan]));
}
else {
View
@@ -1,9 +1,9 @@
#!perl -w
use strict;
-use Test::More tests => 227;
+use Test::More tests => 228;
BEGIN { use_ok(Imager=>':all') }
-use Imager::Test qw(is_image);
+use Imager::Test qw(is_image is_color4);
#require "t/testtools.pl";
@@ -194,6 +194,10 @@ SKIP:
my $cmp = $out->copy;
$out->rubthrough(src => $sc);
is_image($out, $cmp, "check we get the right image after scaling");
+
+ # we now set alpha=0 pixels to zero on scaling
+ is_color4($sc->getpixel('x' => 39, 'y' => 39), 0, 0, 0, 0,
+ "check we set alpha=0 pixels to zero on scaling");
}
{ # scale_calculate

0 comments on commit 2757bad

Please sign in to comment.