|
|
|
@ -131,6 +131,11 @@ internal sealed class PngDecoderCore : ImageDecoderCore |
|
|
|
/// </summary>
|
|
|
|
private readonly int maxUncompressedLength; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A value indicating whether the image data has been read.
|
|
|
|
/// </summary>
|
|
|
|
private bool hasImageData; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="PngDecoderCore"/> class.
|
|
|
|
/// </summary>
|
|
|
|
@ -749,7 +754,11 @@ internal sealed class PngDecoderCore : ImageDecoderCore |
|
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
|
{ |
|
|
|
using ZlibInflateStream inflateStream = new(this.currentStream, getData); |
|
|
|
inflateStream.AllocateNewBytes(chunkLength, true); |
|
|
|
if (!inflateStream.AllocateNewBytes(chunkLength, !this.hasImageData)) |
|
|
|
{ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
DeflateStream dataStream = inflateStream.CompressedStream!; |
|
|
|
|
|
|
|
if (this.header.InterlaceMethod is PngInterlaceMode.Adam7) |
|
|
|
@ -803,7 +812,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore |
|
|
|
int bytesRead = compressedStream.Read(scanSpan, currentRowBytesRead, bytesPerFrameScanline - currentRowBytesRead); |
|
|
|
if (bytesRead <= 0) |
|
|
|
{ |
|
|
|
return; |
|
|
|
goto EXIT; |
|
|
|
} |
|
|
|
|
|
|
|
currentRowBytesRead += bytesRead; |
|
|
|
@ -848,6 +857,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore |
|
|
|
} |
|
|
|
|
|
|
|
EXIT: |
|
|
|
this.hasImageData = true; |
|
|
|
blendMemory?.Dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -906,7 +916,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore |
|
|
|
int bytesRead = compressedStream.Read(this.scanline.GetSpan(), currentRowBytesRead, bytesPerInterlaceScanline - currentRowBytesRead); |
|
|
|
if (bytesRead <= 0) |
|
|
|
{ |
|
|
|
return; |
|
|
|
goto EXIT; |
|
|
|
} |
|
|
|
|
|
|
|
currentRowBytesRead += bytesRead; |
|
|
|
@ -979,6 +989,7 @@ internal sealed class PngDecoderCore : ImageDecoderCore |
|
|
|
} |
|
|
|
|
|
|
|
EXIT: |
|
|
|
this.hasImageData = true; |
|
|
|
blendMemory?.Dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
|