Archived

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

Megatron

Bitmap Translucency

Recommended Posts

Guest Anonymous Poster   
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 mode
for(each pixel)
{
color3 = ((color1&MASK565)+(color2&MASK565))>>1;
}

// if you are in 555 mode
for(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.







Share this post


Link to post
Share on other sites