• Announcements

Archived

This topic is now archived and is closed to further replies.

Bitmap Translucency

Recommended Posts

Megatron    122
Using DirectDraw, is there any way to make a bitmap translucent?

Share on other sites
Funkymunky    1413
I think with DirectX you''re limited to using D3D and it''s alpha blending capabilities, or implementing a software translucency method with direct draw (thrownback to dx7)

Share on other sites
Guest Anonymous Poster

There is a good article here on how to do 8 bit software
translucency:

http://www.flipcode.com/tutorials/tut_transmaps.shtml

For 16 bit translucency, you can try something like this:

#define MASK565 (1111011111011110b); // assuming a 565 format#define MASK555 (0111101111011110b); // assuming a 555 format// if you are in 565 modefor(each pixel){    color3 = ((color1&MASK565)+(color2&MASK565))>>1;}// if you are in 555 modefor(each pixel){    color3 = ((color1&MASK555)+(color2&MASK555))>>1;}

The above is only good for 50% translucency, and it is slight inaccurate in the LSB. If you want other percentages, you will have to separate each pixel into it''s red, green, and blue components, average them together using math or a lookup table, and recombine each red, green, and blue value into your new color.