У меня есть проблема с картинкой с анимацией GIF, это не двигаться, с помощью кода C # - PullRequest
3 голосов
/ 21 сентября 2011

У меня проблема с картинкой, я выбираю тип изображения gif анимации, Картинка отображается, но она не двигается, код c #

Ответы [ 2 ]

1 голос
/ 21 сентября 2011

это может помочь: ImageAnimator.Animate Method

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());
    }
}
0 голосов
/ 21 сентября 2011

Вы должны справиться с анимацией вручную.Вот пример http://www.vcskicks.com/csharp_animated_gif2.php

Изменить код доступен здесь: Может ли PictureBox отображать анимированный GIF в приложении Windows?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...