From a49c40392bc69e1d875124877d85f861c12a8f20 Mon Sep 17 00:00:00 2001 From: Gregor Schneider Date: Tue, 14 Apr 2009 21:30:03 +0000 Subject: [PATCH] - ICON_CreateCursorFromData should pass a header that fits to the bitmap data to SetDIBits to allow color conversion if necessary; create the color cursor if requested in the same function - Winamp 2.95 now shows a custom cursor, but it's still surrounded by blackness, bug #4370 - Misc typo fixes, cleanup svn path=/trunk/; revision=40510 --- reactos/dll/win32/user32/windows/bitmap.c | 3 +-- reactos/dll/win32/user32/windows/icon.c | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/reactos/dll/win32/user32/windows/bitmap.c b/reactos/dll/win32/user32/windows/bitmap.c index 6a5044ca999..afe0e9c8b80 100644 --- a/reactos/dll/win32/user32/windows/bitmap.c +++ b/reactos/dll/win32/user32/windows/bitmap.c @@ -56,8 +56,7 @@ typedef struct #include "poppack.h" -/*forward declerations... actualy in user32\windows\icon.c but usful here****/ -HICON ICON_CreateCursorFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired, int xHotspot, int yHotspot); +/* forward declerations... actually in user32\windows\icon.c but usful here */ HICON ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired, int xHotspot, int yHotspot); CURSORICONDIRENTRY *CURSORICON_FindBestIcon( CURSORICONDIR *dir, int width, int height, int colors); CURSORICONDIRENTRY *CURSORICON_FindBestCursor( CURSORICONDIR *dir, int width, int height, int colors); diff --git a/reactos/dll/win32/user32/windows/icon.c b/reactos/dll/win32/user32/windows/icon.c index d7f940a6883..e6c4ab95bce 100644 --- a/reactos/dll/win32/user32/windows/icon.c +++ b/reactos/dll/win32/user32/windows/icon.c @@ -94,9 +94,9 @@ ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDe HICON ICON_CreateCursorFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired, int xHotspot, int yHotspot) { - /* FIXME - color cursors */ BYTE BitmapInfoBuffer[sizeof(BITMAPINFOHEADER) + 2 * sizeof(RGBQUAD)]; BITMAPINFO *bwBIH = (BITMAPINFO *)BitmapInfoBuffer; + BITMAPINFO *orgBIH = (BITMAPINFO *)IconImage; ICONINFO IconInfo; PVOID XORImageData = ImageData; @@ -104,7 +104,7 @@ ICON_CreateCursorFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cx IconInfo.xHotspot = xHotspot; IconInfo.yHotspot = yHotspot; - /* Create a BITMAPINFO header for the monocrome part of the icon */ + /* Create a BITMAPINFO header for the monochrome part of the icon */ bwBIH->bmiHeader.biBitCount = 1; bwBIH->bmiHeader.biWidth = IconImage->icHeader.biWidth; bwBIH->bmiHeader.biHeight = IconImage->icHeader.biHeight; @@ -133,10 +133,24 @@ ICON_CreateCursorFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cx if (IconInfo.hbmMask) { SetDIBits(hDC, IconInfo.hbmMask, 0, IconImage->icHeader.biHeight, - XORImageData, bwBIH, DIB_RGB_COLORS); + XORImageData, orgBIH, DIB_RGB_COLORS); } - IconInfo.hbmColor = (HBITMAP)0; + if (IconImage->icHeader.biBitCount == 1) + { + IconInfo.hbmColor = (HBITMAP)0; + } + else + { + /* Create the color part of the icon */ + IconInfo.hbmColor = CreateDIBitmap(hDC, &IconImage->icHeader, 0, + XORImageData, orgBIH, DIB_RGB_COLORS); + if (IconInfo.hbmColor) + { + SetDIBits(hDC, IconInfo.hbmColor, 0, IconImage->icHeader.biHeight, + XORImageData, orgBIH, DIB_RGB_COLORS); + } + } /* Create the icon based on everything we have so far */ return NtUserCreateCursorIconHandle(&IconInfo, FALSE);