Archived

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

16- and 24-bit color

This topic is 6730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
This would be in DirectDraw. I make a bitmap in 16 or 24 bit color and it won't work. But then I use a palette with 256 colors and it works fine. Thats what I mean.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites