From 860a89dcd261f97a172e8ae8a0075c5d71b15336 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Tue, 29 Aug 2017 14:26:21 +0200 Subject: [PATCH] comments on rounding logic --- .../GolangPort/Components/Decoder/JpegBlockPostProcessor.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/JpegBlockPostProcessor.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/JpegBlockPostProcessor.cs index be03b5dd6..08cf1eb60 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/JpegBlockPostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/Components/Decoder/JpegBlockPostProcessor.cs @@ -78,6 +78,9 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort.Components.Decoder this.data.ResultBlock.NormalizeColorsInplace(); Size divs = component.SubSamplingDivisors; + // To conform better to libjpeg we actually NEED TO loose precision here. + // This is because they store blocks as Int16 between all the operations. + // Unfortunately, we need to emulate this to be "more accurate" :( this.data.ResultBlock.RoundInplace(); this.data.ResultBlock.CopyTo(destArea, divs.Width, divs.Height);