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



commit d8c164ced3c96e150b8600c3b35cd8876b93465a
Author: Jacob Boerema <jgboerema gmail com>
Date:   Thu Jan 7 17:52:48 2021 -0500

    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.

 plug-ins/file-bmp/bmp-save.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/plug-ins/file-bmp/bmp-save.c b/plug-ins/file-bmp/bmp-save.c
index f23319c756..7fdbdf9c55 100644
--- a/plug-ins/file-bmp/bmp-save.c
+++ b/plug-ins/file-bmp/bmp-save.c
@@ -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 */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]