Browse Source

Use optimized write CopyTo for png encoding

pull/30/head
James Jackson-South 10 years ago
parent
commit
6dfb6a8023
  1. 3
      src/ImageSharp/Formats/Png/PngEncoderCore.cs

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

@ -317,8 +317,7 @@ namespace ImageSharp.Formats
where TPacked : struct
{
// We can use the optimized PixelAccessor here and copy the bytes in unmanaged memory.
int bpp = this.bytesPerPixel;
using (PixelRow<TColor, TPacked> pixelRow = new PixelRow<TColor, TPacked>(this.width, rawScanline, bpp == 4 ? ComponentOrder.XYZW : ComponentOrder.XYZ))
using (PixelRow<TColor, TPacked> pixelRow = new PixelRow<TColor, TPacked>(this.width, rawScanline, this.bytesPerPixel == 4 ? ComponentOrder.XYZW : ComponentOrder.XYZ))
{
pixels.CopyTo(pixelRow, row);
}

Loading…
Cancel
Save