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;
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<TPixel>(Stream compressedStream, PixelAccessor<TPixel> pixels)
where TPixel : struct, IPixel<TPixel>
{
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;
}
}
}

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