mirror of
https://github.com/reactos/reactos.git
synced 2024-10-08 10:24:06 +00:00
[SYSDM]
- use alpha blend when drawing the ros logo on the general page - misc code cleanup CORE-8071 svn path=/trunk/; revision=62856
This commit is contained in:
parent
a794e3f2d0
commit
5c1e3b6489
|
@ -22,12 +22,14 @@ typedef struct _IMGINFO
|
||||||
HBITMAP hBitmap;
|
HBITMAP hBitmap;
|
||||||
INT cxSource;
|
INT cxSource;
|
||||||
INT cySource;
|
INT cySource;
|
||||||
|
INT iPLanes;
|
||||||
|
INT iBits;
|
||||||
} IMGINFO, *PIMGINFO;
|
} IMGINFO, *PIMGINFO;
|
||||||
|
|
||||||
PIMGINFO pImgInfo = NULL;
|
PIMGINFO pImgInfo = NULL;
|
||||||
|
BLENDFUNCTION BlendFunc = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
|
||||||
|
|
||||||
void
|
VOID ShowLastWin32Error(HWND hWndOwner)
|
||||||
ShowLastWin32Error(HWND hWndOwner)
|
|
||||||
{
|
{
|
||||||
LPTSTR lpMsg;
|
LPTSTR lpMsg;
|
||||||
DWORD LastError;
|
DWORD LastError;
|
||||||
|
@ -53,39 +55,86 @@ ShowLastWin32Error(HWND hWndOwner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
static VOID InitLogo(HWND hwndDlg)
|
||||||
InitImageInfo(PIMGINFO ImgInfo)
|
|
||||||
{
|
{
|
||||||
BITMAP bitmap;
|
BITMAP logoBitmap;
|
||||||
|
BITMAP maskBitmap;
|
||||||
|
BITMAPINFO bmpi;
|
||||||
|
HDC hDC = GetDC(hwndDlg);
|
||||||
|
HDC hDCLogo = CreateCompatibleDC(NULL);
|
||||||
|
HDC hDCMask = CreateCompatibleDC(NULL);
|
||||||
|
HBITMAP hMask, hLogo, hAlphaLogo = NULL;
|
||||||
|
COLORREF *pBits;
|
||||||
|
INT line, column;
|
||||||
|
|
||||||
ZeroMemory(ImgInfo, sizeof(*ImgInfo));
|
ZeroMemory(pImgInfo, sizeof(*pImgInfo));
|
||||||
|
ZeroMemory(&bmpi, sizeof(bmpi));
|
||||||
|
|
||||||
ImgInfo->hBitmap = LoadImage(hApplet,
|
hLogo = (HBITMAP)LoadImage(hApplet, MAKEINTRESOURCE(IDB_ROSBMP), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
||||||
MAKEINTRESOURCE(IDB_ROSBMP),
|
hMask = (HBITMAP)LoadImage(hApplet, MAKEINTRESOURCE(IDB_ROSMASK), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);
|
||||||
IMAGE_BITMAP,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
LR_DEFAULTCOLOR);
|
|
||||||
|
|
||||||
if (ImgInfo->hBitmap != NULL)
|
if (hLogo != NULL && hMask != NULL)
|
||||||
{
|
{
|
||||||
GetObject(ImgInfo->hBitmap, sizeof(BITMAP), &bitmap);
|
GetObject(hLogo, sizeof(BITMAP), &logoBitmap);
|
||||||
|
GetObject(hMask, sizeof(BITMAP), &maskBitmap);
|
||||||
|
|
||||||
ImgInfo->cxSource = bitmap.bmWidth;
|
if(logoBitmap.bmHeight != maskBitmap.bmHeight || logoBitmap.bmWidth != maskBitmap.bmWidth)
|
||||||
ImgInfo->cySource = bitmap.bmHeight;
|
return;
|
||||||
|
|
||||||
|
pImgInfo->cxSource = logoBitmap.bmWidth;
|
||||||
|
pImgInfo->cySource = logoBitmap.bmHeight;
|
||||||
|
|
||||||
|
bmpi.bmiHeader.biSize = sizeof(BITMAPINFO);
|
||||||
|
bmpi.bmiHeader.biWidth = logoBitmap.bmWidth;
|
||||||
|
bmpi.bmiHeader.biHeight = logoBitmap.bmHeight;
|
||||||
|
bmpi.bmiHeader.biPlanes = 1;
|
||||||
|
bmpi.bmiHeader.biBitCount = 32;
|
||||||
|
bmpi.bmiHeader.biCompression = BI_RGB;
|
||||||
|
bmpi.bmiHeader.biSizeImage = 4 * logoBitmap.bmWidth * logoBitmap.bmHeight;
|
||||||
|
|
||||||
|
hAlphaLogo = CreateDIBSection(hDC, &bmpi, DIB_RGB_COLORS, (PVOID*)&pBits, 0, 0);
|
||||||
|
|
||||||
|
if(!hAlphaLogo)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SelectObject(hDCLogo, hLogo);
|
||||||
|
SelectObject(hDCMask, hMask);
|
||||||
|
|
||||||
|
for(line = logoBitmap.bmHeight - 1; line >= 0; line--)
|
||||||
|
{
|
||||||
|
for(column = 0; column < logoBitmap.bmWidth; column++)
|
||||||
|
{
|
||||||
|
COLORREF alpha = GetPixel(hDCMask, column, line) & 0xFF;
|
||||||
|
COLORREF Color = GetPixel(hDCLogo, column, line);
|
||||||
|
DWORD r, g, b;
|
||||||
|
|
||||||
|
r = GetRValue(Color) * alpha / 255;
|
||||||
|
g = GetGValue(Color) * alpha / 255;
|
||||||
|
b = GetBValue(Color) * alpha / 255;
|
||||||
|
|
||||||
|
*pBits++ = b | g << 8 | r << 16 | alpha << 24;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pImgInfo->hBitmap = hAlphaLogo;
|
||||||
|
pImgInfo->cxSource = logoBitmap.bmWidth;
|
||||||
|
pImgInfo->cySource = logoBitmap.bmHeight;
|
||||||
|
pImgInfo->iBits = logoBitmap.bmBitsPixel;
|
||||||
|
pImgInfo->iPLanes = logoBitmap.bmPlanes;
|
||||||
|
|
||||||
|
DeleteObject(hLogo);
|
||||||
|
DeleteObject(hMask);
|
||||||
|
DeleteDC(hDCLogo);
|
||||||
|
DeleteDC(hDCMask);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK RosImageProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
LRESULT CALLBACK RosImageProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
static UINT timerid = 0, top = 0, offset;
|
static UINT timerid = 0, top = 0, offset;
|
||||||
static HBITMAP hBitmap2;
|
static HBITMAP hCreditsBitmap;
|
||||||
RECT r;
|
|
||||||
NONCLIENTMETRICS ncm;
|
|
||||||
HFONT hfont;
|
|
||||||
BITMAP bitmap;
|
|
||||||
HDC dc, sdc;
|
|
||||||
TCHAR devtext[2048];
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_LBUTTONDBLCLK:
|
case WM_LBUTTONDBLCLK:
|
||||||
|
@ -93,51 +142,65 @@ LRESULT CALLBACK RosImageProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||||
{
|
{
|
||||||
if (timerid == 0)
|
if (timerid == 0)
|
||||||
{
|
{
|
||||||
top = 0; // Set top
|
HDC hCreditsDC, hLogoDC;
|
||||||
|
HFONT hFont;
|
||||||
|
NONCLIENTMETRICS ncm;
|
||||||
|
RECT rcCredits;
|
||||||
|
TCHAR szCredits[2048];
|
||||||
|
INT iDevsHeight;
|
||||||
|
|
||||||
// Build new bitmap
|
top = 0;
|
||||||
GetObject(pImgInfo->hBitmap, sizeof(BITMAP), &bitmap);
|
offset = 0;
|
||||||
dc = CreateCompatibleDC(GetDC(NULL));
|
hCreditsDC = CreateCompatibleDC(GetDC(NULL));
|
||||||
if (dc == NULL)
|
hLogoDC = CreateCompatibleDC(hCreditsDC);
|
||||||
{
|
|
||||||
|
if (hCreditsDC == NULL || hLogoDC == NULL)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
sdc = CreateCompatibleDC(dc);
|
SetRect(&rcCredits, 0, 0, 0, 0);
|
||||||
if (sdc == NULL)
|
|
||||||
{
|
|
||||||
DeleteDC(dc);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
ncm.cbSize = sizeof(NONCLIENTMETRICS);
|
||||||
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0);
|
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0);
|
||||||
|
|
||||||
hfont = CreateFontIndirect(&ncm.lfMessageFont);
|
hFont = CreateFontIndirect(&ncm.lfMessageFont);
|
||||||
SelectObject(dc, hfont);
|
SelectObject(hCreditsDC, hFont);
|
||||||
SetRect(&r, 0, 0, 0, 0);
|
|
||||||
LoadString(hApplet, IDS_DEVS, devtext, sizeof(devtext) / sizeof(TCHAR));
|
|
||||||
DrawText(dc, devtext, -1, &r, DT_CALCRECT);
|
|
||||||
hBitmap2 = CreateBitmap(pImgInfo->cxSource, (2 * pImgInfo->cySource) + (r.bottom + 1 - r.top), bitmap.bmPlanes, bitmap.bmBitsPixel, NULL);
|
|
||||||
SelectObject(sdc, pImgInfo->hBitmap);
|
|
||||||
SelectObject(dc, hBitmap2);
|
|
||||||
offset = 0;
|
|
||||||
BitBlt(dc, 0, offset, bitmap.bmWidth, bitmap.bmHeight, sdc, 0, 0, SRCCOPY);
|
|
||||||
offset += bitmap.bmHeight;
|
|
||||||
|
|
||||||
SetRect(&r, 0, offset, bitmap.bmWidth, offset + (r.bottom - r.top) + 1);
|
LoadString(hApplet, IDS_DEVS, szCredits, sizeof(szCredits) / sizeof(TCHAR));
|
||||||
FillRect(dc, &r, GetSysColorBrush(COLOR_3DFACE));
|
DrawText(hCreditsDC, szCredits, -1, &rcCredits, DT_CALCRECT);
|
||||||
SetBkMode(dc, TRANSPARENT);
|
|
||||||
OffsetRect(&r, 1, 1);
|
|
||||||
SetTextColor(dc, GetSysColor(COLOR_BTNSHADOW));
|
|
||||||
DrawText(dc, devtext, -1, &r, DT_CENTER);
|
|
||||||
OffsetRect(&r, -1, -1);
|
|
||||||
SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
|
|
||||||
DrawText(dc, devtext, -1, &r, DT_CENTER);
|
|
||||||
offset += r.bottom - r.top;
|
|
||||||
|
|
||||||
BitBlt(dc, 0, offset, bitmap.bmWidth, bitmap.bmHeight, sdc, 0, 0, SRCCOPY);
|
iDevsHeight = rcCredits.bottom - rcCredits.top;
|
||||||
offset += bitmap.bmHeight;
|
|
||||||
DeleteDC(sdc);
|
hCreditsBitmap = CreateBitmap(pImgInfo->cxSource, (2 * pImgInfo->cySource) + iDevsHeight + 1, pImgInfo->iPLanes, pImgInfo->iBits, NULL);
|
||||||
DeleteDC(dc);
|
|
||||||
|
if(!hCreditsBitmap)
|
||||||
|
break;
|
||||||
|
|
||||||
|
SelectObject(hLogoDC, pImgInfo->hBitmap);
|
||||||
|
SelectObject(hCreditsDC, hCreditsBitmap);
|
||||||
|
|
||||||
|
offset += pImgInfo->cySource;
|
||||||
|
|
||||||
|
SetRect(&rcCredits, 0, 0, pImgInfo->cxSource, (2 * pImgInfo->cySource) + iDevsHeight + 1);
|
||||||
|
FillRect(hCreditsDC, &rcCredits, GetSysColorBrush(COLOR_3DFACE));
|
||||||
|
|
||||||
|
SetRect(&rcCredits, 0, offset, pImgInfo->cxSource, offset + iDevsHeight + 1);
|
||||||
|
SetBkMode(hCreditsDC, TRANSPARENT);
|
||||||
|
|
||||||
|
OffsetRect(&rcCredits, 1, 1);
|
||||||
|
SetTextColor(hCreditsDC, GetSysColor(COLOR_BTNSHADOW));
|
||||||
|
DrawText(hCreditsDC, szCredits, -1, &rcCredits, DT_CENTER);
|
||||||
|
|
||||||
|
OffsetRect(&rcCredits, -1, -1);
|
||||||
|
SetTextColor(hCreditsDC, GetSysColor(COLOR_WINDOWTEXT));
|
||||||
|
DrawText(hCreditsDC, szCredits, -1, &rcCredits, DT_CENTER);
|
||||||
|
|
||||||
|
offset += iDevsHeight;
|
||||||
|
|
||||||
|
AlphaBlend(hCreditsDC, 0, 0, pImgInfo->cxSource, pImgInfo->cySource, hLogoDC, 0, 0, pImgInfo->cxSource, pImgInfo->cySource, BlendFunc);
|
||||||
|
AlphaBlend(hCreditsDC, 0, offset, pImgInfo->cxSource, pImgInfo->cySource, hLogoDC, 0, 0, pImgInfo->cxSource, pImgInfo->cySource, BlendFunc);
|
||||||
|
|
||||||
|
DeleteDC(hLogoDC);
|
||||||
|
DeleteDC(hCreditsDC);
|
||||||
|
|
||||||
timerid = SetTimer(hwnd, 1, ANIM_TIME, NULL);
|
timerid = SetTimer(hwnd, 1, ANIM_TIME, NULL);
|
||||||
}
|
}
|
||||||
|
@ -146,22 +209,40 @@ LRESULT CALLBACK RosImageProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
if (timerid)
|
if (timerid)
|
||||||
{
|
{
|
||||||
|
RECT rcCredits;
|
||||||
|
HDC hDC = GetDC(hwnd);
|
||||||
|
|
||||||
|
GetClientRect(hwnd, &rcCredits);
|
||||||
|
SetRect(&rcCredits, 0, 0, rcCredits.right, pImgInfo->cySource);
|
||||||
|
FillRect(hDC, &rcCredits, GetSysColorBrush(COLOR_3DFACE));
|
||||||
|
|
||||||
KillTimer(hwnd, timerid);
|
KillTimer(hwnd, timerid);
|
||||||
|
DeleteObject(hCreditsBitmap);
|
||||||
|
InvalidateRect(hwnd, NULL, FALSE);
|
||||||
|
|
||||||
top = 0;
|
top = 0;
|
||||||
timerid = 0;
|
timerid = 0;
|
||||||
DeleteObject(hBitmap2);
|
|
||||||
InvalidateRect(hwnd, NULL, FALSE);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WM_TIMER:
|
case WM_TIMER:
|
||||||
top += ANIM_STEP;
|
top += ANIM_STEP;
|
||||||
if (top > offset - pImgInfo->cySource)
|
|
||||||
|
if (top > offset)
|
||||||
{
|
{
|
||||||
|
RECT rcCredits;
|
||||||
|
HDC hDC = GetDC(hwnd);
|
||||||
|
|
||||||
|
GetClientRect(hwnd, &rcCredits);
|
||||||
|
SetRect(&rcCredits, 0, 0, rcCredits.right, pImgInfo->cySource);
|
||||||
|
FillRect(hDC, &rcCredits, GetSysColorBrush(COLOR_3DFACE));
|
||||||
|
|
||||||
KillTimer(hwnd, timerid);
|
KillTimer(hwnd, timerid);
|
||||||
|
DeleteObject(hCreditsBitmap);
|
||||||
|
|
||||||
top = 0;
|
top = 0;
|
||||||
timerid = 0;
|
timerid = 0;
|
||||||
DeleteObject(hBitmap2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidateRect(hwnd, NULL, FALSE);
|
InvalidateRect(hwnd, NULL, FALSE);
|
||||||
break;
|
break;
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
|
@ -169,15 +250,10 @@ LRESULT CALLBACK RosImageProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||||
PAINTSTRUCT PS;
|
PAINTSTRUCT PS;
|
||||||
HDC hdcMem, hdc;
|
HDC hdcMem, hdc;
|
||||||
LONG left;
|
LONG left;
|
||||||
if (wParam != 0)
|
|
||||||
{
|
hdc = wParam != 0 ? (HDC)wParam : BeginPaint(hwnd, &PS);
|
||||||
hdc = (HDC)wParam;
|
|
||||||
}
|
GetClientRect(hwnd, &PS.rcPaint);
|
||||||
else
|
|
||||||
{
|
|
||||||
hdc = BeginPaint(hwnd,&PS);
|
|
||||||
}
|
|
||||||
GetClientRect(hwnd,&PS.rcPaint);
|
|
||||||
|
|
||||||
/* Position image in center of dialog */
|
/* Position image in center of dialog */
|
||||||
left = (PS.rcPaint.right - pImgInfo->cxSource) / 2;
|
left = (PS.rcPaint.right - pImgInfo->cxSource) / 2;
|
||||||
|
@ -185,16 +261,17 @@ LRESULT CALLBACK RosImageProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||||
|
|
||||||
if (hdcMem != NULL)
|
if (hdcMem != NULL)
|
||||||
{
|
{
|
||||||
SelectObject(hdcMem, timerid ? hBitmap2 : pImgInfo->hBitmap);
|
if(timerid != 0)
|
||||||
BitBlt(hdc,
|
{
|
||||||
left,
|
SelectObject(hdcMem, hCreditsBitmap);
|
||||||
PS.rcPaint.top,
|
BitBlt(hdc, left, PS.rcPaint.top, PS.rcPaint.right - PS.rcPaint.left, PS.rcPaint.top + pImgInfo->cySource, hdcMem, 0, top, SRCCOPY);
|
||||||
PS.rcPaint.right - PS.rcPaint.left,
|
}
|
||||||
PS.rcPaint.top + pImgInfo->cySource,
|
else
|
||||||
hdcMem,
|
{
|
||||||
0,
|
SelectObject(hdcMem, pImgInfo->hBitmap);
|
||||||
top,
|
AlphaBlend(hdc, left, PS.rcPaint.top, pImgInfo->cxSource, pImgInfo->cySource, hdcMem, 0, 0, pImgInfo->cxSource, pImgInfo->cySource, BlendFunc);
|
||||||
SRCCOPY);
|
}
|
||||||
|
|
||||||
DeleteDC(hdcMem);
|
DeleteDC(hdcMem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,7 +598,7 @@ GeneralPageProc(HWND hwndDlg,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitImageInfo(pImgInfo);
|
InitLogo(hwndDlg);
|
||||||
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_ROSIMG), GWL_WNDPROC, (LONG)RosImageProc);
|
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_ROSIMG), GWL_WNDPROC, (LONG)RosImageProc);
|
||||||
GetSystemInformation(hwndDlg);
|
GetSystemInformation(hwndDlg);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#define IDI_DOWN 2501
|
#define IDI_DOWN 2501
|
||||||
|
|
||||||
#define IDB_ROSBMP 55
|
#define IDB_ROSBMP 55
|
||||||
|
#define IDB_ROSMASK 56
|
||||||
|
|
||||||
#define IDS_CPLSYSTEMNAME 60
|
#define IDS_CPLSYSTEMNAME 60
|
||||||
#define IDS_CPLSYSTEMDESCRIPTION 61
|
#define IDS_CPLSYSTEMDESCRIPTION 61
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 161 KiB After Width: | Height: | Size: 149 KiB |
BIN
reactos/dll/cpl/sysdm/resources/rosbitmap_mask.bmp
Normal file
BIN
reactos/dll/cpl/sysdm/resources/rosbitmap_mask.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
|
@ -19,6 +19,7 @@ IDI_DEVMGR ICON "resources/devmgr.ico"
|
||||||
IDI_UP ICON "resources/up.ico"
|
IDI_UP ICON "resources/up.ico"
|
||||||
IDI_DOWN ICON "resources/down.ico"
|
IDI_DOWN ICON "resources/down.ico"
|
||||||
IDB_ROSBMP BITMAP "resources/rosbitmap.bmp"
|
IDB_ROSBMP BITMAP "resources/rosbitmap.bmp"
|
||||||
|
IDB_ROSMASK BITMAP "resources/rosbitmap_mask.bmp"
|
||||||
|
|
||||||
RC_LICENSE RTDATA "resources/gpl.txt"
|
RC_LICENSE RTDATA "resources/gpl.txt"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue