From 95f118ee3b6681e1a10814caf0f0609c38db6f02 Mon Sep 17 00:00:00 2001 From: JimBobSquarePants Date: Tue, 3 Oct 2017 13:23:43 +1100 Subject: [PATCH 1/2] Allow dithering on animated gifs. --- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index 1b25fd1f1..c257a24ed 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -98,9 +98,7 @@ namespace SixLabors.ImageSharp.Formats.Gif this.hasFrames = image.Frames.Count > 1; - // Dithering when animating gifs is a bad idea as we introduce pixel tearing across frames. var ditheredQuantizer = (IQuantizer)this.quantizer; - ditheredQuantizer.Dither = !this.hasFrames; // Quantize the image returning a palette. QuantizedImage quantized = ditheredQuantizer.Quantize(image.Frames.RootFrame, size); From 7c71b3771638ff82a9890f22f8ab4082bb43f1aa Mon Sep 17 00:00:00 2001 From: JimBobSquarePants Date: Tue, 3 Oct 2017 13:26:12 +1100 Subject: [PATCH 2/2] rename variable Fix #262 --- src/ImageSharp/Formats/Gif/GifEncoderCore.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs index c257a24ed..b10f8a2e0 100644 --- a/src/ImageSharp/Formats/Gif/GifEncoderCore.cs +++ b/src/ImageSharp/Formats/Gif/GifEncoderCore.cs @@ -98,10 +98,10 @@ namespace SixLabors.ImageSharp.Formats.Gif this.hasFrames = image.Frames.Count > 1; - var ditheredQuantizer = (IQuantizer)this.quantizer; + var pixelQuantizer = (IQuantizer)this.quantizer; // Quantize the image returning a palette. - QuantizedImage quantized = ditheredQuantizer.Quantize(image.Frames.RootFrame, size); + QuantizedImage quantized = pixelQuantizer.Quantize(image.Frames.RootFrame, size); int index = this.GetTransparentIndex(quantized); @@ -124,7 +124,7 @@ namespace SixLabors.ImageSharp.Formats.Gif { if (quantized == null) { - quantized = ditheredQuantizer.Quantize(frame, size); + quantized = pixelQuantizer.Quantize(frame, size); } this.WriteGraphicalControlExtension(frame.MetaData, writer, this.GetTransparentIndex(quantized));