Skip to content

Commit c7b28a1

Browse files
committed
[GDITOOLS] Implement ChangeScreenBpp helper
1 parent 4746b1b commit c7b28a1

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

‎modules/rostests/apitests/gditools/gditools.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <winbase.h>
77
#include <wingdi.h>
88
#include <winddi.h>
9+
#include <winuser.h>
910
#include <prntfont.h>
1011

1112
#define NTOS_MODE_USER
@@ -105,6 +106,34 @@ GdiGetHandleUserData(
105106
return pentry->pUser;
106107
}
107108

109+
BOOL
110+
ChangeScreenBpp(
111+
_In_ ULONG cBitsPixel,
112+
_Out_ PULONG pcOldBitsPixel)
113+
{
114+
DEVMODEW dm = { .dmSize = sizeof(dm) };
115+
116+
if (!EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm))
117+
{
118+
printf("EnumDisplaySettingsW failed\n");
119+
return FALSE;
120+
}
121+
122+
*pcOldBitsPixel = dm.dmBitsPerPel;
123+
124+
if (dm.dmBitsPerPel != cBitsPixel)
125+
{
126+
dm.dmBitsPerPel = cBitsPixel;
127+
if (ChangeDisplaySettingsExW(NULL, &dm, NULL, CDS_UPDATEREGISTRY | CDS_GLOBAL, NULL) != DISP_CHANGE_SUCCESSFUL)
128+
{
129+
printf("Failed to change display settings to %lu bpp. Current bpp: %u\n", cBitsPixel, *pcOldBitsPixel);
130+
return FALSE;
131+
}
132+
}
133+
134+
return TRUE;
135+
}
136+
108137
#define FL_INVERT_COLORS 0x01
109138
#define FL_RED_BLUE 0x02
110139

‎modules/rostests/apitests/gditools/gditools.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,7 @@ PVOID
4141
GdiGetHandleUserData(
4242
_In_ HGDIOBJ hobj);
4343

44+
BOOL
45+
ChangeScreenBpp(
46+
_In_ ULONG cBitsPixel,
47+
_Out_ PULONG pcOldBitsPixel);

0 commit comments

Comments
 (0)