Direct Draw/Display question
Is there an easy way to get the current color depth?
I just need to store the color depth in an int(like 8,16,24,32) etc.
I didn''t use DDraw in a long time but I think there was a GetPixelFormat method (call it from a surface, like lpDDS->GetPixelFormat(...).
If I remember well, you''ve got to pass it a pointer to a DDPIXELFORMAT struct (LPDDPIXELFORMAT?). Just check MSDN or the DX sdk help on these .
If I remember well, you''ve got to pass it a pointer to a DDPIXELFORMAT struct (LPDDPIXELFORMAT?). Just check MSDN or the DX sdk help on these .
DDPIXELFORMAT ddpf;
ddpf.dwSize = sizeof(ddpf);
m_pBackSurface->GetPixelFormat(&ddpf);
switch(ddpf.dwRGBBitCount)
{
case 8:
m_dwPixelFormat = BPP8_PALETTE;
break;
case 16:
if(ddpf.dwRBitMask == 0x7C00/* && ddpf.dwGBitMask == 0x03E0 && ddpf.dwBBitMask == 0x001F*/)
{
m_dwPixelFormat = BPP16_555;
}
else /*if(ddpf.dwRBitMask == 0xF800 && ddpf.dwGBitMask == 0x07E0 && ddpf.dwBBitMask == 0x001F)*/
{
m_dwPixelFormat = BPP16_565;
}
break;
case 24:
if(ddpf.dwRBitMask == 0x00FF0000/* && ddpf.dwGBitMask == 0x0000FF00 && ddpf.dwBBitMask == 0x000000FF*/)
{
m_dwPixelFormat = BPP24_RGB;
}
else /*if(ddpf.dwRBitMask == 0x000000FF && ddpf.dwGBitMask == 0x0000FF00 && ddpf.dwBBitMask == 0x00FF0000)*/
{
m_dwPixelFormat = BPP24_BGR;
}
break;
case 32:
if(ddpf.dwRBitMask == 0x00FF0000/* && ddpf.dwGBitMask == 0x0000FF00 && ddpf.dwBBitMask == 0x000000FF*/)
{
m_dwPixelFormat = BPP32_RGB;
}
else /*if(ddpf.dwRBitMask == 0x000000FF && ddpf.dwGBitMask == 0x0000FF00 && ddpf.dwBBitMask == 0x00FF0000)*/
{
m_dwPixelFormat = BPP32_BGR;
}
break;
}
see DX sdk help: Surface Pixel Format
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement