Jump to content
  • Advertisement
Sign in to follow this  
kzar

Silly sdl colour key problem

This topic is 4816 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have been using the SDL_SetColorKey function with no problems, but since I made myself some new graphics it hasn't been working. Both images are bmp, I think the main difference between them is that the old one was 8bit but the new one is 32bit. The background colour is the same bright pink colour for both pictures (I checked that its exactly 255,128,255 in both as well). Heres my code, any ideas?
    SDL_Surface *temp;
    temp = SDL_LoadBMP("stuff.bmp");
    if (temp == NULL)
    {
        printf("Unable to load picture\n");
        return false;
    }
    SDL_SetColorKey(temp, SDL_SRCCOLORKEY | SDL_RLEACCEL, (Uint16) SDL_MapRGB(temp->format, 255, 128, 255));
    stuff_image = SDL_DisplayFormat(temp);
    SDL_FreeSurface(temp);


Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Try removing the cast to Uint16:

SDL_SetColorKey(temp, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB(temp->format, 255, 128, 255));

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!