Can't read transparent BMP images

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Jason S
Posts: 103
Joined: 2010-12-14T19:42:12-07:00
Authentication code: 8675308

Can't read transparent BMP images

Post by Jason S »

Version 6.8.0-4 supports the transparency in the these BMP images: rgba16-4444.bmp rgba32.bmp, but 6.8.0-5 does not.

Here's what changed in the code:

Code: Select all

6.8.0-4:coders/bmp.c:846

    image->matte=(bmp_info.alpha_mask != 0) ||
      ((bmp_info.compression == BI_RGB) && (bmp_info.bits_per_pixel == 32)) ?
      MagickTrue : MagickFalse;

6.8.0-5:

    image->matte=(bmp_info.alpha_mask != 0) &&
      ((bmp_info.compression == BI_RGB) && (bmp_info.bits_per_pixel == 32)) ?
      MagickTrue : MagickFalse;
I suggest this instead:

Code: Select all

    image->matte=(bmp_info.alpha_mask != 0) &&
      (bmp_info.compression == BI_BITFIELDS) ?
      MagickTrue : MagickFalse;
Although Microsoft's documentation implies that the alpha_mask field is valid for BI_RGB images, it also says what all the bits are used for, and leaves none of them available for an alpha mask. If you want to try to allow some BI_RGB images to have transparency, I wouldn't object, but I don't think it's necessary, and it would have to be done very carefully.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Can't read transparent BMP images

Post by glennrp »

Jason, "magick" committed your patch at SVN revision 10011; it will appear in IM-6.8.0-6.
Post Reply