khrispy
asked on
In C# How do stop an animated GIF after a single loop
My C# program runs an animated GIFs. Is there any way to have it stop the animated GIF after a single loop (or a specified number of loops) through all the frames in the GIF?
Currently, I'm running the animated GIF's in a small PictureBox control that is on my main form:
this.AnimationGIF = new System.Windows.Forms.Pictu reBox();
AnimationGIF.Image = Image.FromFile(GIF filename);
The above will display and run the animated GIF continuously in the picture box. I currently stop it by running the above as a thread and stopping it after a fixed number of seconds. I would like it to stop automatically after a set number of loops through all the frames.
Thanks.
Currently, I'm running the animated GIF's in a small PictureBox control that is on my main form:
this.AnimationGIF = new System.Windows.Forms.Pictu
AnimationGIF.Image = Image.FromFile(GIF filename);
The above will display and run the animated GIF continuously in the picture box. I currently stop it by running the above as a thread and stopping it after a fixed number of seconds. I would like it to stop automatically after a set number of loops through all the frames.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for you suggestion although it didn't quite work. I had given you the points (you can keep them) before completely testing out your suggestion in my code. I went ahead and created some animated GIFs that loops only once. Unfortunatley when they are loaded onto the picturebox control they run continuously. The control seems to ignore the looping property of the GIF. The same problem occurs using the ImageAnimator class.
When I open up the animated GIFs on a web browser they run only a single loop as designed.