Archived

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

dx7 colour

This topic is 5885 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

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
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