note 113049 added to function.imagefilter
| From: | yoann at yoone dot eu | Date: | Thu, 22 Aug 2013 14:04:40 +0000 |
| Subject: | note 113049 added to function.imagefilter | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196051@lists.php.net to get a copy of this message | ||
Here is an alternative to IMG_FILTER_COLORIZE filter, but taking the alpha parameter of each pixel
in account.
<?php
function rgba_colorize(&$img, $color)
{
imagesavealpha($img, true);
imagealphablending($img, true);
$img_x = imagesx($img);
$img_y = imagesy($img);
for ($x = 0; $x < $img_x; ++$x)
{
for ($y = 0; $y < $img_y; ++$y)
{
$rgba = imagecolorsforindex($img, imagecolorat($img, $x, $y));
$color_alpha = imagecolorallocatealpha($img, $color[0], $color[1], $color[2],
$rgba['alpha']);
imagesetpixel($img, $x, $y, $color_alpha);
imagecolordeallocate($img, $color_alpha);
}
}
}
?>
----
Server IP: 69.147.83.199
Probable Submitter: 90.8.67.101
----
Manual Page -- http://php.net/manual/en/function.imagefilter.php
Edit -- https://master.php.net/note/edit/113049
Del: integrated -- https://master.php.net/note/delete/113049/integrated
Del: useless -- https://master.php.net/note/delete/113049/useless
Del: bad code -- https://master.php.net/note/delete/113049/bad+code
Del: spam -- https://master.php.net/note/delete/113049/spam
Del: non-english -- https://master.php.net/note/delete/113049/non-english
Del: in docs -- https://master.php.net/note/delete/113049/in+docs
Del: other reasons-- https://master.php.net/note/delete/113049
Reject -- https://master.php.net/note/reject/113049
Search -- https://master.php.net/manage/user-notes.php