SDL colorkey question

Started by
2 comments, last by password 17 years, 9 months ago
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?
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
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.
0xa0000000
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.

This topic is closed to new replies.

Advertisement