ID:               39273
 User updated by:  seth at pricepages dot org
 Reported By:      seth at pricepages dot org
 Status:           Bogus
 Bug Type:         GD related
 Operating System: Mac 10.4
 PHP Version:      5.1.6
 Assigned To:      pajoye
 New Comment:

But that has one of the bugs that I pointed out: boolean 
transparency. The original doesn't have that problem.


Previous Comments:
------------------------------------------------------------------------

[2006-10-28 14:04:59] [EMAIL PROTECTED]

Use the code I just gave you, it does create the resized version (by
copying):
http://blog.thepimp.net/misc/39273_out.png




------------------------------------------------------------------------

[2006-10-28 13:15:45] seth at pricepages dot org

I ran your code before I posted my last comment, but I still 
don't know what you are implying. The results are exactly as I 
expect them to be.

If this bug is bogus, please tell me how I can create an 
enlarged version of test.png? It isn't possible without 
applying a fix.

------------------------------------------------------------------------

[2006-10-28 10:49:54] [EMAIL PROTECTED]

"I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other."

You are not aware that your image is *NOT* fully black.

Background color (the transparent color) is not the same than a color
with a ALPHA component. Please run the code I gave you, read the
results (like the values of the channels in these two pixels, or any
other).



------------------------------------------------------------------------

[2006-10-27 17:22:07] seth at pricepages dot org

I am aware that the image is fully black, except for 
variations in alpha. That is why this is a bug related to 
the alpha channel and not any other.

Well, I went in and fixed it myself. The problem was in the 
function gdImageGetTrueColorPixel(). It assumed that palette 
images always have binary transparency, with a correct value 
in im->transparent. Because my source image didn't have a 
correct value in im->transparent, it was always marked as 
opaque.

This line:

return gdTrueColorAlpha(im->red[p], im->green[p], im->blue
[p], (im->transparent == p) ? gdAlphaTransparent : 
gdAlphaOpaque);

Needs to be changed to:

return gdTrueColorAlpha(im->red[p], im->green[p], im->blue
[p], (im->transparent == p) ? gdAlphaTransparent : im->alpha
[p]);

Making this patch also fixes the same bug in 
imagecopyresampled(), and who knows what else.


Although, I would recommend using gdTrueColorAlpha() at the 
appropriate point(s) in gdImageCopyResized() instead of 
gdImageGetTrueColorPixel(). This would eliminate an extra 
function call, branch, and color lookup.

------------------------------------------------------------------------

[2006-10-27 14:01:12] [EMAIL PROTECTED]

There is nothing wrong in imagecopyresize (or imagecopy).

The problem you have is the misunderstanding of what is the background
color, the alpha channel and alpha blending.

Your original image has many black colors, one is transparent (what you
consider as background), and the other with various transparency
levels.
Try the code below, it will explain you what is your image and how it
works.
<?php
$small = imagecreatefrompng('39273.png');
print_r(imagecolortransparent($small));
$width = 300;
$height = 300;
$srcW = imagesx($small);
$srcH = imagesy($small);

print_r(imagecolorsforindex($small, imagecolorat($small, 0,0)));

// one of the ""black"" pixel
print_r(imagecolorsforindex($small, imagecolorat($small, 37,1)));
imagecolortransparent($small, 1);

$img = imagecreatetruecolor($width, $height);
$trans = imagecolorresolve($img,255,255,255);
imagefill($img, 0,0, $trans);
imagecolortransparent($img, $trans);

imagecopyresized($img, $small, 0,0, 0,0, $width, $height, $srcW,
$srcH);
imagepng($img, '1.png');


------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/39273

-- 
Edit this bug report at http://bugs.php.net/?id=39273&edit=1

Reply via email to