我很好奇如何使用imagemagick库类在C#中创建一个动画.gif。这就是我到目前为止正在使用的:
using (MagickImageCollection collection = new MagickImageCollection())
{
//collection.CacheDirectory = @"C:\MyProgram\MyTempDir";
// Add first image and set the animation delay to 100ms
//MagickNET.Initialize(@"C:\Users\johsam\Downloads\Magick\MagickScript.xsd");
collection.Add("Koala.jpg");
collection[0].AnimationDelay = 1;
// Add second image, set the animation delay to 100ms and flip the image
collection.Add("Desert.jpg");
collection[1].AnimationDelay = 100;
collection[1].Flip();
// Optionally reduce colors
QuantizeSettings settings = new QuantizeSettings();
settings.Colors = 256;
collection.Quantize(settings);
// Optionally optimize the images (images should have the same size).
collection.Optimize();
// Save gif
collection.Write("test.Animated.gif");
}问题是,尽管它创建了一个.gif,但当你打开它时,并没有运动的图像。你如何将这些图像串在一起来创建一个运动图像?
发布于 2016-02-15 05:26:04
您正在使用的代码似乎是codeplex site提供的示例。逻辑似乎按预期工作,但我的假设是,在集合中的初始图像上,动画延迟太小(1ms)。你可能只会看到第二张图片。请增加您的动画延迟(到100ms),并确认。完成后,您可以适当地调整延迟,使其达到可产生所需输出的时间间隔。
https://stackoverflow.com/questions/35397556
复制相似问题