Playing Gifs in .NET...

UCM

Well-known member
Joined
Jan 1, 2003
Messages
135
Location
Colorado, usa
How do you play an animated gif in .NET...

Like on a form, panel, button, toolbar, label, or picturebox ( id rather not use a picturebox if possible )
 
I dont believe theres any built-in support for showing the animation part of an animated gif. You can load an animated gif as a single image but to use the other images as an animation will require parsing the gif yourself or using a 3rd party control.

Or, you could use the WebBrowser control :p

-Nerseus
 
lol, I know about the AXWebBrower control... This is a very nifty control indeed.... but the thing is that I dont want to have to use it to achieve an animated gif....

Your idea of parsing the images out of the gif sounds rock on...

Does anyone have any ideas on how I could retrieve the multiple images stored in a gif?

Or even retrieve the animated gif info ( looping, first image, transparent color, ect )
 
Heres a link to a post on another forum that has VB6 code to parse an animated gif and display it with transparency. I think he got the code from someone else and ported it to VB6 (or for his own needs). Regardless, it works and could get you started.

Click here to download.

-Nerseus
 
This is very possible with just the .NET framework. It has full support for reading images with multiple frames in. I knocked up some code to get all the frames and their display times, but then came across the following URL where they seem to have wrapped everything nicely to run animated gifs in a ThreadPool.

The ImageAnimator class in the System.Drawing namespace is what you need.

http://www.c-sharpcorner.com/Code/2002/Nov/ThreadPoolGifs.asp
 
Not if there wasnt one on the site. I believe there are some free web C# to VB translators out there though, could be worth searching.
 
Back
Top