I am confused on how to get 16 or 24 bit color working. I can do everything I need to do fine in 256 color mode, with palettes and all, but why can't I get it to work in 16 bit color? Could someone please give an example or something like that? It would be greatly appreciated. Thanks.
16- and 24-bit color
Started by Gf11speed, Aug 15 1999 09:40 AM
5 replies to this topic
Sponsor:
#2 Members - Reputation: 104
Posted 14 August 1999 - 06:54 AM
Please elaborate more, do you mean 16 bit or 24 bit in ddraw,d3d? What if you mean in directx i cant think of any reason it might not be working unless you are trying to do pixels and any custom drawing functions. That dont take 16/24 bit into concern.
#4 Members - Reputation: 122
Posted 14 August 1999 - 08:59 AM
16 or 24 bit color modes does not have palettes. They use a _packed_ pixel format. That means r,g and b values stored right inside a pixel value. For example 24 bit mode uses 8 bits to represent red, green and blue color values.
FlyFire/CodeX
http://codexorg.webjump.com
#6 Members - Reputation: 122
Posted 15 August 1999 - 09:40 AM
To convert your color to 16 or 24 bit format you gonna do the following:
newPix = ((r & RedMask) << RedFieldPos) +
((g & GreenMask) << GreenFieldPos) +
((b & BlueMask) << BlueFieldPos);
RedMask, RedFieldPos, ... you can get from DirectX (i dunno how, but there was some discussions about it some time ago. For 24 bit color they are:
RedMask =GreenMask = BlueMask = 0xff
redfieldpos = 0;
greenfieldpos = 8;
bluefieldpos = 16;
)
To obtain r,g and b values you gotta lookup them in picture's palette.
newPix = ((r & RedMask) << RedFieldPos) +
((g & GreenMask) << GreenFieldPos) +
((b & BlueMask) << BlueFieldPos);
RedMask, RedFieldPos, ... you can get from DirectX (i dunno how, but there was some discussions about it some time ago. For 24 bit color they are:
RedMask =GreenMask = BlueMask = 0xff
redfieldpos = 0;
greenfieldpos = 8;
bluefieldpos = 16;
)
To obtain r,g and b values you gotta lookup them in picture's palette.






