icicleman Posted January 10, 2007 Share Posted January 10, 2007 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 layersimagecopy($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 discimagepng($im, "final.png");// Deallocate memory of imageimagedestroy($im); Help ??? Link to comment https://forums.phpfreaks.com/topic/33667-gd2-help/ Share on other sites More sharing options...
DarkendSoul Posted January 11, 2007 Share Posted January 11, 2007 try this.[code]<?php$im = @imagecreatetruecolor(200, 200) or die("Cannot Initialize new GD image stream");imagealphablending( $im, false );$col = imagecolorallocatealpha( $im, 0, 0, 0, 127 );imagefilledrectangle( $im, 0, 0, 200, 200, $col );imagealphablending( $im, true );imageSaveAlpha($im, true);// 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 layersimagecopy($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);// Save image to discimagepng($im, "final.png");// Deallocate memory of imageimagedestroy($im);?>[/code]Untested, but a collaboration of things found on google... Link to comment https://forums.phpfreaks.com/topic/33667-gd2-help/#findComment-157788 Share on other sites More sharing options...
icicleman Posted January 11, 2007 Author Share Posted January 11, 2007 Thanks for the help Link to comment https://forums.phpfreaks.com/topic/33667-gd2-help/#findComment-157789 Share on other sites More sharing options...
DarkendSoul Posted January 11, 2007 Share Posted January 11, 2007 I'm guessing that means it works then? Link to comment https://forums.phpfreaks.com/topic/33667-gd2-help/#findComment-157793 Share on other sites More sharing options...
icicleman Posted January 11, 2007 Author Share Posted January 11, 2007 Yes Link to comment https://forums.phpfreaks.com/topic/33667-gd2-help/#findComment-157795 Share on other sites More sharing options...
DarkendSoul Posted January 11, 2007 Share Posted January 11, 2007 No problem, please remember to mark all posts that have been solved as "Solved".Its a nice little script that this forum has. :) Link to comment https://forums.phpfreaks.com/topic/33667-gd2-help/#findComment-157799 Share on other sites More sharing options...
icicleman Posted January 11, 2007 Author Share Posted January 11, 2007 Oh and where is that? Link to comment https://forums.phpfreaks.com/topic/33667-gd2-help/#findComment-157807 Share on other sites More sharing options...
DarkendSoul Posted January 11, 2007 Share Posted January 11, 2007 [code]http://www.phpfreaks.com/forums/index.php/topic,118758.0.html[/code]Bottom of the page. :) Link to comment https://forums.phpfreaks.com/topic/33667-gd2-help/#findComment-157811 Share on other sites More sharing options...
icicleman Posted January 11, 2007 Author Share Posted January 11, 2007 I cant see that Link to comment https://forums.phpfreaks.com/topic/33667-gd2-help/#findComment-157819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.