problem with imagecolorsforindex()

From: Date: Wed, 24 Jan 2001 17:00:22 +0000
Subject: problem with imagecolorsforindex()
Groups: php.general 
Request: Send a blank email to php-general+get-36434@lists.php.net to get a copy of this message
Hello, I have this code in a php script, which takes all pixels from a PNG image and produces a second "image" with random numbers in HTML format this time. (an example can be found at http://www.cyprusnews.org/sub/prog2.php). Instead of getting ALL shades of red from the pallette, I get only 8-9 shades: those corresponding to values of red with R value 0,51,102,153,204,255. Anyone can explain that? Here's the code: $im = imagecreatefrompng("vac3.png"); $dimx = imagesx($im); $dimy = imagesy($im); for ($f=0; $f<$dimy; $f+=5) { for ($i=0; $i<$dimx; $i+=5) { $colsat = imagecolorat($im,$i,$f); $colss = imagecolorsforindex($im,$colsat); $r = dechex($colss[red]); $g = dechex($colss[green]); $b = dechex($colss[blue]); if ($colss[red] < 16) $r = "0" . $r; // assure that 13 becomes #0D and not D if ($colss[green] < 16) $g = "0" . $g; if ($colss[blue] < 16) $b = "0" . $b; $rndn = rand(0,9); echo "<font color=#".$r.$g.$b.">".$rndn."0"; } echo "<br>"; } ImageDestroy($im); thanks subbie

« previous php.general (#36434) next »