|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-01-18 10:40 UTC] henus at mail dot ru
Description:
------------
After using imagefilter (IMG_FILTER_COLORIZE) on transparent png image the result color of translucent pixels is wrong.
I.e. the edge of non-transparent part of image, which contain translucent antialiasing area - wrong colored.
Reproduce code:
---------------
<?
$mask=imagecreatefrompng("mask.png"); // http://fort-ross.ru/henus/gd/mask.png (mask for colorize, contain translucent)
$imagewidth=imagesx($mask);
$imageheight=imagesy($mask);
$imagemain=imagecreatetruecolor($imagewidth,$imageheight);
imagealphablending($mask, TRUE);
imagealphablending($imagemain, TRUE);
$color=imagecolorallocate($imagemain, 0, 0, 0);
imagefill($imagemain, 0, 0, $color);
imagefilter($mask, IMG_FILTER_COLORIZE, -255, -255, 0);
imagecopy($imagemain, $mask, 0, 0, 0, 0, $imagewidth, $imageheight);
imagepng($imagemain,"result_incorrect.png"); // http://www.fort-ross.ru/henus/gd/result_incorrect.png
imagedestroy($mask);
imagedestroy($imagemain);
?>
Expected result:
----------------
The result image - absolutely black square
Actual result:
--------------
The result image - black square with gray line (on the edge of mask image)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 03:00:01 2025 UTC |
php-5.2.0\ext\gd\libgd\gd.c Lines 3682-3685: new_pxl = gdImageColorAllocateAlpha(src, (int)r, (int)g, (int)b, a); if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, (int)r, (int)g, (int)b, a); } ....should be without alpha...correction fo my previous post about php-5.2.0\ext\gd\libgd\gd.c Lines 3682-3688: new_pxl = gdImageColorAllocateAlpha(src, (int)r, (int)g, (int)b, a); if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, (int)r, (int)g, (int)b, a); } if ((y >= 0) && (y < src->sy)) { gdImageSetPixel (src, x, y, new_pxl); in gdImageSetPixel src should be absolutely transparent, with alpha=127 differently it mix colors.