Doc #53175 [Opn->Asn]: Confusing (ambiguous) imagecolorallocate return value when color is black

From: Date: Tue, 26 Oct 2010 21:09:30 +0000
Subject: Doc #53175 [Opn->Asn]: Confusing (ambiguous) imagecolorallocate return value when color is black
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5425@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: Open +Status: Assigned Type: Documentation Problem Package: Documentation problem Operating System: Windows 7/2003 Server PHP Version: 5.2.14 -Assigned To: +Assigned To: kalle Block user comment: N Previous Comments: ------------------------------------------------------------------------ [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

« previous php.doc.bugs (#5425) next »