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

SpazBoy the Mitey

Can I read the BPP of a display in WIN32?

Recommended Posts

I am writing a resolution changing thing that uses WIN32 API calls to change the res, and then uses its destructor to change back again. Is there an API function I can call that gives me the display''s BPP? Also I am currently using GetSystemMetrics to determine the width/height of the screen. Is that right? god I hate being a newbie again

Share this post

Link to post
Share on other sites
I think the following code is what you are looking for...

int bpp;
HDC screenDC;

// get the current screen resolution

int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);

// get the screen DC for our current display and it''s BPP

screenDC = GetDC(NULL);
bpp = GetDeviceCaps(screenDC,BITSPIXEL);

The value returned in bpp is the value you are looking for, e.g. 8, 16, 24 or 32.

Share this post

Link to post
Share on other sites