ID: 46466 User updated by: laszlo dot janszky at gmail dot com Reported By: laszlo dot janszky at gmail dot com Status: Bogus Bug Type: GD related Operating System: windows xp PHP Version: 5.2.6 New Comment:
http://hu.php.net/imagecolorallocate I had read the documentation before I sent the report. I wrote an if in my code like this: $c=imagecolorallocate($image,$r,$b,$g); imagettftext($image,$s,$a,$l,$t,$c,'xfont.ttf',$char); $c was false, but the $r,$b,$g parameters were valid, and they weren's the same as the background. I checked it with another ttf file, but nothing changed. I'll check it tomorrow without rand manually, but I'm afraid it's caused by that function. Previous Comments: ------------------------------------------------------------------------ [2008-11-02 22:23:42] [EMAIL PROTECTED] what about checking the colors you get? Like the random values may be duplicated or ends using the bg color. There is no bug in either the ttf or the color function. Try to predefine the colors to verify it. ------------------------------------------------------------------------ [2008-11-02 21:59:54] laszlo dot janszky at gmail dot com Description: ------------ I'm calling imagecolorallocate and imagettftext functions with random parameters in a loop, but after some call the imagecolorallocate function returns FALSE. I checked the random parameters, but nothing strange about them. I think the bug is associated with the rand function, because the more I call the rand function, the earlier the bug comes in loop. If I delete the rand from the 5 times I call, and replace it with constant number, the bug comes later in cycle. With this settings it's about character 'w', but not on a constant place, somtimes 'x' or 'y'. Reproduce code: --------------- $text=str_split('0123456789abcdefghijklmnopqrstvwxyz',1); $image=imagecreate(600,50); $bgcolor=imagecolorallocate($image,0,200,130); foreach($text as $char) { $r=rand(0,30); $b=255-rand(0,30); $g=138+rand(-15,15); $a=rand(0,10); $l=15+$len*15; $t=35+rand(-5,5); $s=20+rand(-2,2); imagettftext($image,$s,$a,$l,$t,imagecolorallocate($image,$r,$b,$g),'xfont.ttf',$char); $len++; } header("Expires: Mon,26 Jul 1997 05:00:00 GMT"); header("Last-Modified: ".gmdate("D,d M Y H:i:S")." GMT"); header("Cache-Control: no-store,no-cache,must-revalidate"); header("Cache-Control: post-check=0,pre-check=0",false); header("Pragma: no-cache"); header("Content-type: image/png"); imagepng($image); imagedestroy($image); Expected result: ---------------- I expect to get an image with characters '0123456789abcdefghijklmnopqrstvwxyz' one after the other with different(random) angles and colour. Actual result: -------------- I got an image with characters '0123456789abcdefghijklmnopqrstvw', so not the complete character list. And didn't get any error messages or notices with error_reporting(2047). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46466&edit=1
