1 Replies - 159 Views - Last Post: 05 February 2012 - 07:21 AM Rate Topic: -----

Topic Sponsor:

#1 JizzaDaMan  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 119
  • Joined: 23-May 11

split gifs

Posted 05 February 2012 - 06:28 AM

HI, I want to split a gif image into its constituent frames, so I can use them to animate a character in a basic game.
Can anyone point me towards an app that will do it for me? I've been searching for a while now and haven't been able to find anything :(

Thanks for any help
:boat:

Is This A Good Question/Topic? 0
  • +

Replies To: split gifs

#2 Sergio Tapia  Icon User is offline

  • Is that a raincoat?
  • member icon

Reputation: 1012
  • View blog
  • Posts: 3,816
  • Joined: 27-January 10

Re: split gifs

Posted 05 February 2012 - 07:21 AM

First if you're using something like XNA, here's something I wrote to get you started with using a spritesheet to animate something on screen:

http://www.dreaminco...have-a-seizure/

Now to answer your question about splitting a GIF into individual frames:

I copied this from the intertubes:

public static IEnumerable<Bitmap> GetImages(Stream stream)
{
    using (var gifImage = Image.FromStream(stream))
    {
        var dimension = new FrameDimension(gifImage.FrameDimensionsList[0]); //gets the GUID
        var frameCount = gifImage.GetFrameCount(dimension); //total frames in the animation
        for (var index = 0; index < frameCount; index++)
        {
            gifImage.SelectActiveFrame(dimension, index); //find the frame
            yield return (Bitmap) gifImage.Clone(); //return a copy of it
        }
    }
}

This post has been edited by Sergio Tapia: 05 February 2012 - 07:23 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1