public void Decompress(TiffDecompressionContext context, ReadOnlyMemory <byte> input, Memory <byte> output) { // Copy frame header JpegFrameHeader frameHeader = _frameHeader; frameHeader = new JpegFrameHeader(frameHeader.SamplePrecision, (ushort)context.ImageSize.Height, (ushort)context.ImageSize.Width, frameHeader.NumberOfComponents, frameHeader.Components); var decoder = new JpegDecoder(); decoder.StartOfFrame = JpegMarker.StartOfFrame0; decoder.MemoryPool = context.MemoryPool; decoder.SetFrameHeader(frameHeader); decoder.SetRestartInterval(_restartInterval); foreach (ComponentInfo componentInfo in _components) { decoder.SetQuantizationTable(componentInfo.QuantizationTable); decoder.SetHuffmanTable(componentInfo.DcTable); decoder.SetHuffmanTable(componentInfo.AcTable); } var outputWriter = new JpegBuffer8BitOutputWriter(context.ImageSize.Width, context.SkippedScanlines, context.SkippedScanlines + context.RequestedScanlines, decoder.NumberOfComponents, output); decoder.SetOutputWriter(outputWriter); var reader = new JpegReader(input); decoder.ProcessScan(ref reader, _scanHeader); }