Author: hbelusca
Date: Sat Jul 8 00:04:21 2017
New Revision: 75303
URL:
http://svn.reactos.org/svn/reactos?rev=75303&view=rev
Log:
[USERINIT]: Paint the ReactOS logo transparently (with alpha channel), much like it's
done in dll/cpl/sysdm/general.c . CORE-13527 #resolve
This also fixes the drawing mismatch problem reported at CORE-11323 #resolve
Finally, add a standard comctl32 manifest.
Added:
branches/setup_improvements/base/system/userinit/res/rosbitmap.bmp
- copied unchanged from r75302,
branches/setup_improvements/dll/cpl/sysdm/resources/rosbitmap.bmp
branches/setup_improvements/base/system/userinit/res/rosbitmap_mask.bmp
- copied unchanged from r75302,
branches/setup_improvements/dll/cpl/sysdm/resources/rosbitmap_mask.bmp
branches/setup_improvements/base/system/userinit/res/rosbitmap_old.bmp
- copied unchanged from r75302,
branches/setup_improvements/base/system/userinit/res/rosbitmap.bmp
Modified:
branches/setup_improvements/base/system/userinit/livecd.c
branches/setup_improvements/base/system/userinit/resource.h
branches/setup_improvements/base/system/userinit/userinit.h
branches/setup_improvements/base/system/userinit/userinit.rc
Modified: branches/setup_improvements/base/system/userinit/livecd.c
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/system/…
==============================================================================
--- branches/setup_improvements/base/system/userinit/livecd.c [iso-8859-1] (original)
+++ branches/setup_improvements/base/system/userinit/livecd.c [iso-8859-1] Sat Jul 8
00:04:21 2017
@@ -11,27 +11,80 @@
HWND hLocaleList;
BOOL bSpain = FALSE;
+/*
+ * Taken and adapted from dll/cpl/sysdm/general.c
+ */
static VOID
-InitImageInfo(PIMGINFO ImgInfo)
-{
- BITMAP bitmap;
-
- ZeroMemory(ImgInfo, sizeof(*ImgInfo));
-
- ImgInfo->hBitmap = LoadImageW(hInstance,
- MAKEINTRESOURCEW(IDB_ROSLOGO),
- IMAGE_BITMAP,
- 0,
- 0,
- LR_DEFAULTCOLOR);
-
- if (ImgInfo->hBitmap != NULL)
- {
- GetObject(ImgInfo->hBitmap, sizeof(bitmap), &bitmap);
-
- ImgInfo->cxSource = bitmap.bmWidth;
- ImgInfo->cySource = bitmap.bmHeight;
- }
+InitLogo(PIMGINFO pImgInfo, HWND hwndDlg)
+{
+ 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(pImgInfo, sizeof(*pImgInfo));
+ ZeroMemory(&bmpi, sizeof(bmpi));
+
+ hLogo = (HBITMAP)LoadImageW(hInstance, MAKEINTRESOURCEW(IDB_ROSLOGO), IMAGE_BITMAP,
0, 0, LR_DEFAULTCOLOR);
+ hMask = (HBITMAP)LoadImageW(hInstance, MAKEINTRESOURCEW(IDB_ROSMASK), IMAGE_BITMAP,
0, 0, LR_DEFAULTCOLOR);
+
+ if (hLogo != NULL && hMask != NULL)
+ {
+ GetObject(hLogo, sizeof(logoBitmap), &logoBitmap);
+ GetObject(hMask, sizeof(maskBitmap), &maskBitmap);
+
+ if (logoBitmap.bmHeight != maskBitmap.bmHeight || logoBitmap.bmWidth !=
maskBitmap.bmWidth)
+ goto Cleanup;
+
+ 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;
+
+ /* Create a premultiplied bitmap */
+ hAlphaLogo = CreateDIBSection(hDC, &bmpi, DIB_RGB_COLORS, (PVOID*)&pBits,
0, 0);
+ if (!hAlphaLogo)
+ goto Cleanup;
+
+ 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;
+ }
+
+Cleanup:
+ DeleteObject(hMask);
+ DeleteObject(hLogo);
+ DeleteDC(hDCMask);
+ DeleteDC(hDCLogo);
}
@@ -521,16 +574,19 @@
hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
if (hdcMem != NULL)
{
+ static BLENDFUNCTION BlendFunc = {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA};
+
SelectObject(hdcMem, pState->ImageInfo.hBitmap);
- BitBlt(lpDrawItem->hDC,
- left,
- lpDrawItem->rcItem.top,
- lpDrawItem->rcItem.right - lpDrawItem->rcItem.left,
- lpDrawItem->rcItem.bottom - lpDrawItem->rcItem.top,
- hdcMem,
- 0,
- 0,
- SRCCOPY);
+ GdiAlphaBlend(lpDrawItem->hDC,
+ left,
+ lpDrawItem->rcItem.top,
+ pState->ImageInfo.cxSource,
+ pState->ImageInfo.cySource,
+ hdcMem,
+ 0, 0,
+ pState->ImageInfo.cxSource,
+ pState->ImageInfo.cySource,
+ BlendFunc);
DeleteDC(hdcMem);
}
}
@@ -754,7 +810,7 @@
RunLiveCD(
PSTATE pState)
{
- InitImageInfo(&pState->ImageInfo);
+ InitLogo(&pState->ImageInfo, NULL);
while (pState->NextPage != DONE)
{
Modified: branches/setup_improvements/base/system/userinit/resource.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/system/…
==============================================================================
--- branches/setup_improvements/base/system/userinit/resource.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/system/userinit/resource.h [iso-8859-1] Sat Jul 8
00:04:21 2017
@@ -4,6 +4,7 @@
/* Bitmaps */
#define IDB_ROSLOGO 100
+#define IDB_ROSMASK 101
#define IDC_STATIC -1
Modified: branches/setup_improvements/base/system/userinit/userinit.h
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/system/…
==============================================================================
--- branches/setup_improvements/base/system/userinit/userinit.h [iso-8859-1] (original)
+++ branches/setup_improvements/base/system/userinit/userinit.h [iso-8859-1] Sat Jul 8
00:04:21 2017
@@ -48,6 +48,8 @@
HBITMAP hBitmap;
INT cxSource;
INT cySource;
+ INT iPlanes;
+ INT iBits;
} IMGINFO, *PIMGINFO;
typedef struct
Modified: branches/setup_improvements/base/system/userinit/userinit.rc
URL:
http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/system/…
==============================================================================
--- branches/setup_improvements/base/system/userinit/userinit.rc [iso-8859-1] (original)
+++ branches/setup_improvements/base/system/userinit/userinit.rc [iso-8859-1] Sat Jul 8
00:04:21 2017
@@ -3,14 +3,16 @@
#include "resource.h"
-#define REACTOS_STR_FILE_DESCRIPTION "Userinit Logon Application"
-#define REACTOS_STR_INTERNAL_NAME "userinit"
-#define REACTOS_STR_ORIGINAL_FILENAME "userinit.dll"
+#define REACTOS_STR_FILE_DESCRIPTION "Userinit Logon Application"
+#define REACTOS_STR_INTERNAL_NAME "userinit"
+#define REACTOS_STR_ORIGINAL_FILENAME "userinit.exe"
#include <reactos/version.rc>
+
+#include <reactos/manifest_exe.rc>
/* Bitmaps */
IDB_ROSLOGO BITMAP "res/rosbitmap.bmp"
-
+IDB_ROSMASK BITMAP "res/rosbitmap_mask.bmp"
/* UTF-8 */
#pragma code_page(65001)