diff --git a/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs b/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs index 882cc13493..42fccdc188 100644 --- a/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs +++ b/src/ImageSharp/Formats/Jpeg/Common/Decoder/JpegImagePostProcessor.cs @@ -56,11 +56,6 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.Common.Decoder public bool DoPostProcessorStep(Image destination) where TPixel : struct, IPixel { - if (this.RawJpeg.ComponentCount != 3) - { - throw new NotImplementedException(); - } - foreach (JpegComponentPostProcessor cpp in this.ComponentProcessors) { cpp.CopyBlocksToColorBuffer(); diff --git a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs index 445578ff54..e8e8fe06e5 100644 --- a/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/GolangPort/OrigJpegDecoderCore.cs @@ -211,11 +211,15 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort { this.ParseStream(stream); +#if OLDCODE this.ProcessBlocksIntoJpegImageChannels(); return this.ConvertJpegPixelsToImagePixels(); +#else + return this.PostProcessIntoImage(); +#endif } - + /// public void Dispose() { @@ -1226,5 +1230,16 @@ namespace SixLabors.ImageSharp.Formats.Jpeg.GolangPort throw new ImageFormatException("JpegDecoder only supports RGB, CMYK and Grayscale color spaces."); } } + + private Image PostProcessIntoImage() + where TPixel : struct, IPixel + { + using (var postProcessor = new JpegImagePostProcessor(this)) + { + var image = new Image(this.configuration, this.ImageWidth, this.ImageHeight, this.MetaData); + postProcessor.PostProcess(image); + return image; + } + } } } \ No newline at end of file