From 0b45bc5fc6b42b3f29f8e811e216d7cf768cb398 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 8 Jan 2019 22:06:31 +0100 Subject: [PATCH] BMP: support bitmask of more than 8 bits --- src/fileformats.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fileformats.c b/src/fileformats.c index 50cd8821..91b34680 100644 --- a/src/fileformats.c +++ b/src/fileformats.c @@ -3120,8 +3120,10 @@ void Test_BMP(T_IO_Context * context, FILE * file) static byte Bitmap_mask(dword pixel, dword mask, int bits, int shift) { dword value = (pixel & mask) >> shift; - if (bits != 8) + if (bits < 8) value = (value << (8 - bits)) | (value >> (2 * bits - 8)); + else if (bits > 8) + value >>= (bits - 8); return (byte)value; }