GDI+ has direct support for reading and outputting animated images.
To get at the individual frames, you can use the image’s FrameDimensionList, and then call SelectActiveFrame, by passing in the dimension and the zero based frame index.
First, create a new FrameDimension object:
FrameDimension dimension = new System.Drawing.Imaging.FrameDimension(myImage.FrameDimensionsList);
Once you have the dimension, you can get the frame count:
int frameCount = myImage.GetFrameCount(dimension);
Now, that you know the frame count of the image, you can call SelectActiveFrame by passing in the dimension and the frame index (zero based).
If the image is being viewed at runtime, then the call to SelectActiveFrame will set the current frame, and then begin to loop through again (unless it is a jpeg image). The attached sample works around this by saving the image to a MemoryStream for display – thereby capturing the one frame that is chosen.