Adds handling of negative height value for bmp files. (#644)

* Adds handling of negative height value for bmp files.

* Simplifies negative height check, and moves it down to include checking the OS/2 16-bit version.

* Adds int16 conversion to OS/2 height.
This commit is contained in:
Joshua Banton
2021-06-23 15:52:25 +06:00
committed by GitHub
parent e8b1c320bf
commit 9a3feab9cc
+7 -2
View File
@@ -29,11 +29,16 @@ func DecodeBmpMeta(r io.Reader) (Meta, error) {
if infoSize >= 40 {
width = int(binary.LittleEndian.Uint32(tmp[18:22]))
height = int(binary.LittleEndian.Uint32(tmp[22:26]))
height = int(int32(binary.LittleEndian.Uint32(tmp[22:26])))
} else {
// CORE
width = int(binary.LittleEndian.Uint16(tmp[18:20]))
height = int(binary.LittleEndian.Uint16(tmp[20:22]))
height = int(int16(binary.LittleEndian.Uint16(tmp[20:22])))
}
// height can be negative in Windows bitmaps
if height < 0 {
height = -height
}
return &meta{