Doc #53175 [Asn->Csd]: Confusing (ambiguous) imagecolorallocate return value when color is black
| From: | kalle@php.net | Date: | Sun, 07 Nov 2010 04:18:52 +0000 |
| Subject: | Doc #53175 [Asn->Csd]: Confusing (ambiguous) imagecolorallocate return value when color is black | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5486@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53175&edit=1
ID: 53175
Updated by: kalle@php.net
Reported by: orlin dot hristov at gmail dot com
Summary: Confusing (ambiguous) imagecolorallocate return
value when color is black
-Status: Assigned
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: Windows 7/2003 Server
PHP Version: 5.2.14
Assigned To: kalle
Block user comment: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2010-11-07 05:18:46] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=305144
Log: Fixed bug #53175 (Confusing (ambiguous) imagecolorallocate return
value when color is black)
------------------------------------------------------------------------
[2010-10-26 22:50:18] orlin dot hristov at gmail dot com
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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53175&edit=1