Browse Source

Added Buffer2D Image ctor, wired new post processor with decoder core

pull/1694/head
Dmitry Pentin 5 years ago
parent
commit
1c10ec6d05
  1. 6
      src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs
  2. 8
      src/ImageSharp/Image{TPixel}.cs

6
src/ImageSharp/Formats/Jpeg/JpegDecoderCore.cs

@ -215,7 +215,7 @@ namespace SixLabors.ImageSharp.Formats.Jpeg
public Image<TPixel> Decode<TPixel>(BufferedReadStream stream, CancellationToken cancellationToken)
where TPixel : unmanaged, IPixel<TPixel>
{
SpectralConverter<TPixel> spectralConverter = new SpectralConverter<TPixel>(this.Configuration, cancellationToken);
var spectralConverter = new SpectralConverter<TPixel>(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<TPixel>(cancellationToken);
return new Image<TPixel>(this.Configuration, spectralConverter.PixelBuffer, this.Metadata);
}
/// <inheritdoc/>
@ -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);
}
}

8
src/ImageSharp/Image{TPixel}.cs

@ -87,6 +87,14 @@ namespace SixLabors.ImageSharp
this.frames = new ImageFrameCollection<TPixel>(this, width, height, default(TPixel));
}
internal Image(
Configuration configuration,
Buffer2D<TPixel> pixelBuffer,
ImageMetadata metadata)
: this(configuration, pixelBuffer.FastMemoryGroup, pixelBuffer.Width, pixelBuffer.Height, metadata)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Image{TPixel}"/> class
/// wrapping an external <see cref="MemoryGroup{T}"/>.

Loading…
Cancel
Save