【问题标题】:Imagemagick C# animated .gifImagemagick C# 动画 .gif
【发布时间】: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


    【解决方案1】:

    您使用的代码似乎是 codeplex site 提供的示例。逻辑似乎按预期工作,但我的假设是集合中初始图像上的动画延迟太小(1 毫秒)。您可能只会看到第二张图片。请增加您的动画延迟(至 100 毫秒),并确认。完成后,您可以将延迟适当地调整到产生所需输出的时间间隔。

    【讨论】:

      猜你喜欢
      • 2015-03-20
      • 2011-07-27
      • 1970-01-01
      • 2017-11-17
      • 2018-01-09
      • 2023-03-03
      • 2012-12-11
      • 1970-01-01
      • 2012-04-16
      相关资源
      最近更新 更多