C# 在c windows应用程序中设置图像动画的最简单方法

C# 在c windows应用程序中设置图像动画的最简单方法,c#,image,animation,slideshow,windows-applications,C#,Image,Animation,Slideshow,Windows Applications,我有一个windows应用程序,可以在发布到web服务器之前预览图像列表,而不使用WPF,当用户按下“下一步”或“上一步”时,我需要在图片之间设置滑动、淡入淡出或翻转动画 谢谢 Hamza您可以使用ImageAnimator类设置图像动画 例如: 可以使用ImageAnimator类设置图像动画 例如: using System; using System.Drawing; using System.Windows.Forms; public class animateImage : For

我有一个windows应用程序,可以在发布到web服务器之前预览图像列表,而不使用WPF,当用户按下“下一步”或“上一步”时,我需要在图片之间设置滑动、淡入淡出或翻转动画

谢谢
Hamza

您可以使用ImageAnimator类设置图像动画

例如:


可以使用ImageAnimator类设置图像动画

例如:

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