Source code in question is:
Code: Select all
using (MagickImageCollection collection = new MagickImageCollection())
{
for (int i = 0; i < video.Count; i++)
{
Bitmap bmp = video[i];
MagickImage img = new MagickImage(bmp);
//img.Resample(600, 400);
collection.Add(img);
collection[collection.Count - 1].AnimationDelay = 150;
collection[collection.Count - 1].AnimationIterations = 1;
tsProgress.Value++;
Application.DoEvents();
}
// Optionally reduce colors
try
{
QuantizeSettings settings = new QuantizeSettings();
settings.Colors = 128;
collection.Quantize(settings);
collection.Optimize();
tsProgress.Value++;
Application.DoEvents();
}
catch (Exception)
{
// do not reduce colors
}
// Optionally optimize the images (images should have the same size).
// Save gif
collection.Write(filename);
}