Csharp/C Sharp/2D Graphics/Gif Animation

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Play Gif animation

<source lang="csharp"> using System; using System.Collections.Generic;

   using System.ruponentModel;
   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));
   }
 }
          
      </source>