Re: ImageColorTransparent Problem
| From: | Jason Davidson | Date: | Mon, 09 Aug 2004 04:37:35 +0000 |
| Subject: | Re: ImageColorTransparent Problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-193167@lists.php.net to get a copy of this message | ||
Does IE even support PNG transparncy properly anyways??? maybe thats the
issue here?
Jason
"Kevin" <rh_kevin@yahoo.co.uk> wrote:
>
> Hi,
>
> I am having PHP Version 4.3.4 with GD 2.0.15 compatible and PNG support
> enabled.
>
> My problem with the following code is that the image produced be this code
> is not transparent. It has a black background. I have viewed it in IE 6 and
> its not transparent.
>
> Can someone help me how to make this image transparent?
>
> <?php
>
> // imagecolorallocate ( resource image, int red, int green, int blue)
> // imagettftext ( resource image, float size, float angle, int x, int y, int
> color, string fontfile, string text)
> // imagepng ( resource image [, string filename])
> // imagecreatetruecolor ( int x_size, int y_size)
> // imagecolortransparent ( resource image [, int color])
>
> header("Content-type: image/png");
> $im = imagecreatetruecolor(400,600); // i have used imagecreatetruecolor in
> place of imagecreate()
> $bg = imagecolorallocate($im, 0, 0, 0);
> imagecolortransparent($im, $bg); // this function makes the color
> transparent specified in $bg.
>
> $j=0;
> $k = 0;
> $r = 1;
> $g = 100;
> $b = 20;
>
> for($i=1;$i<=50;$i++)
> {
> if($r > 255)
> $r = 1;
> if($g > 255)
> $g = 100;
> if($b > 255)
> $b = 20;
>
> $textcolor = imagecolorallocate($im, $r, $g, $b);
> $r = $r * 3;
> $g = $g + 10;
> $b = $b + 20;
>
> imagettftext($im, 10, 0, 0, $j, $textcolor, "fonts/2.ttf", "Row number
> : $i | Color = " . $textcolor);
> $j=$j+12;
> }
> imagepng($im,"kk.png");
> ?>
>
> Thanks a lot for reading this far.
> --
> Kevin
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>