Sign in to follow this  
The Rug

Creating a mask in SDL

Recommended Posts

The Rug    628
Ive been trying to create a 2D shadow effect in SDL, by creating a black/transparent mask. The shadow would be a copy of the image it was created from, except the pixels would either be black or transparent. The black pixels would be where the source image was opaque, and the transparent pixels where it was transparent. The closest I've come to success with this was writing my own custom blitting routine, but the complexities of pointer arithmetic and such got the better of me, and at best it only worked with 24bpp images. At worst... it looked like clown vomit, there were randomly coloured pixels everywhere. Does anyone know a way to do this? I'd like to steer away from anything that involves me manipulating the pixels if possible! Cheers

Share this post


Link to post
Share on other sites
PnP Bios    494
Stay the heck away from pixel manipulation.
Instead, have the transparent color be like bright green, and do your black stuff like normal. Then just use the set color key function.

I have a tutorial on masking on my site.

And a quick tip for your masking thing, if your art program has a reduce color depth feature, reduce it to 2 colors, then bring it back up. bang, you have your mask.

Share this post


Link to post
Share on other sites
The Rug    628
Yeah I learned my lesson about pixels manipulation...

Looks like I'll have to try it this way. My aim was to generate masks at run time from a surface, but that seems out of the question now :o(

Cheers for the tips.

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