|
|
|
@ -440,28 +440,28 @@ namespace ImageSharp.Formats |
|
|
|
where TColor : struct, IPackedPixel<TPacked> |
|
|
|
where TPacked : struct |
|
|
|
{ |
|
|
|
for (int pass = 0; pass < 7; pass++) |
|
|
|
{ |
|
|
|
int y = Adam7FirstRow[pass]; |
|
|
|
int numColumns = this.ComputeColumnsAdam7(pass); |
|
|
|
|
|
|
|
if (numColumns == 0) |
|
|
|
{ |
|
|
|
// This pass contains no data; skip to next pass
|
|
|
|
continue; |
|
|
|
} |
|
|
|
byte[] previousScanline = ArrayPool<byte>.Shared.Rent(this.bytesPerScanline); |
|
|
|
byte[] scanline = ArrayPool<byte>.Shared.Rent(this.bytesPerScanline); |
|
|
|
|
|
|
|
int bytesPerInterlaceScanline = this.CalculateScanlineLength(numColumns) + 1; |
|
|
|
// Zero out the previousScanline, because the bytes that are rented from the arraypool may not be zero.
|
|
|
|
Array.Clear(previousScanline, 0, this.bytesPerScanline); |
|
|
|
|
|
|
|
while (y < this.header.Height) |
|
|
|
try |
|
|
|
{ |
|
|
|
for (int pass = 0; pass < 7; pass++) |
|
|
|
{ |
|
|
|
byte[] previousScanline = ArrayPool<byte>.Shared.Rent(this.bytesPerScanline); |
|
|
|
byte[] scanline = ArrayPool<byte>.Shared.Rent(this.bytesPerScanline); |
|
|
|
int y = Adam7FirstRow[pass]; |
|
|
|
int numColumns = this.ComputeColumnsAdam7(pass); |
|
|
|
|
|
|
|
// Zero out the previousScanline, because the bytes that are rented from the arraypool may not be zero.
|
|
|
|
Array.Clear(previousScanline, 0, this.bytesPerScanline); |
|
|
|
if (numColumns == 0) |
|
|
|
{ |
|
|
|
// This pass contains no data; skip to next pass
|
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
try |
|
|
|
int bytesPerInterlaceScanline = this.CalculateScanlineLength(numColumns) + 1; |
|
|
|
|
|
|
|
while (y < this.header.Height) |
|
|
|
{ |
|
|
|
compressedStream.Read(scanline, 0, bytesPerInterlaceScanline); |
|
|
|
|
|
|
|
@ -506,16 +506,17 @@ namespace ImageSharp.Formats |
|
|
|
this.ProcessInterlacedDefilteredScanline(scanline, y, pixels, Adam7FirstColumn[pass], Adam7ColumnIncrement[pass]); |
|
|
|
|
|
|
|
Swap(ref scanline, ref previousScanline); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
ArrayPool<byte>.Shared.Return(previousScanline); |
|
|
|
ArrayPool<byte>.Shared.Return(scanline); |
|
|
|
} |
|
|
|
|
|
|
|
y += Adam7RowIncrement[pass]; |
|
|
|
|
|
|
|
y += Adam7RowIncrement[pass]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
ArrayPool<byte>.Shared.Return(previousScanline); |
|
|
|
ArrayPool<byte>.Shared.Return(scanline); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -765,7 +766,6 @@ namespace ImageSharp.Formats |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Reads a text chunk containing image properties from the data.
|
|
|
|
/// </summary>
|
|
|
|
|