[SDL] Animation Woes

Doug biteme at bitbasher.net
Mon Sep 25 18:44:34 PDT 2006


In article <116832210609230300k43c21cf6xd780010b67eec05c at mail.gmail.com>, 
sahanthegamecreator at gmail.com says...
>How would I go about showing an animation in SDL which has 60 frames? It is
>saved as a GIF.

There's no one "right" way to do it, but it might be easier to convert the GIF 
file to some frames first.  I'd use PaintShopPro (or something similar) to 
extract all the GIF frames out into say something like JPEG frames.

Once you have the files in a format that something like SDL_image can handle, 
then you can just read in the frames and blit them to the SDL surface at your 
desired frame rate.

I've been doing this with motion-JPEG files.  Those are AVI files inwhich the 
frames are JPEG frames instead of more complex frames such as MPEG, DivX, 
xvid, etc.  I selected motion-JPEG because the camera I'm using captures 
videos this way, and motion-JPEG AVI files are fairly easy to create from the 
single frame data.

SDL_image will handle GIF files, but I don't think it can handle animated 
GIFs.  If you don't want your app to have 60 little frame files on the disk, 
you can always cull all the frames into a single resource file (with some kind 
of frame index) and just read/seek through the "frame file" yourself.

Doug.






More information about the SDL mailing list