使用 C# 访问 GIF 帧

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/540701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 07:22:59  来源:igfitidea点击:

Access GIF frames with C#

c#gifanimated-gif

提问by Valeria

I'm a beginner in C#. I would like to know if there's a way to access different frames inside a GIF animation with C#. I'm using Visual Studio 2008.

我是 C# 的初学者。我想知道是否有办法使用 C# 访问 GIF 动画中的不同帧。我正在使用 Visual Studio 2008。

回答by RvdK

a bit of googling: editing animated gif's in c#

有点谷歌搜索:在 C# 中编辑动画 gif

You can read the animated Gif with Image.GetFrameCount() and SelectActiveFrame().

您可以使用 Image.GetFrameCount() 和 SelectActiveFrame() 读取动画 Gif。

回答by Renaud Bompuis

Try this:

尝试这个:

using System.Drawing;    
using System.Drawing.Imaging;

Image gifImg = Image.FromFile(pathToGifFile);
FrameDimension dimension = new FrameDimension(gifImg.FrameDimensionsList[0]);
// Number of frames
int frameCount = gifImg.GetFrameCount(dimension);
// Return an Image at a certain index
gifImg.SelectActiveFrame(dimension, index);