|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-10-26 23:09 UTC] kalle@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: kalle
[2010-11-07 05:18 UTC] kalle@php.net
[2010-11-07 05:18 UTC] kalle@php.net
-Status: Assigned
+Status: Closed
[2010-11-07 05:18 UTC] kalle@php.net
[2020-02-07 06:08 UTC] phpdocbot@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 08 07:00:01 2026 UTC |
Description: ------------ According to the online documentation the imagecolorallocate function returns "A color identifier or FALSE if the allocation failed". The confusion comes when I try to allocate black color, passing 0x0 to all the three color components. The function always returns 0, which means FALSE, but it looks like the identifier is valid. Future use of it in other gd functions leads to successful results. I also noticed in the online documentation that in prior to 5.1.3 versions of PHP this function returns -1 if the allocation failed, so it is eather a problem in the documentation or bug in the gd extension I am using. Test script: --------------- Code: header("Content-type: image/png"); $im = imagecreatetruecolor(300, 100); $font_color = imagecolorallocate($im, 0, 0, 0); // Black $bg_color = imagecolorallocate($im, 255, 255, 0); // Yellow imagefill($im, 0, 0, $bg_color); imagestring($im, 10, 40, 40, "font color identifier is: $font_color", $font_color); imagepng($im); imagedestroy($im); Output: Yellow image with black colored string: "font color identifier is: 0" Expected result: ---------------- The imagecolorallocate function should not return zero value for valid color identifiers or the documentation should be changed.