VC# - Draw Image a GIF animation using code
-
I have a GIF animation which i want to paint in a picturebox. I know that a picturebox is capable of displaying GIF animations when you preload them in the designer etc (i have tried it). But I want to paint it (DrawImage it) on the picturebox control at runtime (I dont want to assign an image directly as it wont work for my project). Is there any way apart from using a timer to alternate between the various images of the animation. Thanks for all the help!!
-
I have a GIF animation which i want to paint in a picturebox. I know that a picturebox is capable of displaying GIF animations when you preload them in the designer etc (i have tried it). But I want to paint it (DrawImage it) on the picturebox control at runtime (I dont want to assign an image directly as it wont work for my project). Is there any way apart from using a timer to alternate between the various images of the animation. Thanks for all the help!!
Wow - that's news to me. I've never seen a picturebox play an animated gif and I know there are CP articles on how to get one to play in c#.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Wow - that's news to me. I've never seen a picturebox play an animated gif and I know there are CP articles on how to get one to play in c#.
Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
Nope, just checked, animates gif in both .Net 1.1, and 2.0. I we never knew...
My current favourite word is: Bauble!
-SK Genius
-
I have a GIF animation which i want to paint in a picturebox. I know that a picturebox is capable of displaying GIF animations when you preload them in the designer etc (i have tried it). But I want to paint it (DrawImage it) on the picturebox control at runtime (I dont want to assign an image directly as it wont work for my project). Is there any way apart from using a timer to alternate between the various images of the animation. Thanks for all the help!!
Anyway, had you looked, im sure you would have found:
System.Drawing.ImageAnimator.Animate(Image, onFrameChanged);
andSystem.Drawing.ImageAnimator.UpdateFrames(Image);
Animate will use the animations of timing, and call you Frame Chenged event handler (in this case called 'onFrameChanged'), when its time for the next frame. And UpdateFrames will just move on to the next frame, regardless of the time. Google them to find out exactly how they work.My current favourite word is: Bauble!
-SK Genius
-
Anyway, had you looked, im sure you would have found:
System.Drawing.ImageAnimator.Animate(Image, onFrameChanged);
andSystem.Drawing.ImageAnimator.UpdateFrames(Image);
Animate will use the animations of timing, and call you Frame Chenged event handler (in this case called 'onFrameChanged'), when its time for the next frame. And UpdateFrames will just move on to the next frame, regardless of the time. Google them to find out exactly how they work.My current favourite word is: Bauble!
-SK Genius
-
I have a GIF animation which i want to paint in a picturebox. I know that a picturebox is capable of displaying GIF animations when you preload them in the designer etc (i have tried it). But I want to paint it (DrawImage it) on the picturebox control at runtime (I dont want to assign an image directly as it wont work for my project). Is there any way apart from using a timer to alternate between the various images of the animation. Thanks for all the help!!
Check out this article Strip Images From Animated Gif[^].The article shows how to access a specific frame in gif image. So what you need split the source into frames ,and show them separately using timer ...
DevIntelligence.com - My blog for .Net Developers
-
But how can you help me how to display animated gif in picturebox for windows mobile 6 using C# Thanks in advance
-
But how can you help me how to display animated gif in picturebox for windows mobile 6 using C# Thanks in advance