Added support for 32-bit BMP files with an alpha channel
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404238
This commit is contained in:
parent
215689096f
commit
a8a1831e74
1 changed files with 14 additions and 3 deletions
|
@ -57,6 +57,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||||
Uint32 Rmask;
|
Uint32 Rmask;
|
||||||
Uint32 Gmask;
|
Uint32 Gmask;
|
||||||
Uint32 Bmask;
|
Uint32 Bmask;
|
||||||
|
Uint32 Amask;
|
||||||
SDL_Palette *palette;
|
SDL_Palette *palette;
|
||||||
Uint8 *bits;
|
Uint8 *bits;
|
||||||
Uint8 *top, *end;
|
Uint8 *top, *end;
|
||||||
|
@ -160,7 +161,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We don't support any BMP compression right now */
|
/* We don't support any BMP compression right now */
|
||||||
Rmask = Gmask = Bmask = 0;
|
Rmask = Gmask = Bmask = Amask = 0;
|
||||||
switch (biCompression) {
|
switch (biCompression) {
|
||||||
case BI_RGB:
|
case BI_RGB:
|
||||||
/* If there are no masks, use the defaults */
|
/* If there are no masks, use the defaults */
|
||||||
|
@ -178,9 +179,14 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||||
Rmask = 0x000000FF;
|
Rmask = 0x000000FF;
|
||||||
Gmask = 0x0000FF00;
|
Gmask = 0x0000FF00;
|
||||||
Bmask = 0x00FF0000;
|
Bmask = 0x00FF0000;
|
||||||
break;
|
#else
|
||||||
|
Rmask = 0x00FF0000;
|
||||||
|
Gmask = 0x0000FF00;
|
||||||
|
Bmask = 0x000000FF;
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
|
Amask = 0xFF000000;
|
||||||
Rmask = 0x00FF0000;
|
Rmask = 0x00FF0000;
|
||||||
Gmask = 0x0000FF00;
|
Gmask = 0x0000FF00;
|
||||||
Bmask = 0x000000FF;
|
Bmask = 0x000000FF;
|
||||||
|
@ -196,10 +202,15 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||||
switch (biBitCount) {
|
switch (biBitCount) {
|
||||||
case 15:
|
case 15:
|
||||||
case 16:
|
case 16:
|
||||||
|
Rmask = SDL_ReadLE32(src);
|
||||||
|
Gmask = SDL_ReadLE32(src);
|
||||||
|
Bmask = SDL_ReadLE32(src);
|
||||||
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
Rmask = SDL_ReadLE32(src);
|
Rmask = SDL_ReadLE32(src);
|
||||||
Gmask = SDL_ReadLE32(src);
|
Gmask = SDL_ReadLE32(src);
|
||||||
Bmask = SDL_ReadLE32(src);
|
Bmask = SDL_ReadLE32(src);
|
||||||
|
Amask = SDL_ReadLE32(src);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -214,7 +225,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc)
|
||||||
/* Create a compatible surface, note that the colors are RGB ordered */
|
/* Create a compatible surface, note that the colors are RGB ordered */
|
||||||
surface =
|
surface =
|
||||||
SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask,
|
SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask,
|
||||||
Bmask, 0);
|
Bmask, Amask);
|
||||||
if (surface == NULL) {
|
if (surface == NULL) {
|
||||||
was_error = SDL_TRUE;
|
was_error = SDL_TRUE;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue