• Advertisement
Sign in to follow this  

SDL colorkey question

This topic is 4291 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

It's possible to remove, for example every white pixel on a picture by using this line. SDL_SetColorKey(image, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image->format, 0xff, 0xff, 0xff)); Right now I need a similar function that removes everything except the color you want. In other words, if I write 0xff, 0xff, 0xff, I want everything to be removed except the white pixels. Is that possible?

Share this post


Link to post
Share on other sites
Advertisement
Why don't you just use SDL_Image, and use .pngs for transparency? You can use The Gimp to save png's like that. Atleast, that is what I do (except I use Photoshop CS2).

I hope that helps,
Chad

Share this post


Link to post
Share on other sites
One thing you can do is go through all pixels in the image and set all the colors you don't want to the colorkey. This method is slow if done every frame.

If you're working with 32-bits surfaces and per-pixel blits, set the alpha of all pixels you don't want to blit to 0.

In conclusion, you will have to write the magic function that does not blit the unwanted colors.

Good Luck.

Share this post


Link to post
Share on other sites
Quote:
Original post by Chad Smith
Why don't you just use SDL_Image, and use .pngs for transparency? You can use The Gimp to save png's like that. Atleast, that is what I do (except I use Photoshop CS2).

I hope that helps,
Chad


I am using SDL_image and png files aswell. There are about 5-6 different colors that most be removed from the image, transparency won't work and never worked before when I only wanted to remove a background.

Quote:
Original post by Jack Sotac
One thing you can do is go through all pixels in the image and set all the colors you don't want to the colorkey. This method is slow if done every frame.

If you're working with 32-bits surfaces and per-pixel blits, set the alpha of all pixels you don't want to blit to 0.

In conclusion, you will have to write the magic function that does not blit the unwanted colors.

Good Luck.


I was thinking of doing something similar, like picking out all colors from the image in photoshop and make many colorkeys instead of one, for the same image and remove all colors that isn't supposed to be there. I guess I have to use that now.

Share this post


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

  • Advertisement