From 0aa22f41af7208e67cc10d96cd5d66dfb8e9f476 Mon Sep 17 00:00:00 2001 From: Thomas Broust Date: Sat, 28 Jun 2014 18:52:29 +0200 Subject: [PATCH] First fix of an animated gif problem on Mono Former-commit-id: d38b0ada26a9b0f080390d15bd6707c919b4faad --- src/ImageProcessor/Imaging/Formats/FormatUtilities.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs index 36d2e3c07..3c6e3b3e0 100644 --- a/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs +++ b/src/ImageProcessor/Imaging/Formats/FormatUtilities.cs @@ -135,12 +135,14 @@ namespace ImageProcessor.Imaging.Formats int frameCount = image.GetFrameCount(frameDimension); int last = frameCount - 1; int delay = 0; - int index = 0; List gifFrames = new List(); for (int i = 0; i < frameCount; i++) { - int thisDelay = BitConverter.ToInt32(image.GetPropertyItem(20736).Value, index); + // GDI returns a single array with all delays, while Mono returns a different array for each frame + image.SelectActiveFrame(frameDimension, i); + var times = image.GetPropertyItem(20736).Value; + int thisDelay = BitConverter.ToInt32(times, 4*i % times.Length); int toAddDelay = thisDelay * 10 < 20 ? 20 : thisDelay * 10; // Minimum delay is 20 ms // Find the frame @@ -156,7 +158,6 @@ namespace ImageProcessor.Imaging.Formats } delay += toAddDelay; - index += 4; } info.GifFrames = gifFrames;