Browse Source

Fix concurrent png decoding

pull/77/head
James Jackson-South 10 years ago
parent
commit
0036208fb4
  1. 6
      src/ImageSharp.Formats.Png/PngDecoderCore.cs

6
src/ImageSharp.Formats.Png/PngDecoderCore.cs

@ -361,7 +361,8 @@ namespace ImageSharp.Formats
byte[] previousScanline = ArrayPool<byte>.Shared.Rent(this.bytesPerScanline); byte[] previousScanline = ArrayPool<byte>.Shared.Rent(this.bytesPerScanline);
byte[] scanline = ArrayPool<byte>.Shared.Rent(this.bytesPerScanline); byte[] scanline = ArrayPool<byte>.Shared.Rent(this.bytesPerScanline);
// Zero out the previousScanline, because the bytes that are rented from the arraypool may not be zero. // Zero out the scanlines, because the bytes that are rented from the arraypool may not be zero.
Array.Clear(scanline, 0, this.bytesPerScanline);
Array.Clear(previousScanline, 0, this.bytesPerScanline); Array.Clear(previousScanline, 0, this.bytesPerScanline);
try try
@ -437,7 +438,8 @@ namespace ImageSharp.Formats
{ {
for (int pass = 0; pass < 7; pass++) for (int pass = 0; pass < 7; pass++)
{ {
// Zero out the previousScanline, because the bytes that are rented from the arraypool may not be zero. // Zero out the scanlines, because the bytes that are rented from the arraypool may not be zero.
Array.Clear(scanline, 0, this.bytesPerScanline);
Array.Clear(previousScanline, 0, this.bytesPerScanline); Array.Clear(previousScanline, 0, this.bytesPerScanline);
int y = Adam7FirstRow[pass]; int y = Adam7FirstRow[pass];

Loading…
Cancel
Save