note 114675 added to function.imagepalettetotruecolor
| From: | walf | Date: | Fri, 21 Mar 2014 06:20:18 +0000 |
| Subject: | note 114675 added to function.imagepalettetotruecolor | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198993@lists.php.net to get a copy of this message | ||
The backwards compatibility example does not preserve transparency. You must first wipe out the
default black background on the new image:
<?php
// Backwards compatiblity
if (!function_exists('imagepalettetotruecolor')) {
function imagepalettetotruecolor(&$src) {
if (imageistruecolor($src)) {
return true;
}
$dst = imagecreatetruecolor(imagesx($src), imagesy($src));
imagealphablending($dst, false);//prevent blending with default black
$transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127);//change the RGB values if
you need, but leave alpha at 127
imagefilledrectangle($dst, 0, 0, $imagesx($src), imagesy($src), $transparent);//simpler than flood
fill
imagealphablending($dst, true);//restore default blending
imagecopy($dst, $src, 0, 0, 0, 0, imagesx($src), imagesy($src));
imagedestroy($src);
$src = $dst;
return true;
}
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 150.101.23.241
----
Manual Page -- http://php.net/manual/en/function.imagepalettetotruecolor.php
Edit -- https://master.php.net/note/edit/114675
Del: integrated -- https://master.php.net/note/delete/114675/integrated
Del: useless -- https://master.php.net/note/delete/114675/useless
Del: bad code -- https://master.php.net/note/delete/114675/bad+code
Del: spam -- https://master.php.net/note/delete/114675/spam
Del: non-english -- https://master.php.net/note/delete/114675/non-english
Del: in docs -- https://master.php.net/note/delete/114675/in+docs
Del: other reasons-- https://master.php.net/note/delete/114675
Reject -- https://master.php.net/note/reject/114675
Search -- https://master.php.net/manage/user-notes.php