[SDL] SDL_SetColorkey on a surface made from a PNG?

James O\'Meara james at nformant.net
Sun Dec 5 07:39:34 PST 2004


I'm trying to get SDL_SetColorkey to work on a surface I made from a .png using
SDL_image.

My code looks like this:

  SDL_Surface *flower;
  flower=IMG_Load("flower.png")
  SDL_SetColorKey(flower, SDL_SRCCOLORKEY, SDL_MapRGB(flower->format, 255, 0, 255));

When  I do this, my sruface is still shown with the magenta visible. If,
however, I change the image to a bmp, it works fine. This code works without
problems:

  SDL_Surface *flower;
  flower=SDL_LoadBMP("flower.bmp")
  SDL_SetColorKey(flower, SDL_SRCCOLORKEY, SDL_MapRGB(flower->format, 255, 0, 255));

What can I do to get it working on my .png?

Thanks for the help.






More information about the SDL mailing list