Re: Re: Trying to create a colortable - what am I missing here?

From: Date: Tue, 12 May 2009 13:45:01 +0000
Subject: Re: Re: Trying to create a colortable - what am I missing here?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-292481@lists.php.net to get a copy of this message
Thodoris wrote: > >> דניאל דנון wrote: >>> I've tried to make a color table, but I am missing something. not in the >>> color-table-code itself, but in somewhere else... I just can't find... >> >> untested but try.. >> >> // 4096*4096 = 16777216 = FFFFFF+1 >> $im = imagecreate(4096, 4096); >> $white = imagecolorallocate($im, 0, 0, 0); >> $r = $g = $b = $x = $y = 0; >> $max = 255; >> while ($r <= $max) { >> while ($g <= $max) { >> while ($b <= $max) { >> $n = imagecolorallocate($im, $r, $g, $b); >> imagesetpixel($im, $x, $y, $n); >> $x = $x == 4096 ? 0 : $x+1; >> $y = $y == 4096 ? 0 : $y+1; >> $b++; >> } >> $b = 0; >> $g++; >> } >> $g = 0; >> $r++; >> } >> header("Content-Type: image/png"); >> imagepng($im); >> imagedestroy($im); >> >> > > Never used image manipulation with PHP but this is giving me a black image. > You probably need $im = imagecreatetruecolor(4096,4096); Also be aware that creating a truecolor image 4096 pixels square is going to take a LOT of memory, and it will take a while to download to the client, AND it is 4096 pixels square!!!!! That's a fair bit bigger than most screens... I suspect the OP is going to have to rethink this... -- Peter Ford phone: 01580 893333 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent

« previous php.general (#292481) next »