【发布时间】:2016-02-15 05:26:03
【问题描述】:
我很好奇如何使用 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,但当您打开它时却没有动态图像。您如何将图像串在一起以创建动态图像?
【问题讨论】:
标签: c# imagemagick animated