Subject: | "transparent" somehow alters color table |
There is somehow strange behavior while applying transparency to images
loaded from JPG/GIF files. To summarize:
my $closest = $img->colorClosest( $r, $g, $b );
$img->transparent( $img->colorClosest( $r, $g, $b ) );
# Now $img->transparent == $closest
# but $img->transparent != $img->colorClosest( $r, $g, $b )
I'm attaching the failing test.
Subject: | transp.t |
use strict;
use warnings;
use Test::More tests => 10;
use_ok('GD');
my $im = GD::Image->newFromGif("class.gif");
$im->transparent( -1 );
is($im->transparent, -1, 'image is not transparent');
my $closest = $im->colorClosest( 24, 53, 62 );
$im->transparent( $im->colorClosest( 24, 53, 62 ) );
ok( $im->transparent == $closest, 'transparency preserves RGB before' );
ok( $im->transparent == $im->colorClosest( 24, 53, 62 ), 'transparency preserves RGB after' );
$im = GD::Image->newFromJpeg("class.jpg");
$im->transparent( -1 );
is($im->transparent, -1, 'image is not transparent');
$closest = $im->colorClosest( 24, 53, 62 );
$im->transparent( $im->colorClosest( 24, 53, 62 ) );
ok( $im->transparent == $closest, 'transparency preserves RGB before' );
ok( $im->transparent == $im->colorClosest( 24, 53, 62 ), 'transparency preserves RGB after' );
$im = GD::Image->newFromJpeg("dupa.jpg");
$im->transparent( -1 );
is($im->transparent, -1, 'image is not transparent');
$closest = $im->colorClosest( 24, 53, 62 );
$im->transparent( $im->colorClosest( 24, 53, 62 ) );
ok( $im->transparent == $closest, 'transparency preserves RGB before' );
ok( $im->transparent == $im->colorClosest( 24, 53, 62 ), 'transparency preserves RGB after' );