diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index aece86700..05ba5ee60 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -191,7 +191,7 @@ namespace ImageSharp.Formats PixelAccessor pixels = null; try { - using (DeframeStream deframeStream = new DeframeStream(this.currentStream)) + using (ZlibInflateStream deframeStream = new ZlibInflateStream(this.currentStream)) { PngChunk currentChunk; while (!this.isEndChunkReached && (currentChunk = this.ReadChunk()) != null) @@ -492,12 +492,14 @@ namespace ImageSharp.Formats private void DecodeInterlacedPixelData(Stream compressedStream, PixelAccessor pixels) where TPixel : struct, IPixel { - while (this.pass < 7) + while (true) { int numColumns = this.ComputeColumnsAdam7(this.pass); if (numColumns == 0) { + this.pass++; + // This pass contains no data; skip to next pass continue; } @@ -561,6 +563,14 @@ namespace ImageSharp.Formats } this.pass++; + if (this.pass < 7) + { + this.currentRow = Adam7FirstRow[this.pass]; + } + else + { + break; + } } } diff --git a/src/ImageSharp/Formats/Png/Zlib/Adler32.cs b/src/ImageSharp/Formats/Png/Zlib/Adler32.cs index 56b116cd3..5f92cc9e0 100644 --- a/src/ImageSharp/Formats/Png/Zlib/Adler32.cs +++ b/src/ImageSharp/Formats/Png/Zlib/Adler32.cs @@ -52,7 +52,7 @@ namespace ImageSharp.Formats /// checked separately. (Any sequence of zeroes has a Fletcher /// checksum of zero.)" /// - /// + /// /// internal sealed class Adler32 : IChecksum { diff --git a/src/ImageSharp/Formats/Png/Zlib/DeframeStream.cs b/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs similarity index 97% rename from src/ImageSharp/Formats/Png/Zlib/DeframeStream.cs rename to src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs index 2e92fd52d..0743d8ded 100644 --- a/src/ImageSharp/Formats/Png/Zlib/DeframeStream.cs +++ b/src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs @@ -9,7 +9,7 @@ /// /// Provides methods and properties for deframing streams from PNGs. /// - internal class DeframeStream : Stream + internal class ZlibInflateStream : Stream { /// /// The inner raw memory stream @@ -45,10 +45,10 @@ private int currentDataRemaining; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The inner raw stream - public DeframeStream(Stream innerStream) + public ZlibInflateStream(Stream innerStream) { this.innerStream = innerStream; }