SDL_LoadBMP vs transparency

Hi list,

I am using SDL_LoadBMP() in one of my little projects to load bitmaps
with some transparent pixels, and it works very well with SDL2.

Recently I tried to use SDL_LoadBMP() in a project that uses SDL v1.2,
but unfortunately the transparency doesn’t work here.

The documentation of SDL_LoadBMP() doesn’t provide any information about
transparency support, so I though maybe I could get some clues here: is
BMP transparency a new feature of SDL2, or have I missed something and
it should work in SDL 1.2 as well?

Of course I know about SDL_Image, and I expect some (most) would say “go
with PNG if you need transparency”. Still, I’d prefer to keep bare SDL
and avoid additional dependencies. In my case, SDL_Image with PNG
doesn’t provide any advantage over ‘raw’ SDL with BMP support (as long
as I can get the transparency working).

cheers,
Mateusz

Hi again,

I compared the SDL_bmp.c files from SDL 1.2 and SDL2, and I see that the
former lacks all the ‘alpha’ bits found in the latter, hence I think I
have my answer… I should have checked this in the first place, sorry
for the noise.

Still, it would be nice to have this aspect documented somewhere -
transparency support in BMP is IMO a highly interesting feature :slight_smile:

cheers,
MateuszOn 09/07/2014 12:41 PM, Mateusz Viste wrote:

Hi list,

I am using SDL_LoadBMP() in one of my little projects to load bitmaps
with some transparent pixels, and it works very well with SDL2.

Recently I tried to use SDL_LoadBMP() in a project that uses SDL v1.2,
but unfortunately the transparency doesn’t work here.

The documentation of SDL_LoadBMP() doesn’t provide any information about
transparency support, so I though maybe I could get some clues here: is
BMP transparency a new feature of SDL2, or have I missed something and
it should work in SDL 1.2 as well?

Of course I know about SDL_Image, and I expect some (most) would say “go
with PNG if you need transparency”. Still, I’d prefer to keep bare SDL
and avoid additional dependencies. In my case, SDL_Image with PNG
doesn’t provide any advantage over ‘raw’ SDL with BMP support (as long
as I can get the transparency working).

cheers,
Mateusz


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Check SDL_SetAlphaMod, Run a Search on SDL API Docs About ‘Alpha’.

Could not need to be in Image Loading and handled in Rendering, specially
me thinking BMP transparency is not in the Format, but in a Color Mask
(say: don’t draw black pixels).