more clever code for BMP hack
This commit is contained in:
parent
1006a71b1d
commit
474d7179a4
|
@ -555,6 +555,7 @@ img_t gfx_combine(img_t src, img_t dst)
|
||||||
static img_t _gfx_load_image(char *filename)
|
static img_t _gfx_load_image(char *filename)
|
||||||
{
|
{
|
||||||
SDL_Surface *img;
|
SDL_Surface *img;
|
||||||
|
SDL_RWops *rwop;
|
||||||
int nr = 0;
|
int nr = 0;
|
||||||
if (strstr(filename,".gif") || strstr(filename,".GIF"))
|
if (strstr(filename,".gif") || strstr(filename,".GIF"))
|
||||||
nr = AG_LoadGIF(filename, NULL, 0, NULL);
|
nr = AG_LoadGIF(filename, NULL, 0, NULL);
|
||||||
|
@ -571,19 +572,17 @@ static img_t _gfx_load_image(char *filename)
|
||||||
anigif_add(agif);
|
anigif_add(agif);
|
||||||
return agif->frames[0].surface;
|
return agif->frames[0].surface;
|
||||||
}
|
}
|
||||||
img = IMG_Load(filename);
|
rwop = SDL_RWFromFile(filename, "rb");
|
||||||
if (!img) {
|
if (!rwop)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
img = IMG_Load_RW(rwop, 0);
|
||||||
if (img->format->BitsPerPixel == 32) { /* hack for 32 bit BMP :( */
|
if (!img)
|
||||||
SDL_RWops *rwop;
|
goto out;
|
||||||
rwop = SDL_RWFromFile(filename, "rb");
|
if (img->format->BitsPerPixel == 32 &&
|
||||||
if (rwop) {
|
IMG_isBMP(rwop))/* hack for 32 bit BMP :( */
|
||||||
if (IMG_isBMP(rwop))
|
SDL_SetAlpha(img, 0, SDL_ALPHA_OPAQUE);
|
||||||
SDL_SetAlpha(img, SDL_RLEACCEL, SDL_ALPHA_OPAQUE);
|
out:
|
||||||
SDL_FreeRW(rwop);
|
SDL_FreeRW(rwop);
|
||||||
}
|
|
||||||
}
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue