C# - 从多张图片中创建gif(animationframes) [英] C# - create gif (animationframes) from multiple pictures
问题描述
嘿社区,
我试图拍摄相同尺寸的x图片,假设500x500
并将它们组合成动画gif风格的最终图像。
我已经用另一种方式管理,意味着将所有帧从
gif文件中提取到数组:
Hey Community,
Im trying to take x pictures with the same size, lets assume 500x500
and put them together as a final image in a animated gif style.
I already managed the other way around, means to extract all frames from an
gif file to an array:
Image[] getFrames(Image originalImg)
{
int numberOfFrames = originalImg.GetFrameCount(FrameDimension.Time);
Image[] frames = new Image[numberOfFrames];
for (int i = 0; i < numberOfFrames; i++)
{
originalImg.SelectActiveFrame(FrameDimension.Time, i);
frames[i] = ((Image)originalImg.Clone());
}
return frames;
}
但Image类中没有类似AddFrame(Image img)的功能
那么我该如何创造这样的东西呢?
背后有一些伪代码:
But there is no function within the Image class which is like "AddFrame(Image img)"
So how am I supposed to create such a thing ?
Some Pseudo Code for the idea behind:
void createFromFrames(string path, Image[] frames)
{
Image img;
... create it
foreach(Image f in frames)
{
img.AddFrame(f);
}
... save it
}
,问候
我尝试了什么:
我在网上搜索,搜索了类但没有结果 -
,greetings
What I have tried:
I searched in the web, searched in the classes but no result -
推荐答案
不知道你搜索了什么,但是我有很多点击:
c#创建动画gif - Google搜索 [ ^ ]
其中一个点击是这个CodeProject文章:
NGif,用于.NET的动画GIF编码器 [ ^ ]
可能有一些问题,所以有人创建了它的bugfixed版本:
NGif,用于.NET的动画GIF编码器 - CodeProject [ ^ ]
我测试了一个它似乎工作。
Don't know what you searched for but I got plenty of hits with this:
c# create animated gif - Google Search[^]
One of those hits is this CodeProject article:
NGif, Animated GIF Encoder for .NET[^]
It may have some issues, so somebody created a bugfixed version of it:
NGif, Animated GIF Encoder for .NET - CodeProject[^]
I tested that one and it seems to work.
这篇关于C# - 从多张图片中创建gif(animationframes)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!