当前位置: 首页>>代码示例>>C#>>正文


C# ImageAnimator.Animate方法代码示例

本文整理汇总了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());
    }
}
开发者ID:.NET开发者,项目名称:System.Drawing,代码行数:49,代码来源:ImageAnimator.Animate

示例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));
    }
  }
开发者ID:C#程序员,项目名称:System.Drawing,代码行数:34,代码来源:ImageAnimator.Animate


注:本文中的System.Drawing.ImageAnimator.Animate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。