Воспроизведение Gif анимации - C#

Узнай цену своей работы

Формулировка задачи:

Как сделать что бы GIF фаил играл, я вставляю а он стоит как картинка...

Решение задачи: «Воспроизведение Gif анимации»

textual
Листинг программы
   public partial class Form1 : Form
    {
        Bitmap RotatingBlocks;
        Point DrawHere;
        Rectangle InvalidRect;
        
        public Form1()
        {
            InitializeComponent();
            RotatingBlocks = new Bitmap("d:\\AG00011_.GIF");
            DrawHere = new Point(10, 10);
            InvalidRect = new Rectangle(DrawHere, RotatingBlocks.Size);
 
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.DoubleBuffer, true);
           
            this.Load += new System.EventHandler(this.Form1_Load);
        }
 
       
        protected override void OnPaint(PaintEventArgs e)
        {                      
            ImageAnimator.UpdateFrames(RotatingBlocks);
            
            e.Graphics.DrawImage(RotatingBlocks, DrawHere);
        }
 
        private void OnFrameChanged(object o, EventArgs e)
        {
            
            this.Invalidate(InvalidRect);
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            if (ImageAnimator.CanAnimate(RotatingBlocks))
            {
                
                ImageAnimator.Animate(RotatingBlocks,
                                      new EventHandler(this.OnFrameChanged));
                
               
            }
        }
 
    }

Оцени полезность:

5   голосов , оценка 4 из 5