Page 1 of 1

Problems with transparency/antialias/png.. need urgent help

Posted: Tue Aug 16, 2005 1:30 pm
by Zacay
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.
http://www.zacay.se/image/

Method 1:

Code: Select all

<?
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:

Code: Select all

<?
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?

Posted: Tue Aug 16, 2005 1:39 pm
by feyd
  1. using

    Code: Select all

    tags helps us, help you.
    [*]Moved to [b]Graphics[/b].[/list]

Posted: Sat Aug 20, 2005 4:29 pm
by Zacay
Anyone please?