Jump to content


Photo

GD2 Help


  • Please log in to reply
No replies to this topic

#1 christianmatthew

christianmatthew
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 28 February 2006 - 04:35 PM

I've been working on something which takes multiple PNG Transparent images and layers them on top of each other to make another transparent image. So far it kind or works, however the background turns completely black and I'm not sure what to do from here.

So my main question is, how do I make a transparent background without killing my antialising (I don't want to set a transparent color and place that color as background)?

HERE IS MY CODE:


$im = @imagecreatetruecolor(200, 200)
or die("Cannot Initialize new GD image stream");

// Loading Images
$red = imagecreatefrompng("red.png");
imagealphablending($red, true);
imagesavealpha($red, true);
$blue = imagecreatefrompng("blue.png");
imagealphablending($blue, true);
imagesavealpha($blue, true);
$green = imagecreatefrompng("green.png");
imagealphablending($green, true);
imagesavealpha($green, true);


// Flattening layers
imagecopy($blue, $red, 0, 0, 0, 0, 200, 200);
imagecopy($green, $blue, 0, 0, 0, 0, 200, 200);
imagecopy($im, $green, 0, 0, 0, 0, 200, 200);
imagealphablending($im, true);
imagesavealpha($im, true);


// Save image to disc
imagepng($im, "final.png");

// Deallocate memory of image
imagedestroy($im);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users