mirror of
https://github.com/reactos/reactos.git
synced 2026-05-19 17:19:49 +08:00
[GDITOOLS] Improve ChangeScreenBpp utility function
This commit is contained in:
@@ -106,10 +106,24 @@ GdiGetHandleUserData(
|
||||
return pentry->pUser;
|
||||
}
|
||||
|
||||
VOID
|
||||
PrintAvailableDisplayModes(void)
|
||||
{
|
||||
DEVMODEW dm = { .dmSize = sizeof(dm) };
|
||||
ULONG iMode = 0;
|
||||
|
||||
printf("Available display modes:\n");
|
||||
while (EnumDisplaySettingsW(NULL, iMode++, &dm))
|
||||
{
|
||||
printf(" %ux%u @ %u bpp, freq: %u Hz\n",
|
||||
dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel, dm.dmDisplayFrequency);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
ChangeScreenBpp(
|
||||
_In_ ULONG cBitsPixel,
|
||||
_Out_ PULONG pcOldBitsPixel)
|
||||
_Out_ PDEVMODEW pdmOld)
|
||||
{
|
||||
DEVMODEW dm = { .dmSize = sizeof(dm) };
|
||||
|
||||
@@ -119,18 +133,26 @@ ChangeScreenBpp(
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*pcOldBitsPixel = dm.dmBitsPerPel;
|
||||
printf("ChangeScreenBpp(%lu): Old display settings: %ux%u @ %u bpp\n",
|
||||
cBitsPixel, dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel);
|
||||
|
||||
*pdmOld = dm;
|
||||
|
||||
if (dm.dmBitsPerPel != cBitsPixel)
|
||||
{
|
||||
dm.dmBitsPerPel = cBitsPixel;
|
||||
if (ChangeDisplaySettingsExW(NULL, &dm, NULL, CDS_UPDATEREGISTRY | CDS_GLOBAL, NULL) != DISP_CHANGE_SUCCESSFUL)
|
||||
if (ChangeDisplaySettingsW(&dm, 0) != DISP_CHANGE_SUCCESSFUL)
|
||||
{
|
||||
printf("Failed to change display settings to %lu bpp. Current bpp: %u\n", cBitsPixel, *pcOldBitsPixel);
|
||||
printf("Failed to change display settings.\n");
|
||||
PrintAvailableDisplayModes();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
EnumDisplaySettingsW(NULL, ENUM_CURRENT_SETTINGS, &dm);
|
||||
printf("ChangeScreenBpp(%lu): New display settings: %ux%u @ %u bpp\n",
|
||||
cBitsPixel, dm.dmPelsWidth, dm.dmPelsHeight, dm.dmBitsPerPel);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,4 +44,4 @@ GdiGetHandleUserData(
|
||||
BOOL
|
||||
ChangeScreenBpp(
|
||||
_In_ ULONG cBitsPixel,
|
||||
_Out_ PULONG pcOldBitsPixel);
|
||||
_Out_ PDEVMODEW pdmOld);
|
||||
|
||||
@@ -355,8 +355,8 @@ START_TEST(NtGdiBitBlt)
|
||||
{
|
||||
ok(GdiToolsInit(), "GdiToolsInit failed\n");
|
||||
|
||||
ULONG cBitsPixel;
|
||||
ChangeScreenBpp(32, &cBitsPixel);
|
||||
DEVMODEW dmOld;
|
||||
ChangeScreenBpp(32, &dmOld);
|
||||
|
||||
ghdcDDB1 = CreateCompatibleDC(NULL);
|
||||
SelectObject(ghdcDDB1, ghbmp1);
|
||||
@@ -371,5 +371,5 @@ START_TEST(NtGdiBitBlt)
|
||||
gbUseCLR_INVALID = FALSE;
|
||||
Test_NtGdiBitBlt_1BPP();
|
||||
|
||||
ChangeScreenBpp(cBitsPixel, &cBitsPixel);
|
||||
ChangeDisplaySettingsW(&dmOld, 0);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#define DIBINDEX(n) MAKELONG((n),0x10FF)
|
||||
|
||||
static HDC ghdcDDB1, ghdcDDB32;
|
||||
static HDC ghdcDDB1;
|
||||
|
||||
static
|
||||
COLORREF
|
||||
@@ -186,18 +186,16 @@ START_TEST(NtGdiLineTo)
|
||||
{
|
||||
ok(GdiToolsInit(), "GdiToolsInit failed\n");
|
||||
|
||||
ULONG cBitsPixel;
|
||||
ChangeScreenBpp(32, &cBitsPixel);
|
||||
DEVMODEW dmOld;
|
||||
ChangeScreenBpp(32, &dmOld);
|
||||
|
||||
ghdcDDB1 = CreateCompatibleDC(NULL);
|
||||
ok(SelectObject(ghdcDDB1, ghbmp1) != NULL, "SelectObject failed\n");
|
||||
ghdcDDB32 = CreateCompatibleDC(NULL);
|
||||
ok(SelectObject(ghdcDDB32, ghbmp32) != NULL, "SelectObject failed\n");
|
||||
|
||||
Test_NtGdiLineTo_1BPP_BW(ghdcDDB1);
|
||||
Test_NtGdiLineTo_1BPP_BW(ghdcDIB1);
|
||||
Test_NtGdiLineTo_1BPP_BW(ghdcDIB1_InvCol);
|
||||
Test_NtGdiLineTo_1BPP_RB();
|
||||
|
||||
ChangeScreenBpp(cBitsPixel, &cBitsPixel);
|
||||
ChangeDisplaySettingsW(&dmOld, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user