Skip to content

Commit

Permalink
Workaround for bogus bitmasks used by ImageMagic and the GIMP
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jul 9, 2014
1 parent d66015c commit 023289c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions IMG_bmp.c
Expand Up @@ -391,6 +391,22 @@ static SDL_Surface *LoadBMP_RW (SDL_RWops *src, int freesrc)
Gmask = SDL_ReadLE32(src);
Bmask = SDL_ReadLE32(src);
Amask = SDL_ReadLE32(src);

/* ImageMagick seems to put out bogus masks here. Pick a default. */
if ((Rmask == 0xFFFFFF) && (Gmask == 0xFFFFFF) &&
(Bmask == 0xFFFFFF) && (Amask == 0xFFFFFF) ) {
Amask = 0xFF000000;
Rmask = 0x00FF0000;
Gmask = 0x0000FF00;
Bmask = 0x000000FF;
} else if ((Rmask == 0xFFFFFF00) && (Gmask == 0xFFFFFF00) &&
(Bmask == 0xFFFFFF00) && (Amask == 0xFFFFFF00) ) {
/* argh, The Gimp seems to put out different bogus masks! */
Amask = 0x000000FF;
Rmask = 0xFF000000;
Gmask = 0x00FF0000;
Bmask = 0x0000FF00;
}
break;
default:
break;
Expand Down

0 comments on commit 023289c

Please sign in to comment.