The FlagsToBitDepth function is used by the CreateDevice function to convert bit-depth flags to an actual bit count. It selects the smallest bit count in the mask if more than one flag is present. For more information, see Creating the Direct3D Device.
static DWORD
FlagsToBitDepth(DWORD dwFlags)
{
if (dwFlags & DDBD_1)
return 1;
else if (dwFlags & DDBD_2)
return 2;
else if (dwFlags & DDBD_4)
return 4;
else if (dwFlags & DDBD_8)
return 8;
else if (dwFlags & DDBD_16)
return 16;
else if (dwFlags & DDBD_24)
return 24;
else if (dwFlags & DDBD_32)
return 32;
else
return 0;
}