Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace AnimGIF
- {
- /**
- Please include a animated gif into the debug/release folder
- **/
- public partial class Form1 : Form
- {
- private Bitmap myGif = null;
- private string nameOfMyGIF = "1.gif";
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- myGif = (Bitmap)Image.FromFile(Application.StartupPath + @"\" + nameOfMyGIF);
- if (ImageAnimator.CanAnimate(myGif))
- ImageAnimator.Animate(myGif, this.OnNextFrameUpdateForm); //a self created event-hdlr.
- else
- {
- MessageBox.Show("THIS IMAGE COULDN'T BE ANIMATED!");
- return;
- }
- SetStyle(ControlStyles.UserPaint, true);
- SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- }
- private void OnNextFrameUpdateForm(object sender, EventArgs e)
- {
- this.Invalidate();
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- e.Graphics.DrawImage(myGif, 10, 10);
- ImageAnimator.UpdateFrames();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement