[SDL] Alpha/Transparency from BMP files

Phoenix Kokido kokido at postmark.net
Mon Jan 24 15:01:59 PST 2000


Do all the ugly purple pixels show, colorkeys are very exact and when
images are antialiased if one channel is even one off it will be
blitted.

Phoenix Kokido
members.xoom.com/kokido
kokido at postmark.net

Scott Russell wrote:

> After using SDL_LoadBMP to load a small bitmap, I want to blit it to a
> hardware surface with transparent sections.
> 
> * I create the destination surface with
> Screen = SDL_SetVideoMode(XRes, YRes, Bpp,
> SDL_HWSURFACE|SDL_HWPALETTE|SDL_DOUBLEBUF);
> 
> * Load the bitmap
> image = SDL_LoadBMP(imagename);
> 
> * Set ColorKey and Alpha information
> SDL_SetColorKey(image, 0, SDL_MapRGB(Screen->format, 0xFF, 0x00, 0xFF));
> SDL_SetAlpha(image, SDL_SRCALPHA, 255); //tried with and without this line
> 
> * Then blit it and flip it.
> SDL_BlitSurface(image, NULL, Screen, &dest);
> SDL_Flip(Screen);
> 
> The ugly purple pixels show, when I think they shouldn't.  I'm using NT
4.0,
> Visual Studio 6.
> 
> Am I doing something wrong?
> Does LoadBMP set up a surface that doesn't support transparency or Alpha?
> Do I need to do something to my Screen before blitting?
> Is SDL broke?  I hope not - I really like it so far.
> 
> Also, can someone lay out the procedure or point to a reference for using
> ImageLib with SDL on the NT and Linux platforms?
> 
>   - Scott Russell
> 



More information about the SDL mailing list