Page 1 of 1
couple of gd questions
Posted: Fri May 16, 2003 12:07 pm
by toms100
rite im a bit puzzled.
is it possible to create animated images in gd (i have png and jpg generation available to me)
and how do you do transparent backgrounds?
i cant find the manual for gd or any tutorials on this subject!!
many thanks
Tom
Posted: Fri May 16, 2003 4:11 pm
by cirox
as far as I know, gd is only for static images, sorry pal. But as an idea, you could use javascript, generate a bunch of static images, and have it flip between them. never really used this work around, but I've read about it, and I know it works (seen it in action).
also, transparency in gd is a real pain, and will only work for image formats that permit it (i.e. PNG, since that's all you got). How I do it is, I choose a color that I don't really need (something really specific, like 241, 234, 113 or something), make that color transparent, and imagefill the image with that color. It only works for simple images where that color isn't used though, but at least it's a start. here's the code.
їcode]
$im = imagecreate (100,100);
$color = ImageColorAllocate ($im, 241, 234, 113);
$trans = ImageColorTransparent($im, $color);
imagefill($im, 0,0,$trans);
ї/code]
That's all i can do for ya, that code's from the sprite renderer in my game object. I think there is a way to cut out the image better using this, but it might be tricky (setting up a loop to check each pixel's color, if the color is the transparent color, use imagesetpixel to put the newly transparent color into it. This is really slow and bloated and tricky, but it would work...) Just get to know the PHP manual, it's your friend (that's how i learned php lol). Let me know if this helps. ciro out
Posted: Sat May 17, 2003 2:58 am
by toms100
i really need to generate a whole animated image (if possible) so sticking some together wouldnt do

anyway thanks for that very usefull help!
Tom