- Add new spectrum bitmaps for 4bpp, 8bpp and 16-32bpp. The 8bpp one can probably be done better, but at least it's suitable ;-)

As we use StretchBlt in the code, the bitmaps are very small, so they are stretched to the full size at runtime.
- Change the current spectrum bitmap, when the user selects another color depth
- Enable support for 4bpp color depth
- Fix a bug in "monslctl.c", which broke building under MSVC

svn path=/trunk/; revision=30475
This commit is contained in:
Colin Finck 2007-11-15 21:38:36 +00:00
parent 6fa082e5c1
commit b5e7df42cc
9 changed files with 75 additions and 34 deletions

View file

@ -48,7 +48,8 @@ INT AllocAndLoadString(LPTSTR *lpTarget,
ULONG __cdecl DbgPrint(PCCH Format,...);
#define MAX_DESK_PAGES 32
#define MAX_DESK_PAGES 32
#define NUM_SPECTRUM_BITMAPS 3
/* As slider control can't contain user data, we have to keep an
* array of RESOLUTION_INFO to have our own associated data.

View file

@ -15,6 +15,9 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDC_DESK_ICON ICON "resources/applet.ico"
IDC_DESK_ICON2 ICON "resources/applet.ico"
IDC_MONITOR BITMAP "resources/monitor.bmp"
IDB_SPECTRUM BITMAP "resources/spectrum.bmp"
IDB_SPECTRUM_4 BITMAP "resources/spectrum_4.bmp"
IDB_SPECTRUM_8 BITMAP "resources/spectrum_8.bmp"
IDB_SPECTRUM_16 BITMAP "resources/spectrum_16.bmp"
#include "rsrc.rc"

View file

@ -895,7 +895,7 @@ MonSelPaint(IN OUT PMONITORSELWND infoPtr,
/* Paint the dragging monitor last */
if (infoPtr->IsDraggingMonitor &&
(DWORD)infoPtr->DraggingMonitor >= 0)
infoPtr->DraggingMonitor >= 0)
{
MonSelRectToScreen(infoPtr,
&infoPtr->rcDragging,

View file

@ -66,7 +66,10 @@
#define IDC_SETTINGS_ADVANCED 205
#define IDC_SETTINGS_MONSEL 206
#define IDC_SETTINGS_SPECTRUM 207
#define IDB_SPECTRUM 208
#define IDB_SPECTRUM_4 208
#define IDB_SPECTRUM_8 209
#define IDB_SPECTRUM_16 210
#define IDR_PREVIEW_MENU 2100
#define ID_MENU_NORMAL 2101

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

View file

@ -15,9 +15,9 @@ typedef struct _GLOBAL_DATA
{
PDISPLAY_DEVICE_ENTRY DisplayDeviceList;
PDISPLAY_DEVICE_ENTRY CurrentDisplayDevice;
HBITMAP hBitmap;
int cxSource;
int cySource;
HBITMAP hSpectrumBitmaps[NUM_SPECTRUM_BITMAPS];
int cxSource[NUM_SPECTRUM_BITMAPS];
int cySource[NUM_SPECTRUM_BITMAPS];
} GLOBAL_DATA, *PGLOBAL_DATA;
@ -80,7 +80,8 @@ GetPossibleSettings(IN LPCTSTR DeviceName, OUT DWORD* pSettingsCount, OUT PSETTI
while (EnumDisplaySettingsEx(DeviceName, iMode, &devmode, dwFlags))
{
if ((devmode.dmBitsPerPel==8 ||
if ((devmode.dmBitsPerPel==4 ||
devmode.dmBitsPerPel==8 ||
devmode.dmBitsPerPel==16 ||
devmode.dmBitsPerPel==24 ||
devmode.dmBitsPerPel==32) &&
@ -285,6 +286,7 @@ OnInitDialog(IN HWND hwndDlg)
BITMAP bitmap;
DWORD Result = 0;
DWORD iDevNum = 0;
INT i;
DISPLAY_DEVICE displayDevice;
PGLOBAL_DATA pGlobalData;
@ -362,15 +364,45 @@ OnInitDialog(IN HWND hwndDlg)
}
}
/* init the color spectrum*/
pGlobalData->hBitmap = LoadImageW(hApplet, MAKEINTRESOURCEW(IDB_SPECTRUM), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
if (pGlobalData->hBitmap != NULL)
{
GetObjectW(pGlobalData->hBitmap, sizeof(BITMAP), &bitmap);
/* Initialize the color spectrum bitmaps */
for(i = 0; i < NUM_SPECTRUM_BITMAPS; i++)
{
pGlobalData->hSpectrumBitmaps[i] = LoadImageW(hApplet, MAKEINTRESOURCEW(IDB_SPECTRUM_4 + i), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
pGlobalData->cxSource = bitmap.bmWidth;
pGlobalData->cySource = bitmap.bmHeight;
}
if (pGlobalData->hSpectrumBitmaps[i] != NULL)
{
GetObjectW(pGlobalData->hSpectrumBitmaps[i], sizeof(BITMAP), &bitmap);
pGlobalData->cxSource[i] = bitmap.bmWidth;
pGlobalData->cySource[i] = bitmap.bmHeight;
}
}
}
/* Get the ID for GLOBAL_DATA::hSpectrumBitmaps */
static VOID
ShowColorSpectrum(IN HDC hDC, IN LPRECT client, IN DWORD BitsPerPel, IN PGLOBAL_DATA pGlobalData)
{
HDC hdcMem;
hdcMem = CreateCompatibleDC(hDC);
if (hdcMem)
{
INT iBitmap;
switch(BitsPerPel)
{
case 4: iBitmap = 0; break;
case 8: iBitmap = 1; break;
default: iBitmap = 2;
}
SelectObject(hdcMem, pGlobalData->hSpectrumBitmaps[iBitmap]);
StretchBlt(hDC, client->left, client->top, client->right - client->left,
client->bottom - client->top, hdcMem, 0, 0,
pGlobalData->cxSource[iBitmap], pGlobalData->cySource[iBitmap], SRCCOPY);
DeleteDC(hdcMem);
}
}
static VOID
@ -383,12 +415,19 @@ OnBPPChanged(IN HWND hwndDlg, IN PGLOBAL_DATA pGlobalData)
PSETTINGS_ENTRY Current;
DWORD dmNewBitsPerPel;
DWORD index;
TCHAR Buffer[64];
HDC hSpectrumDC;
HWND hSpectrumControl;
RECT client;
SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, WM_GETTEXT, (WPARAM)(sizeof(Buffer) / sizeof(TCHAR)), (LPARAM)Buffer);
index = (DWORD) SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)Buffer);
index = (DWORD) SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, CB_GETCURSEL, 0, 0);
dmNewBitsPerPel = (DWORD) SendDlgItemMessage(hwndDlg, IDC_SETTINGS_BPP, CB_GETITEMDATA, index, 0);
/* Show a new spectrum bitmap */
hSpectrumControl = GetDlgItem(hwndDlg, IDC_SETTINGS_SPECTRUM);
hSpectrumDC = GetDC(hSpectrumControl);
GetClientRect(hSpectrumControl, &client);
ShowColorSpectrum(hSpectrumDC, &client, dmNewBitsPerPel, pGlobalData);
/* find if new parameters are valid */
Current = pGlobalData->CurrentDisplayDevice->CurrentSettings;
if (dmNewBitsPerPel == Current->dmBitsPerPel)
@ -585,20 +624,10 @@ SettingsPageProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lPar
{
LPDRAWITEMSTRUCT lpDrawItem;
lpDrawItem = (LPDRAWITEMSTRUCT) lParam;
if(lpDrawItem->CtlID == IDC_SETTINGS_SPECTRUM)
{
HDC hdcMem;
hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
if (hdcMem != NULL)
{
SelectObject(hdcMem, pGlobalData->hBitmap);
StretchBlt(lpDrawItem->hDC, lpDrawItem->rcItem.left, lpDrawItem->rcItem.top,
lpDrawItem->rcItem.right - lpDrawItem->rcItem.left,
lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top,
hdcMem, 0, 0, pGlobalData->cxSource, pGlobalData->cySource, SRCCOPY);
DeleteDC(hdcMem);
}
}
ShowColorSpectrum(lpDrawItem->hDC, &lpDrawItem->rcItem, pGlobalData->CurrentDisplayDevice->CurrentSettings->dmBitsPerPel, pGlobalData);
break;
}
case WM_COMMAND:
@ -784,6 +813,8 @@ SettingsPageProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lPar
case WM_DESTROY:
{
INT i;
PDISPLAY_DEVICE_ENTRY Current = pGlobalData->DisplayDeviceList;
while (Current != NULL)
{
@ -801,8 +832,11 @@ SettingsPageProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lPar
HeapFree(GetProcessHeap(), 0, pGlobalData);
if (pGlobalData->hBitmap)
DeleteObject(pGlobalData->hBitmap);
for(i = 0; i < NUM_SPECTRUM_BITMAPS; i++)
{
if(pGlobalData->hSpectrumBitmaps[i])
DeleteObject(pGlobalData->hSpectrumBitmaps[i]);
}
}
}
return FALSE;