From 912eb6ace51407f5ed5df9f9cec962bc49de57d1 Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Fri, 22 Jun 2018 16:48:45 -0700 Subject: [PATCH] Use span copy --- src/ImageSharp/Formats/Png/PngEncoderCore.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Formats/Png/PngEncoderCore.cs b/src/ImageSharp/Formats/Png/PngEncoderCore.cs index 7ec82c57c8..cf869e68a6 100644 --- a/src/ImageSharp/Formats/Png/PngEncoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngEncoderCore.cs @@ -247,7 +247,7 @@ namespace SixLabors.ImageSharp.Formats.Png where TPixel : struct, IPixel { byte[] rawScanlineArray = this.rawScanline.Array; - var rgba = default(Rgba32); + Rgba32 rgba = default; // Copy the pixels across from the image. // Reuse the chunk type buffer. @@ -305,8 +305,9 @@ namespace SixLabors.ImageSharp.Formats.Png switch (this.pngColorType) { case PngColorType.Palette: - // TODO: Use Span copy! - Buffer.BlockCopy(this.palettePixelData, row * this.rawScanline.Length(), this.rawScanline.Array, 0, this.rawScanline.Length()); + int stride = this.rawScanline.Length(); + + this.palettePixelData.AsSpan(row * stride, stride).CopyTo(this.rawScanline.GetSpan()); break; case PngColorType.Grayscale: case PngColorType.GrayscaleWithAlpha: