Make SDL_LoadBMP() work with 32-bit bitmaps from ImageMagick.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 09 Jul 2014 00:01:34 -0400
changeset 9000670efcbd447d
parent 8999 c6398920a9ca
child 9001 c750aab87e82
Make SDL_LoadBMP() work with 32-bit bitmaps from ImageMagick.
src/video/SDL_bmp.c
     1.1 --- a/src/video/SDL_bmp.c	Tue Jul 08 16:17:06 2014 -0400
     1.2 +++ b/src/video/SDL_bmp.c	Wed Jul 09 00:01:34 2014 -0400
     1.3 @@ -246,6 +246,16 @@
     1.4              Gmask = SDL_ReadLE32(src);
     1.5              Bmask = SDL_ReadLE32(src);
     1.6              Amask = SDL_ReadLE32(src);
     1.7 +
     1.8 +            /* ImageMagick seems to put out bogus masks here. Pick a default. */
     1.9 +            if ((Rmask == 0xFFFFFF) && (Gmask == 0xFFFFFF) &&
    1.10 +                (Bmask == 0xFFFFFF) && (Amask == 0xFFFFFF) ) {
    1.11 +                Amask = 0xFF000000;
    1.12 +                Rmask = 0x00FF0000;
    1.13 +                Gmask = 0x0000FF00;
    1.14 +                Bmask = 0x000000FF;
    1.15 +            }
    1.16 +
    1.17              break;
    1.18          default:
    1.19              break;