/// <summary> /// Invoke <see cref="JpegBlockPostProcessor"/> for <see cref="BlockRowsPerStep"/> block rows, copy the result into <see cref="ColorBuffer"/>. /// </summary> public void CopyBlocksToColorBuffer() { var blockPp = new JpegBlockPostProcessor(this.ImagePostProcessor.RawJpeg, this.Component); for (int y = 0; y < this.BlockRowsPerStep; y++) { int yBlock = this.currentComponentRowInBlocks + y; if (yBlock >= this.SizeInBlocks.Height) { break; } int yBuffer = y * this.blockAreaSize.Height; Span <Block8x8> blockRow = this.Component.SpectralBlocks.GetRowSpan(yBlock); ref Block8x8 blockRowBase = ref MemoryMarshal.GetReference(blockRow); for (int xBlock = 0; xBlock < this.SizeInBlocks.Width; xBlock++) { ref Block8x8 block = ref Unsafe.Add(ref blockRowBase, xBlock); int xBuffer = xBlock * this.blockAreaSize.Width; BufferArea <float> destArea = this.ColorBuffer.GetArea( xBuffer, yBuffer, this.blockAreaSize.Width, this.blockAreaSize.Height); blockPp.ProcessBlockColorsInto(ref block, destArea); }
/// <summary> /// Invoke <see cref="JpegBlockPostProcessor"/> for <see cref="BlockRowsPerStep"/> block rows, copy the result into <see cref="ColorBuffer"/>. /// </summary> public void CopyBlocksToColorBuffer() { var blockPp = new JpegBlockPostProcessor(this.ImagePostProcessor.RawJpeg, this.Component); for (int y = 0; y < this.BlockRowsPerStep; y++) { int yBlock = this.currentComponentRowInBlocks + y; if (yBlock >= this.SizeInBlocks.Height) { break; } int yBuffer = y * this.blockAreaSize.Height; for (int x = 0; x < this.SizeInBlocks.Width; x++) { int xBlock = x; int xBuffer = x * this.blockAreaSize.Width; ref Block8x8 block = ref this.Component.GetBlockReference(xBlock, yBlock); BufferArea <float> destArea = this.ColorBuffer.GetArea( xBuffer, yBuffer, this.blockAreaSize.Width, this.blockAreaSize.Height); blockPp.ProcessBlockColorsInto(ref block, destArea); } }
/// <summary> /// Invoke <see cref="JpegBlockPostProcessor"/> for <see cref="BlockRowsPerStep"/> block rows, copy the result into <see cref="ColorBuffer"/>. /// </summary> public void CopyBlocksToColorBuffer() { var blockPp = new JpegBlockPostProcessor(this.ImagePostProcessor.RawJpeg, this.Component); float maximumValue = MathF.Pow(2, this.ImagePostProcessor.RawJpeg.Precision) - 1; int destAreaStride = this.ColorBuffer.Width; for (int y = 0; y < this.BlockRowsPerStep; y++) { int yBlock = this.currentComponentRowInBlocks + y; if (yBlock >= this.SizeInBlocks.Height) { break; } int yBuffer = y * this.blockAreaSize.Height; Span <float> colorBufferRow = this.ColorBuffer.GetRowSpan(yBuffer); Span <Block8x8> blockRow = this.Component.SpectralBlocks.GetRowSpan(yBlock); // see: https://github.com/SixLabors/ImageSharp/issues/824 int widthInBlocks = Math.Min(this.Component.SpectralBlocks.Width, this.SizeInBlocks.Width); for (int xBlock = 0; xBlock < widthInBlocks; xBlock++) { ref Block8x8 block = ref blockRow[xBlock]; int xBuffer = xBlock * this.blockAreaSize.Width; ref float destAreaOrigin = ref colorBufferRow[xBuffer]; blockPp.ProcessBlockColorsInto(ref block, ref destAreaOrigin, destAreaStride, maximumValue); }
/// <summary> /// Invoke <see cref="JpegBlockPostProcessor"/> for <see cref="BlockRowsPerStep"/> block rows, copy the result into <see cref="ColorBuffer"/>. /// </summary> public void CopyBlocksToColorBuffer(int step) { Buffer2D <Block8x8> spectralBuffer = this.Component.SpectralBlocks; var blockPp = new JpegBlockPostProcessor(this.RawJpeg, this.Component); float maximumValue = this.frame.MaxColorChannelValue; int destAreaStride = this.ColorBuffer.Width; int yBlockStart = step * this.BlockRowsPerStep; for (int y = 0; y < this.BlockRowsPerStep; y++) { int yBlock = yBlockStart + y; if (yBlock >= spectralBuffer.Height) { break; } int yBuffer = y * this.blockAreaSize.Height; Span <float> colorBufferRow = this.ColorBuffer.GetRowSpan(yBuffer); Span <Block8x8> blockRow = spectralBuffer.GetRowSpan(yBlock); // see: https://github.com/SixLabors/ImageSharp/issues/824 int widthInBlocks = Math.Min(spectralBuffer.Width, this.SizeInBlocks.Width); for (int xBlock = 0; xBlock < widthInBlocks; xBlock++) { ref Block8x8 block = ref blockRow[xBlock]; int xBuffer = xBlock * this.blockAreaSize.Width; ref float destAreaOrigin = ref colorBufferRow[xBuffer]; blockPp.ProcessBlockColorsInto(ref block, ref destAreaOrigin, destAreaStride, maximumValue); }