note 109787 modified in function.imagefilledrectangle by danbrown
| From: | danbrown@php.net | Date: | Fri, 31 Aug 2012 15:49:24 +0000 |
| Subject: | note 109787 modified in function.imagefilledrectangle by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190339@lists.php.net to get a copy of this message | ||
I wanted to clear an image, and set it to full transparent. imagefilledrectangle()
seems to ignore alpha channel and alpha blending. Use imagefill()
instead: <?php $w =
imagesx($final); $h = imagesy($final); $grande =
imagecreatetruecolor($w, $h); // Alpha blending on to use channel
alpha imagealphablending($grande, true); // Allocate a transparent
color and fill the new image with it. // Without this the image will have a black
background instead // of being transparent. $transparent =
imagecolorallocatealpha($grande, 0, 0, 0, 127); // transparent alpha will be
_ignored_: imagefilledrectangle($grande, 0, 0, $w, $h,
$transparent); // ok, transparent will be used and set whole alpha channel to
transparent: imagefill($grande, 0, 0, $transparent); ?>
--was--
I wanted to clear an image, and set it to full transparent.
imagefilledrectangle() seems to ignore alpha channel and alpha blending.
Use imagefill() instead:
<php
$w = imagesx($final);
$h = imagesy($final);
$grande = imagecreatetruecolor($w, $h);
// Alpha blending on to use channel alpha
imagealphablending($grande, true);
// Allocate a transparent color and fill the new image with it.
// Without this the image will have a black background instead
// of being transparent.
$transparent = imagecolorallocatealpha($grande, 0, 0, 0, 127);
// transparent alpha will be _ignored_:
imagefilledrectangle($grande, 0, 0, $w, $h, $transparent);
// ok, transparent will be used and set whole alpha channel to transparent:
imagefill($grande, 0, 0, $transparent);
?>
http://php.net/manual/en/function.imagefilledrectangle.php