note 75298 added to function.imagecreatetruecolor
| From: | RichardDaveyrich at corephp dot co dot uk | Date: | Tue, 22 May 2007 23:50:57 +0000 |
| Subject: | note 75298 added to function.imagecreatetruecolor | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126831@lists.php.net to get a copy of this message | ||
If you want to create a *transparent* PNG image, where the background is fully transparent, and all
draw operations happen on-top of this, then do the following:
<?php
$png = imagecreatetruecolor(800, 600);
imagesavealpha($png, true);
$trans_colour = imagecolorallocatealpha($png, 0, 0, 0, 127);
imagefill($png, 0, 0, $trans_colour);
$red = imagecolorallocate($png, 255, 0, 0);
imagefilledellipse($png, 400, 300, 400, 300, $red);
header("Content-type: image/png");
imagepng($png);
?>
What you do is create a true colour image, make sure that the alpha save-state is on, then fill the
image with a colour that has had its alpha level set to fully transparent (127).
The resulting PNG from the code above will have a red circle on a fully transparent background (drag
the image into Photoshop to see for yourself)
----
Server IP: 194.145.210.4
Probable Submitter: 88.96.15.166
----
Manual Page -- http://www.php.net/manual/en/function.imagecreatetruecolor.php
Edit -- https://master.php.net/note/edit/75298
Del: integrated -- https://master.php.net/note/delete/75298/integrated
Del: useless -- https://master.php.net/note/delete/75298/useless
Del: bad code -- https://master.php.net/note/delete/75298/bad+code
Del: spam -- https://master.php.net/note/delete/75298/spam
Del: non-english -- https://master.php.net/note/delete/75298/non-english
Del: in docs -- https://master.php.net/note/delete/75298/in+docs
Del: other reasons-- https://master.php.net/note/delete/75298
Reject -- https://master.php.net/note/reject/75298
Search -- https://master.php.net/manage/user-notes.php