Browse Source

Fix alpha condition

Viktor Sokolov 3 months ago
parent
commit
fc51f718f3
1 changed files with 3 additions and 4 deletions
  1. 3 4
      vips/bmpload.c

+ 3 - 4
vips/bmpload.c

@@ -216,11 +216,10 @@ vips_foreign_load_bmp_header(VipsForeignLoad *load)
   if (info_header_len > BMP_BITMAP_INFO_HEADER_LEN) {
     has_alpha = GUINT32_FROM_LE(*(uint32_t *) (info_header + 48)) != 0;
   }
-  else {
-    has_alpha = (bpp == 32); // otherwise, rely on the bpp value
-  }
 
-  if (has_alpha) {
+  // Target image should have alpha channel only in case source image has alpha channel
+  // AND source image alpha mask is not zero
+  if ((bpp == 32) && (has_alpha)) {
     bands = 4;
   }