Jump to content
  • Advertisement
Sign in to follow this  
kzar

Is this possible in sdl?

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

I have an image that is black and white. The pure black is the colour key bit that gets turned transparent. Now after I have loaded the image and turned the black transparent is there a way to take a SDL_Color and apply that colour to the grey / white bits of the image making them that colour instead? Also could I use the alpha value of the SDL_Color to set the transparency of the white / grey bits? Thanks, David

Share this post


Link to post
Share on other sites
Advertisement
It should be possible but it will probably require format conversion of the source image to map ARGB format (or BGRA if your on a big-endian processor) and map the greyscale image to the Alpha bit of the 32-bit image. You'll need to probably make another temporary surface the same size as the source image to hold the color of that you want to blend it with (also in 32-bit format) and do an alpha-blend between the two. Then you can color-key blit the second temporary image to the screen. The alpha blend may be slow so you should consider doing the alpha blending to the temporary surfaces before the main game loop.

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!