Skip to main content
GameDev.net gamedev.net
🔒 Locked

Winapi - Bits Per Pixel

Started by bob_konysh Apr 23, 2004 at 12:23 PM 5 replies 1.2k views
Original Post
bob_konysh
bob_konysh
I was wondering if there was a function in the winapi similar to the GetSystemMetrics(SM_CXSCREEN), but instead of returning the x screen resolution it would return the current system BPP? THX, bob_konysh
CodeMunkie
CodeMunkie
Try this:


DEVMODE dmSettings;
memset(&dmSettings,0,sizeof(dmSettings));

if(!EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&dmSettings))
{
MessageBox(NULL, "Could Not Enumerate Display Settings", "Error", MB_OK);
return;
}


After calling EnumDisplaySettings, dmSettings will contain information on the current display, including bit depth in dmSettings.dmBitsPerPel.


[edited by - CodeMunkie on April 23, 2004 2:00:00 PM]
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.
Agony
Agony
Is GetDeviceCaps() what you''re looking for?


Most of the greatest evils that man has inflicted upon man have come through people feeling quite certain about something which, in fact, was false.

-Bertrand Russell, Unpopular Essays, "Ideas That Have Harmed Mankind"
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas nly, and not for things themselves." - John Locke o
bob_konysh
bob_konysh
I tried GetDeviceCaps(GetDc(GetDesktopWindow), BITSPIXEL), but that was to no avail.

bob_konysh
Agony
Agony
Well, I had forgotten about EnumDisplaySettings(), so that may work just fine (CodeMunkie posted while I was typing). As for GetDeviceCaps(), try using GetDC(NULL). From MSDN Docs for GetDC():
quote:
hWnd
Handle to the window whose device context is to be retrieved. If this value is NULL, GetDC retrieves the device context for the entire screen.



Most of the greatest evils that man has inflicted upon man have come through people feeling quite certain about something which, in fact, was false.

-Bertrand Russell, Unpopular Essays, "Ideas That Have Harmed Mankind"
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas nly, and not for things themselves." - John Locke o
persil
persil
Sorry for getting into, but I''m also searching for this, but I need even more precision than just the bpp.

How could I know the currently used bit masks for red, green and blue???

I tried testing speeds of BitBlt and it is at its best only when I match exactly my window''s masks (of course). But I don''t know how to detect it using only Win32 API...
bob_konysh
bob_konysh
With you advice I tried:

GetDeviceCaps(GetDC(NULL), BITSPIXEL);

That worked and sucessfuly returned the BPP.

bob_konysh

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.