gpt4 book ai didi

c# - 我有一个带有动画 gif 的图片框的问题,它不是移动的,由 c# 代码

转载 作者:行者123 更新时间:2023-11-30 18:03:09 25 4
gpt4 key购买 nike

我的图片框有问题,我选择了动画gif的图片类型,图片显示了,但是没有移动,通过c#代码

最佳答案

这可能会有所帮助: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());
}
}

关于c# - 我有一个带有动画 gif 的图片框的问题,它不是移动的,由 c# 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7495421/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com