note 19123 added to function.imagecolorallocate
| From: | bisqwit at iki dot fi | Date: | Sat, 16 Feb 2002 18:20:37 +0000 |
| Subject: | note 19123 added to function.imagecolorallocate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26702@lists.php.net to get a copy of this message | ||
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.
--
http://www.php.net/manual/en/function.imagecolorallocate.php
http://master.php.net/manage/user-notes.php?action=edit+19123
http://master.php.net/manage/user-notes.php?action=delete+19123
http://master.php.net/manage/user-notes.php?action=reject+19123