We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2878

Summary: SDL_LoadBMP masks alpha channel
Product: SDL Reporter: Keith Campbell <keith>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: 2.0.3Keywords: triage-2.0.4
Hardware: x86_64   
OS: Mac OS X 10.8   
Attachments: Reproduction program.
Reproduction BMP image with alpha channel.

Description Keith Campbell 2015-02-12 02:05:57 UTC
Created attachment 2030 [details]
Reproduction program.

This is on Mac OS 10.10.2

The problem is exemplified through the attached reproduction program, which reports the pixel format for the SDL_Surface created by SDL_LoadBMP when loading the attached bitmap file. The expected result is a nonzero alpha mask, instead here's what I observer:

> clang bug.c -framework SDL2 -o bug
> ./bug bug.bmp
format: 0x16161804
palette: 0x0
BitsPerPixel: 32
BytesPerPixel: 4
Rmask: 0x00ff0000
Gmask: 0x0000ff00
Bmask: 0x000000ff
Amask: 0x00000000

A known workaround (which works for me at least) is to insert the following code after the surface is created:
> surface->format->format = SDL_PIXELFORMAT_ARGB8888;
This seems to trick SDL into doing proper alpha blending with the surface as the alpha bits are already there.
Comment 1 Keith Campbell 2015-02-12 02:07:36 UTC
Created attachment 2031 [details]
Reproduction BMP image with alpha channel.
Comment 2 Keith Campbell 2015-02-12 02:13:37 UTC
FYI: The attached image was created with ImageMagick
Comment 3 Ryan C. Gordon 2015-02-19 06:32:14 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry
if you got a lot of email from this. This is to help me sort through some bugs
in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4,
though!
Comment 4 Ryan C. Gordon 2015-03-24 00:02:44 UTC
We fixed this recently, outside of this bug report:

[icculus@caridad ~]$ ./bug bug.bmp 
format: 0x16362004
palette: 0x0
BitsPerPixel: 32
BytesPerPixel: 4
Rmask: 0x00ff0000
Gmask: 0x0000ff00
Bmask: 0x000000ff
Amask: 0xff000000

So you should be good to go in 2.0.4.

--ryan.