[SDL] Getting transparency in a blit?

Stefan Viljoen rylan at intekom.co.za
Sun Nov 9 04:30:01 PST 2003


Hi all,

Given this code:

//Start code
SDL_DisplayFormat(buttons[OK_BUT_PRESSED]);

SDL_SetAlpha(buttons[OK_BUT_PRESSED],SDL_SRCCOLORKEY,
		       SDL_MapRGB(buttons[OK_BUT_PRESSED]->format,0,0,0));
		  
SDL_SetColorKey(buttons[OK_BUT_PRESSED],SDL_SRCCOLORKEY,
			  SDL_MapRGB(buttons[OK_BUT_PRESSED]->format,0,0,0));

SDL_BlitSurface(buttons[OK_BUT_PRESSED],NULL,surface,&dstrect);

SDL_UpdateRect(surface,0,0,0,0);

//End code

Can anybody tell me WHY black pixels still do not get masked out? Both 
surfaces are of the same format as far as I can determine. I. E. I want 
"black" (RGB8 0,0,0) pixels NOT to be blitted from buttons[OK_BUT_PRESSED] to 
surface, so I can use non-rectangular images.

I create "surface" like this:

surface = SDL_SetVideoMode(xsize,ysize,16,SDL_SWSURFACE);

and buttons[OK_BUT_PRESSED] is loaded from a .JPEG file, which has its 
transparent areas set to RGB8 0,0,0 using the GIMP.

Any ideas anyone? Pointers to where I can get example code showing how to 
implement totally transparent pixels in a source surface?

Thanks!

-- 
Stefan Viljoen
F/EMS Dispatcher
Potchefstroom Public Safety Dept.
Republic of South Africa
http://home.intekom.com/rylan/

"We want you to be soldiers - deadly as long as you have one leg or one arm 
and you are still alive."
 - R. A. H. in Starship Troopers




More information about the SDL mailing list