Archived

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

WoX

dx7 colour

Recommended Posts

When I have a 16 bit colour, how do I get a rgb value out of it? This is what I have done so far : DWORD r,g,b; DDSURFACEDESC2 DDSurfDesc POINT pos = {0,0}; ZeroMemory( &DDSurfDesc, sizeof( DDSurfDesc )); DDSurfDesc.dwSize = sizeof( DDSurfDesc ); lpBackBuffer->Lock( NULL, &DDSurfDesc, DDLOCK_WAIT, 0 ); WORD* SurfPtr; SurfPtr = ( WORD* )DDSurfDesc.lpSurface; bgcolor = SurfPtr[ pos.x + (pos.y * DDSurfDesc.lPitch)/2 ]; // how to get the r,g,b out of bgcolor??? lpBackBuffer->Unlock( NULL ); thanks for any help!

Share this post


Link to post
Share on other sites
It depends on what 16bpp mode you''re in, there''s a true 16bpp and there''s a 15bpp

bits:
XRRRRRGGGGGBBBBB 15bpp
RRRRRGGGGGGBBBBB 16bpp

1111100000000000 0xF800
0000011111100000 0x07E0
0000000000011111 0x001F

for true 16bpp
r = (bgcolor & 0xF800) >> 11;
g = (bgcolor & 0x07E0) >> 5;
b = (bgcolor & 0x001F);

Magmai Kai Holmlor
- Not For Rent

Share this post


Link to post
Share on other sites
just a side question, in the 16bpp one, why does the green get the extra bit?

--- krez (krezisback@aol.com)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Because the human eye is better at seeing different shades of green than red and blue (and better at seeing shades of red than shades of blue).

Share this post


Link to post
Share on other sites
thanks Magmai Kai Holmlor, man I think I gotta find some good book on all that bitdepth stuff, it''s so complicated

Share this post


Link to post
Share on other sites