how loop gif animation ?
Posted: 2017-07-28T23:33:06-07:00
Hello
I try to create gif animation and i want the animation will start over when all the frames is end, thats mean the gif animation will run non stop.
How can i do that ?
Here is my sample code:
I try to create gif animation and i want the animation will start over when all the frames is end, thats mean the gif animation will run non stop.
How can i do that ?
Here is my sample code:
Code: Select all
public string Get()
{
using (MagickImageCollection collection = new MagickImageCollection())
{
// Add first image and set the animation delay to 100ms
collection.Add("Snakeware2.gif");
collection[0].AnimationDelay = 100;
// Add second image, set the animation delay to 100ms and flip the image
collection.Add("Snakeware1.gif");
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.Coalesce();
string data = collection.ToBase64(MagickFormat.Gif);
return data;
}
}