We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to display a GIF animation?

Thread ID:

Created:

Updated:

Platform:

Replies:

2166 Dec 19,2002 10:44 AM UTC Aug 17,2003 03:47 AM UTC WinForms 4
loading
Tags: FAQ
UESTC
Asked On December 19, 2002 10:44 AM UTC

I have tried PictureBox and Panel, but none of them can diaplay the animation. Both of them just displayed the first frame of the animation, why? how to solve it? thanx

Administrator [Syncfusion]
Replied On December 20, 2002 12:45 PM UTC

study this: System.Drawing.ImageAnimator this class makes what you want. sorry that i don't have time to make you an example! > I have tried PictureBox and Panel, but none of them can diaplay the animation. > Both of them just displayed the first frame of the animation, why? how to solve it? > thanx >

Administrator [Syncfusion]
Replied On December 20, 2002 02:35 PM UTC

Example [Visual Basic, C#] This Windows Forms application demonstrates how to draw an animated image to the screen. The image is created from the animated GIF file SampleAnimation.gif located in the same folder as the application. [Visual Basic] Imports System Imports System.Drawing Imports System.Windows.Forms Public Class animateImage Inherits Form 'Create a Bitmpap Object. Private animatedImage As New Bitmap("SampleAnimation.gif") Private currentlyAnimating As Boolean = False 'This method begins the animation. Public Sub AnimateImage() If Not currentlyAnimating Then 'Begin the animation only once. ImageAnimator.Animate(animatedImage, _ New EventHandler(AddressOf Me.OnFrameChanged)) currentlyAnimating = True End If End Sub Private Sub OnFrameChanged(o As Object, e As EventArgs) 'Force a call to the Paint event handler. Me.Invalidate() End Sub Protected Overrides Sub OnPaint(e As PaintEventArgs) 'Begin the animation. AnimateImage() 'Get the next frame ready for rendering. ImageAnimator.UpdateFrames() 'Draw the next frame in the animation. e.Graphics.DrawImage(Me.animatedImage, New Point(0, 0)) End Sub Public Shared Sub Main() Application.Run(New animateImage()) End Sub End Class [C#] using System; using System.Drawing; using System.Windows.Forms; public class animateImage : Form { //Create a Bitmpap Object. Bitmap animatedImage = new Bitmap("SampleAnimation.gif"); bool currentlyAnimating = false; //This method begins the animation. public void AnimateImage() { if (!currentlyAnimating) { //Begin the animation only once. ImageAnimator.Animate(animatedImage, new EventHandler(this.OnFrameChanged)); currentlyAnimating = true; } } private void OnFrameChanged(object o, EventArgs e) { //Force a call to the Paint event handler. this.Invalidate(); } protected override void OnPaint(PaintEventArgs e) { //Begin the animation. AnimateImage(); //Get the next frame ready for rendering. ImageAnimator.UpdateFrames(); //Draw the next frame in the animation. e.Graphics.DrawImage(this.animatedImage, new Point(0, 0)); } public static void Main() { Application.Run(new animateImage()); } } [C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button in the upper-left corner of the page. > > study this: > System.Drawing.ImageAnimator > this class makes what you want. > > sorry that i don't have time to make you an example! > > > > I have tried PictureBox and Panel, but none of them can diaplay the animation. > > Both of them just displayed the first frame of the animation, why? how to solve it? > > thanx > > >

Administrator [Syncfusion]
Replied On December 22, 2002 02:01 AM UTC

Thank you

Administrator [Syncfusion]
Replied On August 17, 2003 03:47 AM UTC

> Example > [Visual Basic, C#] This Windows Forms application demonstrates how to draw an animated image to the screen. The image is created from the animated GIF file SampleAnimation.gif located in the same folder as the application. > > [Visual Basic] > Imports System > Imports System.Drawing > Imports System.Windows.Forms > Public Class animateImage > Inherits Form > 'Create a Bitmpap Object. > Private animatedImage As New Bitmap("SampleAnimation.gif") > Private currentlyAnimating As Boolean = False > 'This method begins the animation. > Public Sub AnimateImage() > If Not currentlyAnimating Then > 'Begin the animation only once. > ImageAnimator.Animate(animatedImage, _ > New EventHandler(AddressOf Me.OnFrameChanged)) > currentlyAnimating = True > End If > End Sub > Private Sub OnFrameChanged(o As Object, e As EventArgs) > 'Force a call to the Paint event handler. > Me.Invalidate() > End Sub > Protected Overrides Sub OnPaint(e As PaintEventArgs) > 'Begin the animation. > AnimateImage() > 'Get the next frame ready for rendering. > ImageAnimator.UpdateFrames() > 'Draw the next frame in the animation. > e.Graphics.DrawImage(Me.animatedImage, New Point(0, 0)) > End Sub > Public Shared Sub Main() > Application.Run(New animateImage()) > End Sub > End Class > [C#] > using System; > using System.Drawing; > using System.Windows.Forms; > public class animateImage : Form { > //Create a Bitmpap Object. > Bitmap animatedImage = new Bitmap("SampleAnimation.gif"); > bool currentlyAnimating = false; > //This method begins the animation. > public void AnimateImage() { > if (!currentlyAnimating) { > //Begin the animation only once. > ImageAnimator.Animate(animatedImage, new EventHandler(this.OnFrameChanged)); > currentlyAnimating = true; > } > } > private void OnFrameChanged(object o, EventArgs e) { > //Force a call to the Paint event handler. > this.Invalidate(); > } > protected override void OnPaint(PaintEventArgs e) { > //Begin the animation. > AnimateImage(); > //Get the next frame ready for rendering. > ImageAnimator.UpdateFrames(); > //Draw the next frame in the animation. > e.Graphics.DrawImage(this.animatedImage, new Point(0, 0)); > } > public static void Main() { > Application.Run(new animateImage()); > } > } > [C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button in the upper-left corner of the page. > > > > > > study this: > > System.Drawing.ImageAnimator > > this class makes what you want. > > > > sorry that i don't have time to make you an example! > > > > > > > I have tried PictureBox and Panel, but none of them can diaplay the animation. > > > Both of them just displayed the first frame of the animation, why? how to solve it? > > > thanx > > > > > >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;