Archived

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

Yarharhar

Direct Draw/Display question

Recommended Posts

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 .

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

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

Share this post


Link to post
Share on other sites