From de38df75f1e27a35f144ae4a2a87ca842ac57950 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 7 Jul 2013 12:53:21 -0700 Subject: [PATCH] Fixed bug 1943 - Wrong handling of legacy 32bpp BMP files Kang Seonghoon While BMP format supports alpha channel, it is enabled only when the header is at least 56 bytes long (BITMAPV3INFOHEADER and later). For very common 40-byte-long header (BITMAPINFOHEADER) 32bpp format should be interpreted as BGRX format, but currently SDL interprets them as BGRA format and causes a significant compatibility problem as many 32bpp files use a padding byte of 0 ("transparent" in BGRA interpretation). --- src/video/SDL_bmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 7ee65d85d..2ec66014c 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -182,7 +182,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) #endif break; case 32: - Amask = 0xFF000000; + Amask = (biSize < 56 ? 0 : 0xFF000000); /* no alpha before BITMAPV3INFOHEADER */ Rmask = 0x00FF0000; Gmask = 0x0000FF00; Bmask = 0x000000FF;