Quantcast
Channel: WP快站
Viewing all articles
Browse latest Browse all 233

Gif image looping only once

$
0
0

I was trying to figure out how to make sure that a GIF image what I put to my WindowsForm project through picturebox going to loop only once and still without finding an answer even after going through as many sites with this problem as I could find.

I know that with using of picturebox programmer lossing control of looping (in case that you set looping only once when creating the gif animation in editor) and I somehow have to get a code which will basically say when gif animation gets to some certain frame...in my case to last one which is number 7 and gets there in 430 milliseconds (190,40,40,40,40,40,40) the gif animation going to be Disposed.

So the whole idea was to make a simple game with balloons which will have an animation with flying and animation with exploding after pressing of the mouse on the ballon_grey picture box.

It would look like that:

private void timer1_Tick(object sender, EventArgs e){    //makes balloon going up    balloon_grey.Location = new Point(balloon_grey.Location.X, balloon_grey.Location.Y - 3);     }private void balloon_grey_Click(object sender, EventArgs e){    //forces balloon_grey picturebox to change animation to balloon_grey_explosion.gif    balloon_grey.Image = Image.FromFile("balloon_grey_explosion.gif");    //gets the amount of frames from the gif animation...don't know if this is needed to reach the goal    int frames = Properties.Resources.balloon_grey_explosion.GetFrameCount(FrameDimension.Time);}

Thank you for your time and any advice about the problem.


Viewing all articles
Browse latest Browse all 233

Trending Articles