[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] about animation gif file



On Saturday 24 September 2005 03:17 am, Kris Schnee wrote:
> flya flya wrote:
> > some gif file has many frames to paly animation,Can pygame load these
> > frames? and do the animation?
> 
> Yes. Load the GIF as a Surface. Make a bunch of Rect objects 
> representing where in the image each frame is. Use those as clipping 
> regions.

Are you saying that the loader will automatically load the animated
GIF by separating each frame out spatially on the Surface? If so, it
has to be pretty smart, and these aren't sufficient instructions for
figuring out what it does.

We're talking about a multi-frame format in the GIF, not frames spread
out on a static GIF.  There is no such thing as "where in the image
each frame is" -- they are in the same place, they are separated by
*time* (i.e. frame number), and therefore by where they are stored in
the file, but there's no such thing as a separate clipping rectangle
for each frame as you seem to be imagining.

Most single-frame image tools only load the *first* frame of an animated
GIF and ignore the rest.  I would naively suspect that this is what will
happen if you try to load one with PIL (which I think is what you must
do to load any image into PyGame unless it's in Microsoft BMP format --
which I must say seems like a strange choice of native format ;-) ),
but I haven't tried it myself, so I'm not sure.

You can do some trickery on the command line to change an animated GIF
to the kind of format you are thinking of, using ImageMagick, though
I'd have to spend some time with the man pages to figure out how. You
might be able to do the same with PIL, though I have doubts, since PIL
doesn't provide all that much support for GIF.

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com