From 13b19b9c21d99a484bbcc0959bee838992fd5ded Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Thu, 7 Sep 2017 20:31:26 +1000 Subject: [PATCH] Adjust for new frame cont in Gif encoder --- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index fe1e4d83e..56eb7b2ba 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -90,11 +90,11 @@ namespace SixLabors.ImageSharp.Formats.Gif var writer = new EndianBinaryWriter(Endianness.LittleEndian, stream); // Ensure that pallete size can be set but has a fallback. - int paletteSize = this.paletteSize; - paletteSize = paletteSize > 0 ? paletteSize.Clamp(1, 256) : 256; + int size = this.paletteSize; + size = size > 0 ? size.Clamp(1, 256) : 256; // Get the number of bits. - this.bitDepth = ImageMaths.GetBitsNeededForColorDepth(paletteSize); + this.bitDepth = ImageMaths.GetBitsNeededForColorDepth(size); this.hasFrames = image.Frames.Count > 1; @@ -103,7 +103,7 @@ namespace SixLabors.ImageSharp.Formats.Gif ditheredQuantizer.Dither = !this.hasFrames; // Quantize the image returning a palette. - QuantizedImage quantized = ditheredQuantizer.Quantize(image.Frames.RootFrame, paletteSize); + QuantizedImage quantized = ditheredQuantizer.Quantize(image.Frames.RootFrame, size); int index = this.GetTransparentIndex(quantized); @@ -119,14 +119,14 @@ namespace SixLabors.ImageSharp.Formats.Gif // Write additional frames. if (this.hasFrames) { - this.WriteApplicationExtension(writer, image.MetaData.RepeatCount, image.Frames.Count); + this.WriteApplicationExtension(writer, image.MetaData.RepeatCount, image.Frames.Count - 1); } - foreach (ImageFrame frame in image.Frames) + foreach (ImageFrame frame in image.Frames.Skip(1)) { if (quantized == null) { - quantized = ditheredQuantizer.Quantize(frame, paletteSize); + quantized = ditheredQuantizer.Quantize(frame, size); } this.WriteGraphicalControlExtension(frame.MetaData, writer, this.GetTransparentIndex(quantized));