本文整理汇总了C#中System.Drawing.ImageAnimator.Animate方法的典型用法代码示例。如果您正苦于以下问题:C# ImageAnimator.Animate方法的具体用法?C# ImageAnimator.Animate怎么用?C# ImageAnimator.Animate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了ImageAnimator.Animate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Bitmap
//引入命名空间
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());
}
}
示例2: Form1
//引入命名空间
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form
{
private Bitmap bmp;
public Form1()
{
bmp = new Bitmap("winter.jpg");
ImageAnimator.Animate(bmp, new EventHandler(this.OnFrameChanged));
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
}
public static void Main(){
Application.Run(new Form1());
}
private void OnFrameChanged(object o, EventArgs e)
{
this.Invalidate();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
ImageAnimator.UpdateFrames();
e.Graphics.DrawImage(this.bmp, new Point(0, 0));
}
}