[SDL] Loading alpha-channeled PNGs?

Ryan C. Gordon icculus at icculus.org
Tue Sep 12 22:26:21 PDT 2006


> The image has alpha channel as you can notice in the PSP window, and in 
> the SDL, it doesn't seem to get it. That's what happens when I remove 
> the SDL_SetColorKey instruction. Any idea? =/

Oh, you have to enable the alpha channel explicitly:

    SDL_SetAlpha(mypngsurface, SDL_SRCALPHA, 0xFF);


If all you care about is getting rid of the black border, though, you'll 
want to use color key blitting, since it's much faster: just pick a 
color other than black (like, bright purple) that doesn't appear in the 
image, and convert the border from black to that color in PSP.

--ryan.





More information about the SDL mailing list