Play Gif animation : Gif Animation « 2D Graphics « C# / C Sharp






Play Gif animation

Play Gif animation
 

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));
    }
  }

           
         
  








Related examples in the same category

1.GIF Converter