Sign in to follow this  
password

SDL colorkey question

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
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:
[i]Original post by Jack Sotac[i]
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this