DEBUG and RELEASE modeException happens when files loaded from stream. It only happens with some interlaced PNG files, particularly with the following 2 files


I have tested the same code with interlaced PNG from your repository plash-interlaced.png and it was successfully loaded.
using (var fileStream = File.OpenWrite(filePath)) { input.Seek(0, SeekOrigin.Begin);> var image = Image.Load(input); }
Exception is:
System.ArgumentOutOfRangeException : Non-negative number required.
Parameter name: count
at System.IO.Win32FileStream.Read(Byte[] array, Int32 offset, Int32 count)
at System.IO.FileStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Compression.DeflateStream.Read(Byte[] array, Int32 offset, Int32 count)
at ImageSharp.Formats.ZlibInflateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at ImageSharp.Formats.PngDecoderCore.DecodeInterlacedPixelData[TPixel](Stream compressedStream, PixelAccessor1 pixels)
at ImageSharp.Formats.PngDecoderCore.Decode[TPixel](Stream stream)
at ImageSharp.Formats.PngDecoder.Decode[TPixel](Configuration configuration, Stream stream, IDecoderOptions options)
at ImageSharp.Image.Decode[TPixel](Stream stream, IDecoderOptions options, Configuration config)
at ImageSharp.Image.Load[TPixel](Configuration config, Stream stream, IDecoderOptions options)
at ImageSharp.Image.Load(Stream stream)
@Drawaes When you have some time could you possibly have a look at this?
I've been trying to debug the issue for a couple of hours now to no avail.
From what I can see the crc reading that is taking place within ZlibInflateStream is causing the private currentDataRemaining field in DeframeStream to be negative -4. Then, and I'm not sure how it's getting called, DeframeStream.Read(byte[] buffer, int offset, int count) is called which throws our error.
I'm a wee bit stumped.
I think I know what the issue is without looking at it. But I would need
the exact test image.
On 27/04/2017 4:11 AM, "James Jackson-South" notifications@github.com
wrote:
@Drawaes https://github.com/Drawaes When you have some time could you
possibly have a look at this?I've been trying to debug the issue for a couple of hours now to no avail.
From what I can see the crc reading that is taking place within
ZlibInflateStream is causing the private currentDataRemaining field in
DeframeStream to be negative -4. Then, and I'm not sure how it's getting
called DeframeStream.Read(byte[] buffer, int offset, int count) is called
which throws our error.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/JimBobSquarePants/ImageSharp/issues/191#issuecomment-297599433,
or mute the thread
https://github.com/notifications/unsubscribe-auth/APpZuQ9wL44k1o3J-YFJ3dzOk0LriADSks5r0AdbgaJpZM4NJJ8h
.
I am pretty sure I know how to fix it and it will make it faster at the same time.
Wizzzzzzaaaard!
Okay I have a fix for that bug, but it has highlighted another issue with the interlaced PNG. I will work on fixing that tonight.
@srudenko This is now fixed with #196 Should be good to go 😄
I can confirm that the issue has been fixed in 1.0.0-alpha8-00058. Tested using different types of images including the provided.,