Fix f/ PNG-24 Alpha Transparency using GDLIB resizing
authorTim Laqua <tlaqua@users.mediawiki.org>
Wed, 22 Aug 2007 00:30:16 +0000 (00:30 +0000)
committerTim Laqua <tlaqua@users.mediawiki.org>
Wed, 22 Aug 2007 00:30:16 +0000 (00:30 +0000)
includes/media/Bitmap.php

index dfa794b..c43e571 100644 (file)
@@ -167,9 +167,18 @@ class BitmapHandler extends ImageHandler {
 
                        $src_image = call_user_func( $loader, $srcPath );
                        $dst_image = imagecreatetruecolor( $physicalWidth, $physicalHeight );
+                       
+                       //PNG-24 Alpha Trans  
+                       $background = imagecolorallocate($dst_image, 0, 0, 0);  //Make $dst_image all black 
+                       ImageColorTransparent($dst_image, $background);         //Make $dst_image transparent 
+                       imagealphablending($dst_image, false); 
+
                        imagecopyresampled( $dst_image, $src_image,
                                                0,0,0,0,
                                                $physicalWidth, $physicalHeight, imagesx( $src_image ), imagesy( $src_image ) );
+
+                       imagesavealpha($dst_image, true);
+                       
                        call_user_func( $saveType, $dst_image, $dstPath );
                        imagedestroy( $dst_image );
                        imagedestroy( $src_image );