Solved

In C# How do stop an animated GIF after a single loop

Posted on 2004-03-26
2
3,817 Views
Last Modified: 2011-09-20
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.PictureBox();
   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.
0
Comment
Question by:khrispy
2 Comments
 
LVL 2

Accepted Solution

by:
codewiz51 earned 250 total points
ID: 10693351
Normally, the looping is set during the construction of the gif.  You should be able to load the file into an animated gif editor and set the looping.  GIF89a supports extensions for looping once, n times or never.

You can also check out the System.Drawing.ImageAnimator class.  It offers some specialized methods you can use to pace your gif and turn off animation using the static StopAnimate method.
0
 

Author Comment

by:khrispy
ID: 10719013
Codewiz51,

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.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
System.Security 2 27
Install Problem 13 31
What can cause the styling on a .NET site to not be found? 17 26
Release Dynamically Allocated Memory in C# 3 26
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question