Basic BMP Alpha Blitting

I’m looking to do one of the most simple operations: blitting a 24 bit bitmap
with the color 255,0,255 defined as the SDL_SRCCOLORKEY.

I’ve looked up examples online and I appear to be doing things the same way as
others, except I notice people using 0,255,0 as their background color-- perhaps
there is a sort of inversing going on behind the scenes that I don’t know about?

Anyway the code is quite simple:
SDL_SetAlpha( ball, SDL_SRCCOLORKEY, SDL_MapRGB( screen->format, 255, 0, 255 ) );
and a
SDL_BlitSurface( ball, NULL, screen, &dst );
The screen is created with
SDL_SetVideoMode(800, 600, 24, SDL_HWSURFACE|SDL_DOUBLEBUF);

I have tested two different bmps, one made in PSP and one made in MS Paint. The
image blits but with the background color included.

Here is an example online I found which happens to match what I am trying:
http://www.jlbcomputers.co.uk/cgi-bin/wiki.pl?2

Thanks

Brian wrote:

I’m looking to do one of the most simple operations: blitting a 24 bit bitmap
with the color 255,0,255 defined as the SDL_SRCCOLORKEY.

I’ve looked up examples online and I appear to be doing things the same way as
others, except I notice people using 0,255,0 as their background color-- perhaps
there is a sort of inversing going on behind the scenes that I don’t know about?

Anyway the code is quite simple:
SDL_SetAlpha( ball, SDL_SRCCOLORKEY, SDL_MapRGB( screen->format, 255, 0, 255 ) );
and a

If you want to do colorkeying, you should use SDL_SetColorKey and not
SDL_SetAlpha. SDL_SetAlpha is for semi-transparent surfaces.
See the SDL_SetColorKey manpage for that.

Stephane