Re: problem with imagecolorsforindex()

From: Date: Thu, 25 Jan 2001 03:02:30 +0000
Subject: Re: problem with imagecolorsforindex()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-36550@lists.php.net to get a copy of this message
> 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. Those are the values of the infamous Netscape 216 "web-safe" colors... Check the docs for anything about 216 or "web-safe" > 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 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#36550) next »