From 1c10ec6d05fb7d75cc83a5a55f096f219c823a81 Mon Sep 17 00:00:00 2001 From: Dmitry Pentin Date: Fri, 9 Jul 2021 20:47:02 +0300 Subject: [PATCH] Added Buffer2D Image ctor, wired new post processor with decoder core --- src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs | 6 +++--- src/ImageSharp/Image{TPixel}.cs | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs index 1682860718..eb4ed5b959 100644 --- a/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs +++ b/src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs @@ -215,7 +215,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg public Image Decode(BufferedReadStream stream, CancellationToken cancellationToken) where TPixel : unmanaged, IPixel { - SpectralConverter spectralConverter = new SpectralConverter(this.Configuration, cancellationToken); + var spectralConverter = new SpectralConverter(this.Configuration, cancellationToken); this.scanDecoder = new HuffmanScanDecoder(stream, spectralConverter, cancellationToken); @@ -225,7 +225,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg this.InitIptcProfile(); this.InitDerivedMetadataProperties(); - return this.PostProcessIntoImage(cancellationToken); + return new Image(this.Configuration, spectralConverter.PixelBuffer, this.Metadata); } /// @@ -925,7 +925,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg this.ImageSizeInMCU = new Size(this.Frame.McusPerLine, this.Frame.McusPerColumn); // This can be injected in SOF marker callback - this.scanDecoder.Frame = this.Frame; + this.scanDecoder.InjectFrameData(this.Frame, this); } } diff --git a/src/ImageSharp/Image{TPixel}.cs b/src/ImageSharp/Image{TPixel}.cs index b43ff0422b..669db2a97b 100644 --- a/src/ImageSharp/Image{TPixel}.cs +++ b/src/ImageSharp/Image{TPixel}.cs @@ -87,6 +87,14 @@ namespace SixLabors.ImageSharp this.frames = new ImageFrameCollection(this, width, height, default(TPixel)); } + internal Image( + Configuration configuration, + Buffer2D pixelBuffer, + ImageMetadata metadata) + : this(configuration, pixelBuffer.FastMemoryGroup, pixelBuffer.Width, pixelBuffer.Height, metadata) + { + } + /// /// Initializes a new instance of the class /// wrapping an external .