plug-ins: fix #6144 Unrecognised or invalid BMP compression format.

The Microsoft specification for BITMAPV5HEADER says that
BI_BITFIELDS is valid for 16 and 32-bits per pixel, but we
were also using this flag for other values of bpp when
no rle compression was used.
Since this specification doesn't mention 24 bpp or other
values use BI_RGB instead.
This commit is contained in:
Jacob Boerema 2021-01-07 17:52:48 -05:00
parent e96dba41f4
commit d8c164ced3
1 changed files with 5 additions and 1 deletions

View File

@ -377,7 +377,11 @@ save_image (GFile *file,
if (! use_rle)
{
if (mask_info_size > 0)
/* The Microsoft specification for BITMAPV5HEADER says that
* BI_BITFIELDS is valid for 16 and 32-bits per pixel,
* Since it doesn't mention 24 bpp or other numbers
* use BI_RGB for that. See issue #6114. */
if (mask_info_size > 0 && (BitsPerPixel == 16 || BitsPerPixel == 32))
bitmap_head.biCompr = 3; /* BI_BITFIELDS */
else
bitmap_head.biCompr = 0; /* BI_RGB */