You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @EliotJones,
I've found a problem with your lib trying to decode this file:
I was using a simple loop to read pixel by pixel the file but something in the output wasn't correct so I tried to simply copy the image into a new one, with this code:
I've found a bug in RawPngData.cs that will result in the skewing effect seen in the output image above. In my case I had a 4bits per pixel image of width 287, an odd number. On line 48 RawPngData.cs we can see this
var bytesInRow = (1 + (width / pixelsPerByte));
Because pixelsPerByte is 2 (we can fit 2 pixels data of 4bits each in a 8bits byte) we get 1 + 143.5 but because we are working with int the .5 gets trunked. So it is bytesInRow = 1 + 143 = 144 which is obviously wrong because an image of width 286 would give us 1 + (286 / 2) = 144 too!
This means all image with an odd width and less than 16 colors will have this bug.
My dirty solution was to round up the division like this:
var bytesInRow = (int)(1 + Math.Ceiling((double)width / pixelsPerByte));
Hi @EliotJones,
I've found a problem with your lib trying to decode this file:
I was using a simple loop to read pixel by pixel the file but something in the output wasn't correct so I tried to simply copy the image into a new one, with this code:
The output image is this:
The input file seems to be ok (you can inspect it here)
With other files (created using the same process) this problem doesn't shows up.
Any thoughts?
Thanks
The text was updated successfully, but these errors were encountered: