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
AD
Administrator
Syncfusion Team
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
>
AD
Administrator
Syncfusion Team
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
> >
>
AD
Administrator
Syncfusion Team
December 22, 2002 02:01 AM UTC
Thank you
AD
Administrator
Syncfusion Team
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
> > >
> >
>