#209 Can\'t open BMP with alpha created by photoshop

closed-fixed
5
2012-10-09
2012-09-10
Anonymous
No

Alpha channel is not loaded from bmp images created by photoshop. Also same problem seems to be with GIMP images.
It is questionable if it is bug or desired behavior.

Possible fix, but not really good one:
diff -r ea545a5f4e80 -r 9b385d2dec2c coders/bmp.c
--- a/coders/bmp.c Sat Jun 23 16:04:57 2012 -0500
+++ b/coders/bmp.c Wed Jul 11 20:18:00 2012 +0400
@@ -836,7 +836,7 @@
image->columns=bmp_info.width;
image->rows=AbsoluteValue(bmp_info.height);
image->depth=8;
- image->matte=bmp_info.alpha_mask != 0;
+ image->matte=bmp_info.alpha_mask ? 1 : (bmp_info.bits_per_pixel == 32 ? 1 : 0);
if ((bmp_info.number_colors != 0) || (bmp_info.bits_per_pixel < 16))
{
image->storage_class=PseudoClass;
@@ -928,7 +928,7 @@
*/
if (bmp_info.compression == BI_RGB)
{
- bmp_info.alpha_mask=0;
+ bmp_info.alpha_mask=image->matte ? 0xff000000L : 0;
bmp_info.red_mask=0x00ff0000L;
bmp_info.green_mask=0x0000ff00L;
bmp_info.blue_mask=0x000000ffL;

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2012-09-10
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2012-10-09
    • status: open --> closed-fixed
     
  • Bob Friesenhahn

    Bob Friesenhahn - 2012-10-09

    Thanks for the heads up. Your fix is applied but with a small correction to assure that it is only used with compression type 0 since 32-bits has a different (valid) meaning if compression type 3 is used.

    The changes are in changeset 13744:558bfdcde368

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks