PHP GD - Transparent areas goes black
I am trying to make very simple ISO engine in PHP, my attempts to render in correct place, order etc are succeding however the images drawn, for some reason are black where it should be transparent. PNG files have transparency channel and I am using following test code: http://pastebin.com/TXk4LkJ8 The code is just rough draft.
Files are just 3 faces of an block with dimensions as follows: top - 44x22; sides:23x34
Thank you for your help and I hope the question is clear enough.
Edit: Here is the problem: http://dl.dropbox.com/u/10530011/obraz开发者_高级运维ki/isofail.png
Edit: [SOLVED] For some reason I had to save the images as GIF to make it work. Thank you for your help.
You should call these two functions before saving the png image, imagealphablending() and imagesavealpha():
imagealphablending( $image, false );
imagesavealpha( $image, true );
This answer suggests two things:
imagealphablending
should be set to false in order to preserve alpha channels- You should set the colour you want transparent (in this case black) as transparent:
$black = imagecolorallocate($image, 0, 0, 0);
imagecolortransparent($image, $black);
Do these help?
精彩评论