The problem is with PCX file with 1 plane and 1 or 8 bpp on the plane and a header value of bytes_per_line greater than (width from window) * bpp / 8. I tried to read this file with several other programs (gimp for examble) without any problems.
So I researched the problem:
The scanline is read directly into the dib buffer. However the dib is created with a width corresponding to the width of the window header field. If bytes_per_line doesn't correspond exactly to this, too many bytes are copied to the dib buffer.
I first tried to just read the amount of bytes expected by the dib and leave up the rest to be discarded by the existing for loop, but the loop doesn't handle RLE compression correctly.
So I do not know why at all this loop is there - in my opinion it is a copy paste leftover - but I didn't touch it.
My fix now is to read the line into a temp buffer, like it is done with other plane / bpp combinations and then copy the needed bytes over to the dib.
See attached patch.
Thanks for the bug fix, it is now available in the CVS.
However, this is a "quick and dirty" fix. The PCX format is a very old (and very badly designed) format, and the FreeImage PCX plugin is also very old.
A complete refactoring would be needed, but it's not the priority, as this very bad format should disappear from user's customer databases and should be replaced by the PNG format.
I just hope that you will be able to convert all your images to PNG easily.
Hervé
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem is with PCX file with 1 plane and 1 or 8 bpp on the plane and a header value of bytes_per_line greater than (width from window) * bpp / 8. I tried to read this file with several other programs (gimp for examble) without any problems.
So I researched the problem:
The scanline is read directly into the dib buffer. However the dib is created with a width corresponding to the width of the window header field. If bytes_per_line doesn't correspond exactly to this, too many bytes are copied to the dib buffer.
I first tried to just read the amount of bytes expected by the dib and leave up the rest to be discarded by the existing for loop, but the loop doesn't handle RLE compression correctly.
So I do not know why at all this loop is there - in my opinion it is a copy paste leftover - but I didn't touch it.
My fix now is to read the line into a temp buffer, like it is done with other plane / bpp combinations and then copy the needed bytes over to the dib.
See attached patch.
Last edit: Jojakim Stahl 2017-01-19
Hi Jojakim,
Thanks for the bug fix, it is now available in the CVS.
However, this is a "quick and dirty" fix. The PCX format is a very old (and very badly designed) format, and the FreeImage PCX plugin is also very old.
A complete refactoring would be needed, but it's not the priority, as this very bad format should disappear from user's customer databases and should be replaced by the PNG format.
I just hope that you will be able to convert all your images to PNG easily.
Hervé
Fixed in release 3.18.0