note 19123 deleted from function.imagecolorallocate by danbrown
| From: | danbrown@php.net | Date: | Fri, 24 Apr 2009 12:52:59 +0000 |
| Subject: | note 19123 deleted from function.imagecolorallocate by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153676@lists.php.net to get a copy of this message | ||
Note Submitter: bisqwit at iki dot fi
----
Looks like this function only allows allocating of 256 distinct colours.
So this code:
<?php
$im = ImageCreate(500,200);
for($a=0; $a<500; $a++)
{
$c = 128 + sin($a) * 127;
ImageLine($im, $a,0, $a,199, ImageColorAllocate($im, $c,$c,$c));
}
ob_start();
ImageJpeg($im, '', 75);
$s = ob_get_contents();
ob_end_clean();
header('Content-type: image/jpeg');
header('Content-length: '.strlen($s));
print $s;
will make an image that has changing colours at
the first 256 pixel columns only. The rest are gray.