Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Imagemagick C#animated.gif_C#_Imagemagick_Animated - Fatal编程技术网

Imagemagick C#animated.gif

Imagemagick C#animated.gif,c#,imagemagick,animated,C#,Imagemagick,Animated,我很好奇如何使用imagemagick库类在C#中创建动画.gif。这就是我目前正在使用的: using (MagickImageCollection collection = new MagickImageCollection()) { //collection.CacheDirectory = @"C:\MyProgram\MyTempDir"; // Add first image and set the animation delay to 100ms //Mag

我很好奇如何使用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文件,但当您打开它时,它并没有移动图像。如何将图像串在一起以创建运动图像?

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