Browse Source

Fixed interlaced PNG

af/merge-core
Drawaes 9 years ago
parent
commit
ae55dbed46
  1. 14
      src/ImageSharp/Formats/Png/PngDecoderCore.cs
  2. 2
      src/ImageSharp/Formats/Png/Zlib/Adler32.cs
  3. 6
      src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs

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

@ -191,7 +191,7 @@ namespace ImageSharp.Formats
PixelAccessor<TPixel> pixels = null; PixelAccessor<TPixel> pixels = null;
try try
{ {
using (DeframeStream deframeStream = new DeframeStream(this.currentStream)) using (ZlibInflateStream deframeStream = new ZlibInflateStream(this.currentStream))
{ {
PngChunk currentChunk; PngChunk currentChunk;
while (!this.isEndChunkReached && (currentChunk = this.ReadChunk()) != null) while (!this.isEndChunkReached && (currentChunk = this.ReadChunk()) != null)
@ -492,12 +492,14 @@ namespace ImageSharp.Formats
private void DecodeInterlacedPixelData<TPixel>(Stream compressedStream, PixelAccessor<TPixel> pixels) private void DecodeInterlacedPixelData<TPixel>(Stream compressedStream, PixelAccessor<TPixel> pixels)
where TPixel : struct, IPixel<TPixel> where TPixel : struct, IPixel<TPixel>
{ {
while (this.pass < 7) while (true)
{ {
int numColumns = this.ComputeColumnsAdam7(this.pass); int numColumns = this.ComputeColumnsAdam7(this.pass);
if (numColumns == 0) if (numColumns == 0)
{ {
this.pass++;
// This pass contains no data; skip to next pass // This pass contains no data; skip to next pass
continue; continue;
} }
@ -561,6 +563,14 @@ namespace ImageSharp.Formats
} }
this.pass++; this.pass++;
if (this.pass < 7)
{
this.currentRow = Adam7FirstRow[this.pass];
}
else
{
break;
}
} }
} }

2
src/ImageSharp/Formats/Png/Zlib/Adler32.cs

@ -52,7 +52,7 @@ namespace ImageSharp.Formats
/// checked separately. (Any sequence of zeroes has a Fletcher /// checked separately. (Any sequence of zeroes has a Fletcher
/// checksum of zero.)" /// checksum of zero.)"
/// </remarks> /// </remarks>
/// <see cref="DeframeStream"/> /// <see cref="ZlibInflateStream"/>
/// <see cref="ZlibDeflateStream"/> /// <see cref="ZlibDeflateStream"/>
internal sealed class Adler32 : IChecksum internal sealed class Adler32 : IChecksum
{ {

6
src/ImageSharp/Formats/Png/Zlib/DeframeStream.cs → src/ImageSharp/Formats/Png/Zlib/ZlibInflateStream.cs

@ -9,7 +9,7 @@
/// <summary> /// <summary>
/// Provides methods and properties for deframing streams from PNGs. /// Provides methods and properties for deframing streams from PNGs.
/// </summary> /// </summary>
internal class DeframeStream : Stream internal class ZlibInflateStream : Stream
{ {
/// <summary> /// <summary>
/// The inner raw memory stream /// The inner raw memory stream
@ -45,10 +45,10 @@
private int currentDataRemaining; private int currentDataRemaining;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="DeframeStream"/> class. /// Initializes a new instance of the <see cref="ZlibInflateStream"/> class.
/// </summary> /// </summary>
/// <param name="innerStream">The inner raw stream</param> /// <param name="innerStream">The inner raw stream</param>
public DeframeStream(Stream innerStream) public ZlibInflateStream(Stream innerStream)
{ {
this.innerStream = innerStream; this.innerStream = innerStream;
} }
Loading…
Cancel
Save