PHP Developers Network
http://forums.devnetwork.net/

Problems with transparency/antialias/png.. need urgent help
http://forums.devnetwork.net/viewtopic.php?f=32&t=36982
Page 1 of 1

Author:  Zacay [ Tue Aug 16, 2005 1:30 pm ]
Post subject:  Problems with transparency/antialias/png.. need urgent help

Hello,

I am tryign to create a transparent image and draw a white line that has to me smooth.
This should be a problem right?
Well I got serious problems with it.
Let me show you:

This url has my example images and the code below (I couldn't use the [img] tag to show the php generated images.


Method 1:
Syntax: [ Download ] [ Hide ]
<?

header("content-type: image/png");



// Create empty image

$image = imagecreatetruecolor(500, 500);



// The image background transparent

imagealphablending($image, false);

imagesavealpha($image, true);

$bgcolor = imagecolorallocatealpha($image, 255, 255, 255, 127);

imagefill($image, 0, 0, $bgcolor);



// Drawing the lines

imageantialias($image, true);

$white = imagecolorallocate($image, 255, 255, 255);

imageline($image, 0, 0, 250, 500, $white);

imageline($image, 0, 100, 500, 500, $white);

imageline($image, 0, 300, 500, 400, $white);

imageline($image, 0, 400, 500, 450, $white);



// Output the image

imagepng($image);

?>


Method 2:
Syntax: [ Download ] [ Hide ]
<?

header("content-type: image/png");



// Create empty image

$image = imagecreatetruecolor(500, 500);



// The image background transparent

imagealphablending($image, true);

imagecolortransparent($image, 0); // 0 = black, the default color then create an image



// Drawing the lines

imageantialias($image, true);

$white = imagecolorallocate($image, 255, 255, 255);

imageline($image, 0, 0, 250, 500, $white);

imageline($image, 0, 100, 500, 500, $white);

imageline($image, 0, 300, 500, 400, $white);

imageline($image, 0, 400, 500, 450, $white);



// Output the image

imagepng($image);

?>


So any ideas?
Am I doing this the wrong way?

Author:  feyd [ Tue Aug 16, 2005 1:39 pm ]
Post subject: 


Author:  Zacay [ Sat Aug 20, 2005 4:29 pm ]
Post subject: 


Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/