Browse Source

Use span copy

af/merge-core
Jason Nelson 8 years ago
parent
commit
912eb6ace5
  1. 7
      src/ImageSharp/Formats/Png/PngEncoderCore.cs

7
src/ImageSharp/Formats/Png/PngEncoderCore.cs

@ -247,7 +247,7 @@ namespace SixLabors.ImageSharp.Formats.Png
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
byte[] rawScanlineArray = this.rawScanline.Array; byte[] rawScanlineArray = this.rawScanline.Array;
var rgba = default(Rgba32); Rgba32 rgba = default;
// Copy the pixels across from the image. // Copy the pixels across from the image.
// Reuse the chunk type buffer. // Reuse the chunk type buffer.
@ -305,8 +305,9 @@ namespace SixLabors.ImageSharp.Formats.Png
switch (this.pngColorType) switch (this.pngColorType)
{ {
case PngColorType.Palette: case PngColorType.Palette:
// TODO: Use Span copy! int stride = this.rawScanline.Length();
Buffer.BlockCopy(this.palettePixelData, row * this.rawScanline.Length(), this.rawScanline.Array, 0, this.rawScanline.Length());
this.palettePixelData.AsSpan(row * stride, stride).CopyTo(this.rawScanline.GetSpan());
break; break;
case PngColorType.Grayscale: case PngColorType.Grayscale:
case PngColorType.GrayscaleWithAlpha: case PngColorType.GrayscaleWithAlpha:

Loading…
Cancel
Save