gpt4 book ai didi

c# - 如何在 C# 中显示 GIF 图像的特定帧?

转载 作者:行者123 更新时间:2023-11-30 14:09:42 24 4
gpt4 key购买 nike

我想显示一帧 gif 图片。搜索了一下,发现下面的代码应该可以,但是不行。它正确检测到帧数,但它显示 gif 的整个帧而不是指定的帧。谢谢大家。

Image[] frames = new Image[36];
Image GG = Image.FromFile(@"C:\Users\Administrator\TEST C#\TEST2frame2\chef.gif");
FrameDimension dimension = new FrameDimension(GG.FrameDimensionsList[0]);
// Number of frames
int frameCount = GG.GetFrameCount(dimension);
label1.Text = frameCount.ToString();

// Return an Image at a certain index
GG.SelectActiveFrame(dimension, 1);
frames[1] = ((Image)GG.Clone());
pictureBox1.Image = frames[1];

最佳答案

在调用 SelectActiveFrame() 之前使用您自己的代码,然后更改为以下行:

frames[0] = new Bitmap(GG);
pictureBox1.Image = frame[0];

这应该可以解决问题。请不要忘记处理创建的图像。

关于c# - 如何在 C# 中显示 GIF 图像的特定帧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27874353/

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