We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback
Platform : WinForms
Category : Bitmaps and Images

How can I read individual frames from an animated image?

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:

Once you have the dimension, you can get the frame count:

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.

Sample Application w/Source Code C# or VB

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon