Image Transparency

I’m blitting a 24bits RGB bitmap image with glDrawPixel and I want a certain color of the image (let’s say 1.0f,0.0f,1.0f) not to be displayed. Is there anyway I can achieve it???

I’ve tried blending but it seems to work well only for textures and primitives, not for images. Maybe I’m wrong???

Is there anyway to get transparency for a particular color when drawing pictures to the screen???

Thanks to everyone

Mr Pink

there is a tutorial on masking on nehe’s website.

The best way is to create a transparentcy mask using the alpha channel. has a good tutor on it, number 33.

I think you could do it with blending, but would have to have two images, one the origonal image and the other a mask of the areas to be transparent.

Thanks to everyone for the masking technique it is really usefull.

However I did my own function that converts my BMP from RGB to RGBA (not really hard, you add a byte after each RGB bytes while reading the file to load it and set it between 0x00 and 0xFF).

This way I now have the full control over each pixel opacity of my new RGBA bitmap and if I want transparency I easily achieve it with a simple ALPHA TEST.

Thanks a lot to everyone anyway.
I’ve appreciated learning about Masking I’m sure it will be usefull soon!!!

Mr Pink

I’m interested with your technique. Can you please help me how you did it? can you give me any source code?


No Problem for the source,if you want it
just e-mail me @

Put OpenGL in the subject and I’ll send it to you.

Please specify in the e-mail what you want exactly :

Just the function that does the conversion or a simple app that uses it (with the sources of course)?

Mr Pink