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>
{
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:

Loading…
Cancel
Save