diff --git a/src/Gifitti/Gifitti/Models/GifModel.cs b/src/Gifitti/Gifitti/Models/GifModel.cs index f5a5cec397b088a813ad2af0cf2100dfa5688446..ec621e3b487c0dae4f13d7988b75a2020a6f6d61 100644 --- a/src/Gifitti/Gifitti/Models/GifModel.cs +++ b/src/Gifitti/Gifitti/Models/GifModel.cs @@ -26,6 +26,7 @@ namespace Gifitti.Models private bool reverse; public int startFrame = 0; public int endFrame = 0; + public int delay { get; set; } = 0; /// <summary> /// Load a GIF into the software model from the system path "path" @@ -94,7 +95,11 @@ namespace Gifitti.Models using (MagickImageCollection collection = new MagickImageCollection()) { for (int i = this.startFrame; i < Math.Min(this.endFrame, frames.Length); i++) + { collection.Add(new MagickImage(frames[i] as Bitmap)); + collection[i - this.startFrame].AnimationDelay = this.delay/10; + } + // Maximize Colour saturation QuantizeSettings settings = new QuantizeSettings(); @@ -123,7 +128,7 @@ namespace Gifitti.Models for (int i = start; i < stop; i++) { collection.Add(new ImageMagick.MagickImage(frames[i] as Bitmap)); - collection[i - start].AnimationDelay = 1; + collection[i - this.startFrame].AnimationDelay = this.delay/10; } // Optionally reduce colors QuantizeSettings settings = new QuantizeSettings(); diff --git a/src/Gifitti/Gifitti/View_Models/MainForm.cs b/src/Gifitti/Gifitti/View_Models/MainForm.cs index 4f0f0ec1ce4f38dbe39ea4df675ac47bab5e9c9f..1a9d5ba356d8f77897592094486b65629d0b5a09 100644 --- a/src/Gifitti/Gifitti/View_Models/MainForm.cs +++ b/src/Gifitti/Gifitti/View_Models/MainForm.cs @@ -25,7 +25,6 @@ namespace Gifitti.View_Models { #region Fields GifModel gm; - int delay = 0; // GifImage _currentGif; <- used to encapsulate info later private const int widthBuffer = 20; @@ -167,7 +166,7 @@ namespace Gifitti.View_Models private void AdvanceFrameTimer(object sender, EventArgs e) { //get next frame - Thread.Sleep(delay); + Thread.Sleep(gm.delay); gifView.Image = gm.GetNextFrame(); } @@ -313,7 +312,7 @@ namespace Gifitti.View_Models /// <param name="e"> Event arguments associated with this event. </param> private void GifFPSSliderUpdate(object sender, EventArgs e) { - delay = (10-trackBar1.Value)*10; + gm.delay = (10-trackBar1.Value)*10; } private void MenuItemResize(object sender, EventArgs e)