BMP: support bitmask of more than 8 bits

This commit is contained in:
Thomas Bernard 2019-01-08 22:06:31 +01:00
parent 51f90c7ec0
commit 0b45bc5fc6
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C

View File

@ -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;
}