Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hello everybody,

I have a gif image, which loop one time and it stop.

I load that image into the picturebox.

My problem is that the image keep looping. I want it to stop after it loop the first time. How can I do that ?

I use the following code to load the image.

thanks.

I wrote following code :
VB
Dim y As New System.Guid
Dim x As Drawing.Imaging.FrameDimension = New Drawing.Imaging.FrameDimension(y)
y = PictureBox1.Image.FrameDimensionsList(0)

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
   If PictureBox1.Image.SelectActiveFrame(x, 0) = 19 Then
      PictureBox1.Enabled = False
      Timer1.Stop()
   End If
End Sub

And this error occurs:
A generic error occurred in GDI+.
Posted
Updated 15-Mar-12 7:48am
v2

1 solution

Data on how fast the image animates and whether to loop or not is embedded in the image itself, and the PictureBox cannot access this directly.

However, the ImageAnimator object, found in the System.Drawing namespace, can access it. I don't have any experience using it so I cannot provide any code for you, but you should be able to find information and examples on the web.
 
Share this answer
 
Comments
maryam ak 15-Mar-12 12:26pm    
I wrote following code :
dim y As New System.Guid
Dim x As Drawing.Imaging.FrameDimension = New Drawing.Imaging.FrameDimension(y)
y = PictureBox1.Image.FrameDimensionsList(0)
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If PictureBox1.Image.SelectActiveFrame(x, 0) = 19 Then
PictureBox1.Enabled = False
Timer1.Stop()
End If
End Sub

And this error occurs:
A generic error occurred in GDI+.
Kschuler 15-Mar-12 13:49pm    
It's better to post more information (like this code) by clicking the Improve Question link, and adding it to your original question. That way everyone who reads the questions sees it right away. I copied it for you this time.
Sergey Alexandrovich Kryukov 15-Mar-12 14:12pm    
Let's start with a simple advice: forget PictireBox and never remember. Everything else goes next.
--SA
Sergey Alexandrovich Kryukov 15-Mar-12 14:12pm    
My 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900