Open ExtReMLapin opened 1 year ago
@ExtReMLapin could you add support for BMPs with negative height?
You just have to change the unpack
format specification to "<Ll"
(or maybe "<ll"
if you also want to supported signed width, but I don't know if width < 0
is allowed) and add height = abs(height)
, then it will work fine.
Here is an example (I had to zip it, because GitHub do not support .bmp
images)
negative-height.zip
Here is the same image, but converted to .png
In this example (if correctly parsed), it must consist of a 100 x 300
image where the top is a red square, the middle is a green square, and the bottom is a blue square. On the BMP header, the height is specified as -300
, i.e., the struct.unpack
call as-is would return (100, 4294966996)
.
🤠Done !
tested with 24bits bmp and 1bit bmp