note 46219 added to function.imagecolorset
| From: | dadedotcatemaildotit at osu1 dot php dot net | Date: | Sat, 02 Oct 2004 20:47:30 +0000 |
| Subject: | note 46219 added to function.imagecolorset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-77761@lists.php.net to get a copy of this message | ||
this is helpful if you would like to implement a color theme system in your website... try it out
Davide Candiloro Italy
function colorize ($pngpath, $r, $g, $b)
/*
REQUIRES: $pngpath to be a valid path of a greyscale PNG-8 image with 64 colors palette
$r, $g, $b to be integers in the range 0..255
EFFECTS: returns the png image colorized with the color represented by $r, $g, $b.
*/
{
header("Content-type: image/png");
$im = imagecreatefrompng("images/table.png");
imagetruecolortopalette($im, FALSE, 256);
for ($c = 0; $c < 64; $c++){ /*64 is the number of colors in the PNG-8 palette*/
$col = imagecolorsforindex($im, $c);
imagecolorset ( $im, $c, $r*$col['red']/256, $g*$col['green']/256,
$b*$col['blue']/256); /*replaces original greyscale palette with a colorized one*/
}
imagepng($im);
imagedestroy($im);
}
----
Manual Page -- http://www.php.net/manual/en/function.imagecolorset.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46219
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46219&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46219&report=yes
Search -- http://master.php.net/manage/user-notes.php