colormap on ver 5.5.7 and 6.4.2
Posted: 2008-07-25T09:08:42-07:00
Hello All,
When I applied colormap to a transparent gif on 5.5.7, I reset all of the colors and then set the transparency and it worked.
This no longer worked in 6.4.2. After fussing around a little, I got it to work by not resetting the transparent color #ffffff and then not calling transparent.
Here is some test code to convert the gray scale gif to all yellow.
#$logo is a transparent #ffffff gif
my $t;
my $col = $logo->Get('colors');
print "\nColorspace ". $logo->Get('colorspace');
for (my $j=0; $j < $col; $j++)
{
$t = $logo->Get("colormap[$j]");
print "\n\nOriginal colormap[$j]= $t";
if ($t !~ /65535,65535,65535/)
{
$logo->Set("colormap[$j]"=>"#ffff00");
}
else
{
#$logo->Set("colormap[$j]"=>'#ffffff');
}
print qq{\nNew colormap[$j]= }.$logo->Get("colormap[$j]");
}
#$logo->Transparent(color=>'#ffffff');
my $p = $logo->SyncImage();
print "\nColorspace ". $logo->Get('colorspace');
for (my $j=0; $j < $col; $j)
{
print qq{\ncolormap[$j]= }.$logo->Get("colormap[$j]");
}
$logo->Write("../htdocs/temp/temp.gif");
Here is the output:
Colorspace RGB
Original colormap[0]= 65535,65535,65535,0
New colormap[0]= 65535,65535,65535,0
Original colormap[1]= 52428,52428,52428,0
New colormap[1]= 65535,65535,0,0
Original colormap[2]= 39321,39321,39321,0
New colormap[2]= 65535,65535,0,0
Original colormap[3]= 26214,26214,26214,0
New colormap[3]= 65535,65535,0,0
Original colormap[4]= 13107,13107,13107,0
New colormap[4]= 65535,65535,0,0
Original colormap[5]= 0,0,0,0
New colormap[5]= 65535,65535,0,0
Original colormap[6]= 65535,65535,65535,65535
New colormap[6]= 65535,65535,65535,65535
It seems that 4th parameter from the get colormap determines the transparent color.
If you use,
$logo->Transparent(color=>'#ffffff');
and then query the results, get colormap shows 65535,65535,65535,0 so it does not seem to actually set the transparency.
I believe this is what causes SyncImage to not work. Hope this is helpful.
Craig
When I applied colormap to a transparent gif on 5.5.7, I reset all of the colors and then set the transparency and it worked.
This no longer worked in 6.4.2. After fussing around a little, I got it to work by not resetting the transparent color #ffffff and then not calling transparent.
Here is some test code to convert the gray scale gif to all yellow.
#$logo is a transparent #ffffff gif
my $t;
my $col = $logo->Get('colors');
print "\nColorspace ". $logo->Get('colorspace');
for (my $j=0; $j < $col; $j++)
{
$t = $logo->Get("colormap[$j]");
print "\n\nOriginal colormap[$j]= $t";
if ($t !~ /65535,65535,65535/)
{
$logo->Set("colormap[$j]"=>"#ffff00");
}
else
{
#$logo->Set("colormap[$j]"=>'#ffffff');
}
print qq{\nNew colormap[$j]= }.$logo->Get("colormap[$j]");
}
#$logo->Transparent(color=>'#ffffff');
my $p = $logo->SyncImage();
print "\nColorspace ". $logo->Get('colorspace');
for (my $j=0; $j < $col; $j)
{
print qq{\ncolormap[$j]= }.$logo->Get("colormap[$j]");
}
$logo->Write("../htdocs/temp/temp.gif");
Here is the output:
Colorspace RGB
Original colormap[0]= 65535,65535,65535,0
New colormap[0]= 65535,65535,65535,0
Original colormap[1]= 52428,52428,52428,0
New colormap[1]= 65535,65535,0,0
Original colormap[2]= 39321,39321,39321,0
New colormap[2]= 65535,65535,0,0
Original colormap[3]= 26214,26214,26214,0
New colormap[3]= 65535,65535,0,0
Original colormap[4]= 13107,13107,13107,0
New colormap[4]= 65535,65535,0,0
Original colormap[5]= 0,0,0,0
New colormap[5]= 65535,65535,0,0
Original colormap[6]= 65535,65535,65535,65535
New colormap[6]= 65535,65535,65535,65535
It seems that 4th parameter from the get colormap determines the transparent color.
If you use,
$logo->Transparent(color=>'#ffffff');
and then query the results, get colormap shows 65535,65535,65535,0 so it does not seem to actually set the transparency.
I believe this is what causes SyncImage to not work. Hope this is helpful.
Craig