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



commit b38eedad010ca27dd6a995d414ef675136f0f8b0
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.
    
    (cherry picked from commit d8c164ced3c96e150b8600c3b35cd8876b93465a)

 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 c8abc36214..4294ce526f 100644
--- a/plug-ins/file-bmp/bmp-save.c
+++ b/plug-ins/file-bmp/bmp-save.c
@@ -371,7 +371,11 @@ save_image (const gchar  *filename,
 
   if (BMPSaveData.use_run_length_encoding == 0)
     {
-      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]