#36218 [Opn->Bgs]: weird behaviour using imagecolorallocate very often
| From: | johannes@php.net | Date: | Mon, 30 Jan 2006 23:11:25 +0000 |
| Subject: | #36218 [Opn->Bgs]: weird behaviour using imagecolorallocate very often | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-92669@lists.php.net to get a copy of this message | ||
ID: 36218
Updated by: johannes@php.net
Reported By: jumo at gmx dot de
-Status: Open
+Status: Bogus
Bug Type: GD related
Operating System: debian
PHP Version: 5.1.2
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
You're alway allocating a new color to a palette based
image. Either register just the colors you use or create
the image using imagecreatetruecolor()
Previous Comments:
------------------------------------------------------------------------
[2006-01-30 23:54:52] jumo at gmx dot de
excuse my bad english!
------------------------------------------------------------------------
[2006-01-30 23:46:58] jumo at gmx dot de
Description:
------------
I want to draw many squares on a PNG image, wich have changing color.
after some correct drawed there is only one color used.
Reproduce code:
---------------
<?php
$bigsize = 500;
$colours = array( 'FF0000' , '00FF00' );
header("Content-type: image/png");
$im = imagecreate( $bigsize * 2 , 50 );
for( $j = 0; $j < $bigsize ; $j++ ) {
$k = $j % count( $colours );
$r = hexdec( substr( $colours[ $k ] , 0 , 2 ) );
$g = hexdec( substr( $colours[ $k ] , 2 , 2 ) );
$b = hexdec( substr( $colours[ $k ] , 4 , 2 ) );
$fill = imagecolorallocate($im, $r , $g , $b );
imagefilledrectangle( $im , 2*$j , 0 , 2*$j+1 , 50 , $fill );
}
imagepng($im);
imagedestroy($im);
?>
Expected result:
----------------
a bar with red and green vertical stripes wich have changing colors.
Actual result:
--------------
the right half of the bar is green.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36218&edit=1