|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-02-21 05:01 UTC] seth at pricepages dot org
Description:
------------
I am filling the background of an image with a transparent red
(it shouldn't have an effect on the rest of the drawing). Over
it, I'm drawing a black, semi-transparent, square.
Reproduce code:
---------------
$img = imagecreatetruecolor(100, 100);
imagealphablending($img, true);
$trans = imagecolorresolvealpha($img,255,0,0, 127);
imagefill($img, 0,0, $trans);
$pTrans = imagecolorresolvealpha($img, 0,0,0, 64);
imagefilledrectangle($img, 10, 10, 50, 50, $pTrans);
imagealphablending($img, false);
imagesavealpha($img,true);
header('Content-Type: image/png');
imagepng($img);
Expected result:
----------------
I would expect the resulting image to be 100% transparent,
except for a grey, 50% transparent square.
Actual result:
--------------
Instead, the black is mixed with the red to form a dark-red
semi-transparent square. The red color should not be there,
because it was 100% transparent.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 04:00:02 2025 UTC |
Well, I ran the following code against the newly released C library, and things seem to work as expected. GD 2.0.33 seg faults for some reason, but 2.0.34 fixes that. So, the bug will be fixed when you sync with PHP's code? gdImagePtr img; int trans, pTrans; FILE *fp; img = gdImageCreateTrueColor(100, 100); gdImageAlphaBlending(img, 1); trans = gdImageColorResolveAlpha(img,255,0,0, 127); gdImageFill(img, 0,0, trans); pTrans = gdImageColorResolveAlpha(img, 0,0,0, 64); gdImageFilledRectangle(img, 10, 10, 50, 50, pTrans); gdImageAlphaBlending(img, 0); gdImageSaveAlpha(img,1); fp = fopen("test.png", "w"); gdImagePng(img, fp); fclose(fp); gdImageDestroy(img);