note 58932 added to function.imagecopy
| From: | ragnar_40k at hotmail dot com | Date: | Mon, 21 Nov 2005 11:17:13 +0000 |
| Subject: | note 58932 added to function.imagecopy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98882@lists.php.net to get a copy of this message | ||
Here a function to make holes into images:
// Set the alpha channel for a part of an image (it ignores the canvas alpha atm).
// $img_canvas - 32-bit true color image w/ alpha channel
// $img_mask - 8-bit gray scale image (white parts will be masked transparent in the canvas).
// This relies on the current pixel format:
// (high byte) -> (alpha channel} {red} {green} {blue} <- (low byte)
function mask($img_canvas, $img_mask, $dst_x, $dst_y)
{
$old_blendmode = imagealphablending($img_canvas, FALSE);
$width = imagesx($img_mask);
$heigth = imagesy($img_mask);
$mask_x = 0;
$x = $dst_y;
while ($mask_x<$width)
{
$mask_y = 0;
$y = $dst_y;
while ($mask_y<$heigth)
{
imagesetpixel($img_canvas, $x, $y,
((imagecolorat($img_mask, $mask_x, $mask_y) >> 1) << 24) |
(imagecolorat($img_canvas, $x, $y) & 0x00FFFFFF));
++$mask_y;
++$y;
}
++$mask_x;
++$x;
}
imagealphablending($img_canvas, $old_blendmode);
}
----
Manual Page -- http://www.php.net/manual/en/function.imagecopy.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58932
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58932&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58932&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58932&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58932&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58932&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58932&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58932&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58932&report=yes
Search -- http://master.php.net/manage/user-notes.php