src/video/SDL_bmp.c
changeset 3497 74d2f44a85de
parent 3310 b907e83deb88
child 3697 f7b03b6838cb
equal deleted inserted replaced
3496:78fc8ea578b2 3497:74d2f44a85de
    55     int i, pad;
    55     int i, pad;
    56     SDL_Surface *surface;
    56     SDL_Surface *surface;
    57     Uint32 Rmask;
    57     Uint32 Rmask;
    58     Uint32 Gmask;
    58     Uint32 Gmask;
    59     Uint32 Bmask;
    59     Uint32 Bmask;
       
    60     Uint32 Amask;
    60     SDL_Palette *palette;
    61     SDL_Palette *palette;
    61     Uint8 *bits;
    62     Uint8 *bits;
    62     Uint8 *top, *end;
    63     Uint8 *top, *end;
    63     SDL_bool topDown;
    64     SDL_bool topDown;
    64     int ExpandBMP;
    65     int ExpandBMP;
   158         ExpandBMP = 0;
   159         ExpandBMP = 0;
   159         break;
   160         break;
   160     }
   161     }
   161 
   162 
   162     /* We don't support any BMP compression right now */
   163     /* We don't support any BMP compression right now */
   163     Rmask = Gmask = Bmask = 0;
   164     Rmask = Gmask = Bmask = Amask = 0;
   164     switch (biCompression) {
   165     switch (biCompression) {
   165     case BI_RGB:
   166     case BI_RGB:
   166         /* If there are no masks, use the defaults */
   167         /* If there are no masks, use the defaults */
   167         if (bfOffBits == (14 + biSize)) {
   168         if (bfOffBits == (14 + biSize)) {
   168             /* Default values for the BMP format */
   169             /* Default values for the BMP format */
   176             case 24:
   177             case 24:
   177 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
   178 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
   178                 Rmask = 0x000000FF;
   179                 Rmask = 0x000000FF;
   179                 Gmask = 0x0000FF00;
   180                 Gmask = 0x0000FF00;
   180                 Bmask = 0x00FF0000;
   181                 Bmask = 0x00FF0000;
       
   182 #else
       
   183                 Rmask = 0x00FF0000;
       
   184                 Gmask = 0x0000FF00;
       
   185                 Bmask = 0x000000FF;
       
   186 #endif
   181                 break;
   187                 break;
   182 #endif
       
   183             case 32:
   188             case 32:
       
   189                 Amask = 0xFF000000;
   184                 Rmask = 0x00FF0000;
   190                 Rmask = 0x00FF0000;
   185                 Gmask = 0x0000FF00;
   191                 Gmask = 0x0000FF00;
   186                 Bmask = 0x000000FF;
   192                 Bmask = 0x000000FF;
   187                 break;
   193                 break;
   188             default:
   194             default:
   194 
   200 
   195     case BI_BITFIELDS:
   201     case BI_BITFIELDS:
   196         switch (biBitCount) {
   202         switch (biBitCount) {
   197         case 15:
   203         case 15:
   198         case 16:
   204         case 16:
       
   205             Rmask = SDL_ReadLE32(src);
       
   206             Gmask = SDL_ReadLE32(src);
       
   207             Bmask = SDL_ReadLE32(src);
       
   208             break;
   199         case 32:
   209         case 32:
   200             Rmask = SDL_ReadLE32(src);
   210             Rmask = SDL_ReadLE32(src);
   201             Gmask = SDL_ReadLE32(src);
   211             Gmask = SDL_ReadLE32(src);
   202             Bmask = SDL_ReadLE32(src);
   212             Bmask = SDL_ReadLE32(src);
       
   213             Amask = SDL_ReadLE32(src);
   203             break;
   214             break;
   204         default:
   215         default:
   205             break;
   216             break;
   206         }
   217         }
   207         break;
   218         break;
   212     }
   223     }
   213 
   224 
   214     /* Create a compatible surface, note that the colors are RGB ordered */
   225     /* Create a compatible surface, note that the colors are RGB ordered */
   215     surface =
   226     surface =
   216         SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask,
   227         SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask,
   217                              Bmask, 0);
   228                              Bmask, Amask);
   218     if (surface == NULL) {
   229     if (surface == NULL) {
   219         was_error = SDL_TRUE;
   230         was_error = SDL_TRUE;
   220         goto done;
   231         goto done;
   221     }
   232     }
   222 
   233