/// <summary> /// Convert and copy <see cref="PixelRowsPerStep"/> row of colors into 'destination' starting at row <see cref="PixelRowCounter"/>. /// </summary> /// <typeparam name="TPixel">The pixel type</typeparam> /// <param name="destination">The destination image</param> private void ConvertColorsInto <TPixel>(ImageFrame <TPixel> destination) where TPixel : unmanaged, IPixel <TPixel> { int maxY = Math.Min(destination.Height, this.PixelRowCounter + PixelRowsPerStep); var buffers = new Buffer2D <float> [this.ComponentProcessors.Length]; for (int i = 0; i < this.ComponentProcessors.Length; i++) { buffers[i] = this.ComponentProcessors[i].ColorBuffer; } for (int yy = this.PixelRowCounter; yy < maxY; yy++) { int y = yy - this.PixelRowCounter; var values = new JpegColorConverter.ComponentValues(buffers, y); this.colorConverter.ConvertToRgba(values, this.rgbaBuffer.GetSpan()); Span <TPixel> destRow = destination.GetPixelRowSpan(yy); // TODO: Investigate if slicing is actually necessary PixelOperations <TPixel> .Instance.FromVector4Destructive(this.configuration, this.rgbaBuffer.GetSpan().Slice(0, destRow.Length), destRow); } }
/// <summary> /// Convert and copy <see cref="PixelRowsPerStep"/> row of colors into 'destination' starting at row <see cref="PixelRowCounter"/>. /// </summary> /// <typeparam name="TPixel">The pixel type</typeparam> /// <param name="destination">The destination image</param> private void ConvertColorsInto <TPixel>(ImageFrame <TPixel> destination) where TPixel : struct, IPixel <TPixel> { int maxY = Math.Min(destination.Height, this.PixelRowCounter + PixelRowsPerStep); Buffer2D <float>[] buffers = this.ComponentProcessors.Select(cp => cp.ColorBuffer).ToArray(); for (int yy = this.PixelRowCounter; yy < maxY; yy++) { int y = yy - this.PixelRowCounter; var values = new JpegColorConverter.ComponentValues(buffers, y); this.colorConverter.ConvertToRgba(values, this.rgbaBuffer.Span); Span <TPixel> destRow = destination.GetPixelRowSpan(yy); PixelOperations <TPixel> .Instance.PackFromVector4(this.rgbaBuffer.Span, destRow, destination.Width); } }