Is this possible in sdl?

Started by
0 comments, last by samuraicrow 18 years, 8 months ago
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
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.

This topic is closed to new replies.

Advertisement