Problem with image transparency and gdImageCopyResampled
| From: | Albert Rovira | Date: | Fri, 13 Jun 2008 16:10:02 +0000 |
| Subject: | Problem with image transparency and gdImageCopyResampled | ||
| Groups: | php.gd.devel | ||
| Request: | Send a blank email to php-gd-devel+get-451@lists.php.net to get a copy of this message | ||
Hi,
I need to load a .gif image and save as resized truecolor .png image.
I wrote this code:
gdImage srcimage = gdscript.gdImageCreateFromGifPtr(out.toByteArray());
gdImage aux = gdscript.gdImageCreateTrueColor(targetWidth,targetHeight);
gdscript.gdImageCopyResampled(aux,srcimage,0,0,0,0,aux.getSx(),aux.getSy(),srcimage.getSx(),srcimage.getSy());
String name = System.currentTimeMillis() +".png";
byte[] png = gdscript.gdImagePngBuf(srcimage);
FileOutputStream out = new FileOutputStream(name);
out.write(png);
out.close();
But destination image lost transparency of the original image (it has black background). Any method to mantain the transparency ? Can dImageAlphaBlending() help me ? (Seem that only work with draw functions not with copy image functions).
Thanks,
Albert.