From 0c98050bdcee69869efa2794f04632efd86bbe4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Mon, 6 Oct 2003 16:25:53 +0000 Subject: [PATCH] Fix icon handling svn path=/trunk/; revision=6251 --- reactos/iface/addsys/w32ksvc.db | 1 - reactos/include/defines.h | 4 +- reactos/include/win32k/gdiobj.h | 1 - reactos/lib/user32/windows/icon.c | 620 ++++++++++++++------- reactos/subsys/win32k/dib/dib16bpp.c | 7 +- reactos/subsys/win32k/dib/dib1bpp.c | 7 +- reactos/subsys/win32k/dib/dib24bpp.c | 7 +- reactos/subsys/win32k/dib/dib32bpp.c | 7 +- reactos/subsys/win32k/dib/dib4bpp.c | 7 +- reactos/subsys/win32k/dib/dib8bpp.c | 7 +- reactos/subsys/win32k/objects/cursoricon.c | 155 +----- reactos/subsys/win32k/objects/dc.c | 9 +- 12 files changed, 461 insertions(+), 371 deletions(-) diff --git a/reactos/iface/addsys/w32ksvc.db b/reactos/iface/addsys/w32ksvc.db index 4764fee79c1..c43e9f0bc6d 100644 --- a/reactos/iface/addsys/w32ksvc.db +++ b/reactos/iface/addsys/w32ksvc.db @@ -40,7 +40,6 @@ NtGdiCreateFontIndirect 1 NtGdiCreateHalftonePalette 1 NtGdiCreateHatchBrush 2 NtGdiCreateIC 4 -NtGdiCreateIcon 9 NtGdiCreateMetaFile 1 NtGdiCreatePalette 1 NtGdiCreatePatternBrush 1 diff --git a/reactos/include/defines.h b/reactos/include/defines.h index fae16a8fcf7..f2cda67d353 100644 --- a/reactos/include/defines.h +++ b/reactos/include/defines.h @@ -1098,7 +1098,7 @@ extern "C" { #define RT_CURSORA (MAKEINTRESOURCEA(1)) #define RT_GROUP_CURSORA (MAKEINTRESOURCEA(12)) #define RT_ICONA (MAKEINTRESOURCEA(3)) -#define RT_GROUP_ICONA (MAKEINTRESOURCEA(13)) +#define RT_GROUP_ICONA (MAKEINTRESOURCEA(14)) #define RT_VERSIONA (MAKEINTRESOURCEA(16)) #define RT_ACCELERATORW (MAKEINTRESOURCEW(9)) @@ -1113,7 +1113,7 @@ extern "C" { #define RT_CURSORW (MAKEINTRESOURCEW(1)) #define RT_GROUP_CURSORW (MAKEINTRESOURCEW(12)) #define RT_ICONW (MAKEINTRESOURCEW(3)) -#define RT_GROUP_ICONW (MAKEINTRESOURCEW(13)) +#define RT_GROUP_ICONW (MAKEINTRESOURCEW(14)) #define RT_VERSIONW (MAKEINTRESOURCEW(16)) #ifndef _DISABLE_TIDENT diff --git a/reactos/include/win32k/gdiobj.h b/reactos/include/win32k/gdiobj.h index 4d525553dfc..19d8dc90d60 100644 --- a/reactos/include/win32k/gdiobj.h +++ b/reactos/include/win32k/gdiobj.h @@ -30,7 +30,6 @@ #define GDI_OBJECT_TYPE_ENHMETAFILE 0x00730000 #define GDI_OBJECT_TYPE_ENHMETADC 0x00740000 #define GDI_OBJECT_TYPE_MEMDC 0x00750000 -#define GDI_OBJECT_TYPE_ICONCURSOR 0x00760000 #define GDI_OBJECT_TYPE_DCE 0x00770000 #define GDI_OBJECT_TYPE_DONTCARE 0x007f0000 /*@}*/ diff --git a/reactos/lib/user32/windows/icon.c b/reactos/lib/user32/windows/icon.c index ee26894e8b1..183cdab895a 100644 --- a/reactos/lib/user32/windows/icon.c +++ b/reactos/lib/user32/windows/icon.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: icon.c,v 1.11 2003/08/29 00:24:42 weiden Exp $ +/* $Id: icon.c,v 1.12 2003/10/06 16:25:53 gvg Exp $ * * PROJECT: ReactOS user32.dll * FILE: lib/user32/windows/icon.c @@ -36,25 +36,194 @@ /* FUNCTIONS *****************************************************************/ +STATIC WINBOOL FASTCALL +ICON_CopyBitmaps(HBITMAP *MaskTo, HBITMAP MaskFrom, + HBITMAP *ColorTo, HBITMAP *ColorFrom, + DWORD Width, DWORD Height) +{ + HDC DCFrom, DCTo; + HBITMAP InitialFrom, InitialTo; + + DCFrom = CreateCompatibleDC(NULL); + if (NULL == DCFrom) + { + return FALSE; + } + DCTo = CreateCompatibleDC(DCFrom); + if (NULL == DCTo) + { + DeleteDC(DCFrom); + return FALSE; + } + + *MaskTo = CreateCompatibleBitmap(DCTo, Width, Height); + if (NULL == *MaskTo) + { + DeleteDC(DCTo); + DeleteDC(DCFrom); + return FALSE; + } + + InitialFrom = SelectObject(DCFrom, MaskFrom); + if (NULL == InitialFrom) + { + DeleteObject(*MaskTo); + *MaskTo = NULL; + DeleteDC(DCTo); + DeleteDC(DCFrom); + return FALSE; + } + + InitialTo = SelectObject(DCTo, *MaskTo); + if (NULL == InitialTo) + { + DeleteObject(*MaskTo); + *MaskTo = NULL; + DeleteDC(DCTo); + SelectObject(DCFrom, InitialFrom); + DeleteDC(DCFrom); + return FALSE; + } + + if (! BitBlt(DCTo, 0, 0, Width, Height, DCFrom, 0, 0, SRCCOPY)) + { + SelectObject(DCTo, InitialTo); + DeleteObject(*MaskTo); + *MaskTo = NULL; + DeleteDC(DCTo); + SelectObject(DCFrom, InitialFrom); + DeleteDC(DCFrom); + return FALSE; + } + + *ColorTo = CreateCompatibleBitmap(DCTo, Width, Height); + if (NULL == *ColorTo) + { + SelectObject(DCTo, InitialTo); + DeleteObject(*MaskTo); + *MaskTo = NULL; + DeleteDC(DCTo); + SelectObject(DCFrom, InitialFrom); + DeleteDC(DCFrom); + return FALSE; + } + + if (NULL == SelectObject(DCFrom, ColorFrom)) + { + DeleteObject(*ColorTo); + *ColorTo = NULL; + SelectObject(DCTo, InitialTo); + DeleteObject(*MaskTo); + *MaskTo = NULL; + DeleteDC(DCTo); + SelectObject(DCFrom, InitialFrom); + DeleteDC(DCFrom); + return FALSE; + } + + if (NULL == SelectObject(DCTo, *ColorTo)) + { + DeleteObject(*ColorTo); + *ColorTo = NULL; + SelectObject(DCTo, InitialTo); + DeleteObject(*MaskTo); + *MaskTo = NULL; + DeleteDC(DCTo); + SelectObject(DCFrom, InitialFrom); + DeleteDC(DCFrom); + return FALSE; + } + + + if (! BitBlt(DCTo, 0, 0, Width, Height, DCFrom, 0, 0, SRCCOPY)) + { + SelectObject(DCTo, InitialTo); + DeleteObject(*ColorTo); + *ColorTo = NULL; + DeleteObject(*MaskTo); + *MaskTo = NULL; + DeleteDC(DCTo); + SelectObject(DCFrom, InitialFrom); + DeleteDC(DCFrom); + return FALSE; + } + + SelectObject(DCTo, InitialTo); + DeleteDC(DCTo); + SelectObject(DCFrom, InitialFrom); + DeleteDC(DCFrom); + + return TRUE; +} + +STATIC +HICON +FASTCALL +ICON_CreateIconIndirect(PICONINFO IconInfo, WINBOOL CopyBitmaps, + DWORD Width, DWORD Height) +{ + PICONINFO NewIcon; + + if (NULL == IconInfo) + { + DPRINT("Invalid parameter passed\n"); + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + NewIcon = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ICONINFO)); + if (NULL == NewIcon) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return NULL; + } + + /* Set up the basic icon stuff */ + NewIcon->fIcon = IconInfo->fIcon; + NewIcon->xHotspot = IconInfo->xHotspot; + NewIcon->yHotspot = IconInfo->yHotspot; + + if (CopyBitmaps) + { + /* Store a copy the bitmaps */ + if (! ICON_CopyBitmaps(&(NewIcon->hbmMask), IconInfo->hbmMask, + &(NewIcon->hbmColor), IconInfo->hbmColor, + Width, Height)) + { + HeapFree(GetProcessHeap(), 0, NewIcon); + return NULL; + } + } + else + { + /* We take ownership of the bitmaps */ + NewIcon->hbmMask = IconInfo->hbmMask; + NewIcon->hbmColor = IconInfo->hbmColor; + } + + return (HICON) NewIcon; +} + HICON ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDesired, int cyDesired, int xHotspot, int yHotspot) { - HANDLE hXORBitmap; - HANDLE hANDBitmap; BITMAPINFO* bwBIH; ICONINFO IconInfo; - HICON hIcon; - //load the XOR bitmap - hXORBitmap = CreateDIBitmap(hDC, &IconImage->icHeader, CBM_INIT, - ImageData, (BITMAPINFO*)IconImage, DIB_RGB_COLORS); + IconInfo.fIcon = TRUE; + IconInfo.xHotspot = xHotspot; + IconInfo.yHotspot = yHotspot; - //make ImageData point to the start of the AND image data + /* Load the XOR bitmap */ + IconInfo.hbmColor = CreateDIBitmap(hDC, &IconImage->icHeader, CBM_INIT, + ImageData, (BITMAPINFO*)IconImage, DIB_RGB_COLORS); + + /* make ImageData point to the start of the AND image data */ ImageData = ((PBYTE)ImageData) + (((IconImage->icHeader.biWidth * IconImage->icHeader.biBitCount + 31) & ~31) >> 3) * (IconImage->icHeader.biHeight ); - //create a BITMAPINFO header for the monocrome part of the icon + /* create a BITMAPINFO header for the monocrome part of the icon */ bwBIH = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof (BITMAPINFOHEADER)+2*sizeof(RGBQUAD)); bwBIH->bmiHeader.biBitCount = 1; @@ -80,26 +249,15 @@ ICON_CreateIconFromData(HDC hDC, PVOID ImageData, ICONIMAGE* IconImage, int cxDe bwBIH->bmiColors[1].rgbRed = 0xff; bwBIH->bmiColors[1].rgbReserved = 0; - //load the AND bitmap - hANDBitmap = CreateDIBitmap(hDC, &bwBIH->bmiHeader, CBM_INIT, - ImageData, bwBIH, DIB_RGB_COLORS); + /* load the AND bitmap */ + IconInfo.hbmMask = CreateDIBitmap(hDC, &bwBIH->bmiHeader, CBM_INIT, + ImageData, bwBIH, DIB_RGB_COLORS); RtlFreeHeap(RtlGetProcessHeap(), 0, bwBIH); - IconInfo.fIcon = TRUE; - IconInfo.xHotspot = xHotspot; - IconInfo.yHotspot = yHotspot; - IconInfo.hbmColor = hXORBitmap; - IconInfo.hbmMask = hANDBitmap; - - //Create the icon based on everything we have so far - hIcon = CreateIconIndirect(&IconInfo); - - //clean up - DeleteObject(hXORBitmap); - DeleteObject(hANDBitmap); - - return hIcon; + /* Create the icon based on everything we have so far */ + return ICON_CreateIconIndirect(&IconInfo, FALSE, IconImage->icHeader.biWidth, + IconImage->icHeader.biHeight); } @@ -111,13 +269,21 @@ STDCALL CopyIcon( HICON hIcon) { - ICONINFO IconInfo; - NtUserGetIconInfo(hIcon, &IconInfo.fIcon, - &IconInfo.xHotspot, - &IconInfo.yHotspot, - &IconInfo.hbmMask, - &IconInfo.hbmColor); - return CreateIconIndirect(&IconInfo); + PICONINFO IconInfo = (PICONINFO) hIcon; + BITMAP BitmapInfo; + + if (NULL == IconInfo) + { + SetLastError(ERROR_INVALID_HANDLE); + return NULL; + } + + if (0 == GetObjectW(IconInfo->hbmColor, sizeof(BITMAP), &BitmapInfo)) + { + return NULL; + } + + return ICON_CreateIconIndirect(IconInfo, TRUE, BitmapInfo.bmWidth, BitmapInfo.bmHeight); } @@ -132,19 +298,27 @@ CreateIcon( int nHeight, BYTE cPlanes, BYTE cBitsPixel, - CONST BYTE *lpbANDbits, - CONST BYTE *lpbXORbits) + CONST BYTE *ANDbits, + CONST BYTE *XORbits) { - DPRINT("hInstance not used in this implementation\n"); - return NtGdiCreateIcon(TRUE, - nWidth, - nHeight, - cPlanes, - cBitsPixel, - nWidth/2, - nHeight/2, - lpbANDbits, - lpbXORbits); + ICONINFO IconInfo; + + IconInfo.fIcon = TRUE; + IconInfo.xHotspot = nWidth / 2; + IconInfo.yHotspot = nHeight / 2; + IconInfo.hbmMask = CreateBitmap(nWidth, nHeight, cPlanes, cBitsPixel, ANDbits); + if (NULL == IconInfo.hbmMask) + { + return NULL; + } + IconInfo.hbmColor = CreateBitmap(nWidth, nHeight, cPlanes, cBitsPixel, XORbits); + if (NULL == IconInfo.hbmColor) + { + DeleteObject(IconInfo.hbmMask); + return NULL; + } + + return ICON_CreateIconIndirect(&IconInfo, FALSE, nWidth, nHeight); } @@ -188,53 +362,54 @@ CreateIconFromResourceEx( DPRINT("dwVersion, cxDesired, cyDesired are all ignored in this implementation!\n"); - if (!fIcon) - { - wXHotspot = (WORD)*pbIconBits; - pbIconBits+=2; - wYHotspot = (WORD)*pbIconBits; - pbIconBits+=2; - cbIconBits-=4; - } + if (! fIcon) + { + wXHotspot = (WORD)*pbIconBits; + pbIconBits+=2; + wYHotspot = (WORD)*pbIconBits; + pbIconBits+=2; + cbIconBits-=4; + } else - { - wXHotspot = cxDesired / 2; - wYHotspot = cyDesired / 2; - } + { + wXHotspot = cxDesired / 2; + wYHotspot = cyDesired / 2; + } - //get an safe copy of the icon data + /* get an safe copy of the icon data */ SafeIconImage = RtlAllocateHeap(RtlGetProcessHeap(), 0, cbIconBits); memcpy(SafeIconImage, pbIconBits, cbIconBits); - //take into acount the origonal hight was for both the AND and XOR images + /* take into acount the origonal hight was for both the AND and XOR images */ SafeIconImage->icHeader.biHeight /= 2; if (SafeIconImage->icHeader.biSize == sizeof(BITMAPCOREHEADER)) - { + { BITMAPCOREHEADER* Core = (BITMAPCOREHEADER*)SafeIconImage; ColourCount = (Core->bcBitCount <= 8) ? (1 << Core->bcBitCount) : 0; HeaderSize = sizeof(BITMAPCOREHEADER) + ColourCount * sizeof(RGBTRIPLE); - } + } else - { + { ColourCount = (SafeIconImage->icHeader.biBitCount <= 8) ? (1 << SafeIconImage->icHeader.biBitCount) : 0; HeaderSize = sizeof(BITMAPINFOHEADER) + ColourCount * sizeof(RGBQUAD); - } + } - //make data point to the start of the XOR image data + /* make data point to the start of the XOR image data */ Data = (PBYTE)SafeIconImage + HeaderSize; - //get a handle to the screen dc, the icon we create is going to be compatable with this - hScreenDc = CreateDCW(L"DISPLAY", NULL, NULL, NULL); + /* get a handle to the screen dc, the icon we create is going to be compatable with this */ + hScreenDc = CreateCompatibleDC(NULL); if (hScreenDc == NULL) - { - RtlFreeHeap(RtlGetProcessHeap(), 0, SafeIconImage); - return(NULL); - } + { + RtlFreeHeap(RtlGetProcessHeap(), 0, SafeIconImage); + return(NULL); + } hIcon = ICON_CreateIconFromData(hScreenDc, Data, SafeIconImage, cxDesired, cyDesired, wXHotspot, wYHotspot); RtlFreeHeap(RtlGetProcessHeap(), 0, SafeIconImage); + return hIcon; } @@ -244,24 +419,33 @@ CreateIconFromResourceEx( */ HICON STDCALL -CreateIconIndirect( - PICONINFO piconinfo) +CreateIconIndirect(PICONINFO IconInfo) { - BITMAP bmMask; - BITMAP bmColor; + BITMAP ColorBitmap; + BITMAP MaskBitmap; - NtGdiGetObject( piconinfo->hbmMask, sizeof(BITMAP), &bmMask ); - NtGdiGetObject( piconinfo->hbmColor, sizeof(BITMAP), &bmColor ); + if (NULL == IconInfo) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } - return NtGdiCreateIcon(piconinfo->fIcon, - bmColor.bmWidth, - bmColor.bmHeight, - bmColor.bmPlanes, - bmColor.bmBitsPixel, - piconinfo->xHotspot, - piconinfo->yHotspot, - bmMask.bmBits, - bmColor.bmBits); + if (0 == GetObjectW(IconInfo->hbmColor, sizeof(BITMAP), &ColorBitmap)) + { + return NULL; + } + if (0 == GetObjectW(IconInfo->hbmMask, sizeof(BITMAP), &MaskBitmap)) + { + return NULL; + } + if (ColorBitmap.bmWidth != MaskBitmap.bmWidth || + ColorBitmap.bmHeight != MaskBitmap.bmWidth) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + + return ICON_CreateIconIndirect(IconInfo, TRUE, ColorBitmap.bmWidth, ColorBitmap.bmHeight); } @@ -273,7 +457,26 @@ STDCALL DestroyIcon( HICON hIcon) { - return NtGdiDeleteObject(hIcon); + PICONINFO IconInfo = (PICONINFO) hIcon; + + if (NULL == IconInfo) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + if (NULL != IconInfo->hbmMask) + { + DeleteObject(IconInfo->hbmMask); + } + if (NULL != IconInfo->hbmColor) + { + DeleteObject(IconInfo->hbmColor); + } + + HeapFree(GetProcessHeap(), 0, IconInfo); + + return TRUE; } @@ -288,7 +491,7 @@ DrawIcon( int Y, HICON hIcon) { - return DrawIconEx (hDC, X, Y, hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE); + return DrawIconEx(hDC, X, Y, hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE); } /* Ported from WINE20030408 */ @@ -308,52 +511,50 @@ DrawIconEx( HBRUSH hbrFlickerFreeDraw, UINT diFlags) { - ICONINFO IconInfo; - BITMAP XORBitmap; - HDC hDC_off = 0, hMemDC; - BOOL result = FALSE, DoOffscreen; - HBITMAP hB_off = 0, hOld = 0; + PICONINFO IconInfo = (PICONINFO) hIcon; + BITMAP Bitmap; + HDC hDC_off = 0, hMemDC; + BOOL result = FALSE, DoOffscreen; + HBITMAP hB_off = 0, hOld = 0; - if (!NtUserGetIconInfo(hIcon, &IconInfo.fIcon, - &IconInfo.xHotspot, - &IconInfo.yHotspot, - &IconInfo.hbmMask, - &IconInfo.hbmColor)) + if (NULL == IconInfo) + { + SetLastError(ERROR_INVALID_HANDLE); return FALSE; - - NtGdiGetObject(IconInfo.hbmColor, sizeof(BITMAP), &XORBitmap); - - DPRINT("(hdc=%p,pos=%d.%d,hicon=%p,extend=%d.%d,istep=%d,br=%p,flags=0x%08x)\n", - hdc,xLeft,yTop,hIcon,cxWidth,cyWidth,istepIfAniCur,hbrFlickerFreeDraw,diFlags ); - - hMemDC = CreateCompatibleDC (hdc); - if (diFlags & DI_COMPAT) - DPRINT("Ignoring flag DI_COMPAT\n"); - - if (!diFlags) - { - diFlags = DI_NORMAL; } - // Calculate the size of the destination image. - if (cxWidth == 0) + GetObjectW(IconInfo->hbmColor, sizeof(BITMAP), &Bitmap); + + DPRINT("(hdc=%p,pos=%d.%d,hicon=%p,extend=%d.%d,istep=%d,br=%p,flags=0x%08x)\n", + hdc,xLeft,yTop,hIcon,cxWidth,cyWidth,istepIfAniCur,hbrFlickerFreeDraw,diFlags ); + + hMemDC = CreateCompatibleDC(hdc); + if (diFlags & DI_COMPAT) { - if (diFlags & DI_DEFAULTSIZE) - cxWidth = GetSystemMetrics (SM_CXICON); - else - cxWidth = XORBitmap.bmWidth; - } - if (cyWidth == 0) - { - if (diFlags & DI_DEFAULTSIZE) - cyWidth = GetSystemMetrics (SM_CYICON); - else - cyWidth = XORBitmap.bmHeight; + DPRINT("Ignoring flag DI_COMPAT\n"); } - DoOffscreen = (GetObjectType( hbrFlickerFreeDraw ) == OBJ_BRUSH); + if (!diFlags) + { + diFlags = DI_NORMAL; + } - if (DoOffscreen) + /* Calculate the size of the destination image. */ + if (cxWidth == 0) + { + cxWidth = (diFlags & DI_DEFAULTSIZE ? GetSystemMetrics (SM_CXICON) + : Bitmap.bmWidth); + } + if (cyWidth == 0) + { + cyWidth = (diFlags & DI_DEFAULTSIZE ? GetSystemMetrics (SM_CYICON) + : Bitmap.bmHeight); + } + + DoOffscreen = (NULL != hbrFlickerFreeDraw + && OBJ_BRUSH == GetObjectType(hbrFlickerFreeDraw)); + + if (DoOffscreen) { RECT r; @@ -362,82 +563,93 @@ DrawIconEx( r.right = cxWidth; r.bottom = cxWidth; - DbgPrint("in DrawIconEx calling: CreateCompatibleDC\n"); + DPRINT("in DrawIconEx calling: CreateCompatibleDC\n"); hDC_off = CreateCompatibleDC(hdc); - DbgPrint("in DrawIconEx calling: CreateCompatibleBitmap\n"); + DPRINT("in DrawIconEx calling: CreateCompatibleBitmap\n"); hB_off = CreateCompatibleBitmap(hdc, cxWidth, cyWidth); if (hDC_off && hB_off) - { - DbgPrint("in DrawIconEx calling: SelectObject\n"); - hOld = SelectObject(hDC_off, hB_off); + { + DPRINT("in DrawIconEx calling: SelectObject\n"); + hOld = SelectObject(hDC_off, hB_off); - DbgPrint("in DrawIconEx calling: FillRect\n"); - FillRect(hDC_off, &r, hbrFlickerFreeDraw); - } + DPRINT("in DrawIconEx calling: FillRect\n"); + FillRect(hDC_off, &r, hbrFlickerFreeDraw); + } } - if (hMemDC && (!DoOffscreen || (hDC_off && hB_off))) + if (hMemDC && (! DoOffscreen || (hDC_off && hB_off))) { - COLORREF oldFg, oldBg; - INT nStretchMode; + COLORREF oldFg, oldBg; + INT nStretchMode; - nStretchMode = SetStretchBltMode (hdc, STRETCH_DELETESCANS); + nStretchMode = SetStretchBltMode(hdc, STRETCH_DELETESCANS); + oldFg = SetTextColor(hdc, RGB(0, 0, 0)); + oldBg = SetBkColor(hdc, RGB(255, 255, 255)); - oldFg = SetTextColor( hdc, RGB(0,0,0) ); - - oldBg = SetBkColor( hdc, RGB(255,255,255) ); - - if (IconInfo.hbmColor && IconInfo.hbmMask) - { - HBITMAP hBitTemp = SelectObject( hMemDC, IconInfo.hbmMask ); - if (diFlags & DI_MASK) + if (IconInfo->hbmColor && IconInfo->hbmMask) { - if (DoOffscreen) - StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth, - hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCAND); - else - StretchBlt (hdc, xLeft, yTop, cxWidth, cyWidth, - hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCAND); + HBITMAP hBitTemp = SelectObject(hMemDC, IconInfo->hbmMask); + if (diFlags & DI_MASK) + { + if (DoOffscreen) + { + StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth, + hMemDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, + SRCAND); + } + else + { + StretchBlt (hdc, xLeft, yTop, cxWidth, cyWidth, + hMemDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, + SRCAND); + } + } + SelectObject(hMemDC, IconInfo->hbmColor); + if (diFlags & DI_IMAGE) + { + if (DoOffscreen) + { + StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth, + hMemDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, + SRCINVERT); + } + else + { + StretchBlt (hdc, xLeft, yTop, cxWidth, cyWidth, + hMemDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, + SRCINVERT); + } + } + SelectObject(hMemDC, hBitTemp); + result = TRUE; } - SelectObject( hMemDC, IconInfo.hbmColor ); - if (diFlags & DI_IMAGE) - { - if (DoOffscreen) - StretchBlt (hDC_off, 0, 0, cxWidth, cyWidth, - hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCPAINT); - else - StretchBlt (hdc, xLeft, yTop, cxWidth, cyWidth, - hMemDC, 0, 0, XORBitmap.bmWidth, XORBitmap.bmHeight, SRCPAINT); - } - SelectObject( hMemDC, hBitTemp ); - result = TRUE; - } SetTextColor( hdc, oldFg ); SetBkColor( hdc, oldBg ); - if (IconInfo.hbmColor) - DeleteObject( IconInfo.hbmColor ); - - if (IconInfo.hbmMask) - DeleteObject( IconInfo.hbmMask ); - SetStretchBltMode (hdc, nStretchMode); if (DoOffscreen) - { - BitBlt(hdc, xLeft, yTop, cxWidth, cyWidth, hDC_off, 0, 0, SRCCOPY); - SelectObject(hDC_off, hOld); - } + { + BitBlt(hdc, xLeft, yTop, cxWidth, cyWidth, hDC_off, 0, 0, SRCCOPY); + SelectObject(hDC_off, hOld); + } } - if (hMemDC) + if (hMemDC) + { DeleteDC( hMemDC ); - if (hDC_off) + } + if (hDC_off) + { DeleteDC(hDC_off); - if (hB_off) + } + if (hB_off) + { DeleteObject(hB_off); - return result; + } + + return result; } @@ -448,26 +660,40 @@ WINBOOL STDCALL GetIconInfo( HICON hIcon, - PICONINFO piconinfo) + PICONINFO IconInfo) { - ICONINFO IconInfo; - WINBOOL res; - - if(!piconinfo) - { - SetLastError(ERROR_NOACCESS); - return FALSE; - } - - res = NtUserGetIconInfo(hIcon, - &piconinfo->fIcon, - &piconinfo->xHotspot, - &piconinfo->yHotspot, - &piconinfo->hbmMask, - &piconinfo->hbmColor); - if(res) - RtlCopyMemory(piconinfo, &IconInfo, sizeof(ICONINFO)); - return res; + PICONINFO IconData = (PICONINFO) hIcon; + BITMAP BitmapInfo; + + if (NULL == IconData) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + if (NULL == IconInfo) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + /* Copy basic info */ + IconInfo->fIcon = IconData->fIcon; + IconInfo->xHotspot = IconData->xHotspot; + IconInfo->yHotspot = IconData->yHotspot; + + /* Copy the bitmaps */ + if (0 == GetObjectW(IconData->hbmColor, sizeof(BITMAP), &BitmapInfo)) + { + return FALSE; + } + if (! ICON_CopyBitmaps(&(IconInfo->hbmMask), IconData->hbmMask, + &(IconInfo->hbmColor), IconData->hbmColor, + BitmapInfo.bmWidth, BitmapInfo.bmHeight)) + { + return FALSE; + } + + return TRUE; } diff --git a/reactos/subsys/win32k/dib/dib16bpp.c b/reactos/subsys/win32k/dib/dib16bpp.c index df2f31f4047..17252c64655 100644 --- a/reactos/subsys/win32k/dib/dib16bpp.c +++ b/reactos/subsys/win32k/dib/dib16bpp.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib16bpp.c,v 1.8 2003/08/31 07:56:24 gvg Exp $ */ +/* $Id: dib16bpp.c,v 1.9 2003/10/06 16:25:53 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -305,7 +305,7 @@ DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, Source = 0; for (k = 0; k < 2; k++) { - Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << (k * 16)); + Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 16)); } } if (UsesPattern) @@ -323,7 +323,7 @@ DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, { if (UsesSource) { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation); + Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); } if (UsesPattern) { @@ -335,6 +335,7 @@ DIB_16BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, Dest >>= 16; } } + sy++; } } return TRUE; diff --git a/reactos/subsys/win32k/dib/dib1bpp.c b/reactos/subsys/win32k/dib/dib1bpp.c index b4af84be69d..64a02b10bcd 100644 --- a/reactos/subsys/win32k/dib/dib1bpp.c +++ b/reactos/subsys/win32k/dib/dib1bpp.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib1bpp.c,v 1.10 2003/08/22 08:03:51 gvg Exp $ */ +/* $Id: dib1bpp.c,v 1.11 2003/10/06 16:25:53 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include @@ -295,7 +295,7 @@ DIB_1BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, Source = 0; for (k = 0; k < 32; k++) { - Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << k); + Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << k); } } if (UsesPattern) @@ -312,7 +312,7 @@ DIB_1BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, { if (UsesSource) { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation); + Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); } if (UsesPattern) { @@ -323,6 +323,7 @@ DIB_1BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, Dest >>= 1; } } + sy++; } } return TRUE; diff --git a/reactos/subsys/win32k/dib/dib24bpp.c b/reactos/subsys/win32k/dib/dib24bpp.c index 3a6daebedbf..a9ad77ff7f8 100644 --- a/reactos/subsys/win32k/dib/dib24bpp.c +++ b/reactos/subsys/win32k/dib/dib24bpp.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib24bpp.c,v 1.13 2003/08/12 21:55:47 gvg Exp $ */ +/* $Id: dib24bpp.c,v 1.14 2003/10/06 16:25:53 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -253,7 +253,7 @@ DIB_24BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, PBRUSHOBJ Brush, PPOINTL BrushOrigin, XLATEOBJ *ColorTranslation, ULONG Rop4) { - LONG i, j, k, sx, sy; + LONG i, j, sx, sy; ULONG Dest, Source, Pattern; PULONG DestBits; BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); @@ -276,7 +276,7 @@ DIB_24BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, Dest = *DestBits & 0x00ffffff; if (UsesSource) { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) & 0x00ffffff; + Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation) & 0x00ffffff; } if (UsesPattern) { @@ -287,6 +287,7 @@ DIB_24BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, *(PBYTE)DestBits = Dest & 0xff; *(PWORD)(DestBits + 1) = Dest >> 8; } + sy++; } } return TRUE; diff --git a/reactos/subsys/win32k/dib/dib32bpp.c b/reactos/subsys/win32k/dib/dib32bpp.c index a131ca57d31..1f15334805f 100644 --- a/reactos/subsys/win32k/dib/dib32bpp.c +++ b/reactos/subsys/win32k/dib/dib32bpp.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib32bpp.c,v 1.5 2003/08/13 20:24:04 chorns Exp $ */ +/* $Id: dib32bpp.c,v 1.6 2003/10/06 16:25:53 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -247,7 +247,7 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, PBRUSHOBJ Brush, PPOINTL BrushOrigin, XLATEOBJ *ColorTranslation, ULONG Rop4) { - LONG i, j, k, sx, sy; + LONG i, j, sx, sy; ULONG Dest, Source, Pattern; PULONG DestBits; BOOL UsesSource = ((Rop4 & 0xCC0000) >> 2) != (Rop4 & 0x330000); @@ -270,7 +270,7 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, Dest = *DestBits; if (UsesSource) { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation); + Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); } if (UsesPattern) { @@ -279,6 +279,7 @@ DIB_32BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, } *DestBits = DIB_DoRop(Rop4, Dest, Source, Pattern); } + sy++; } } return TRUE; diff --git a/reactos/subsys/win32k/dib/dib4bpp.c b/reactos/subsys/win32k/dib/dib4bpp.c index 1e13ad2c6e9..61ba2704cc1 100644 --- a/reactos/subsys/win32k/dib/dib4bpp.c +++ b/reactos/subsys/win32k/dib/dib4bpp.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib4bpp.c,v 1.18 2003/08/13 20:24:04 chorns Exp $ */ +/* $Id: dib4bpp.c,v 1.19 2003/10/06 16:25:53 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -285,7 +285,7 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, Source = 0; for (k = 0; k < 8; k++) { - Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << (k * 4)); + Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 4)); } } if (UsesPattern) @@ -302,7 +302,7 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, { if (UsesSource) { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation); + Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); } if (UsesPattern) { @@ -313,6 +313,7 @@ DIB_4BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, Dest >>= 4; } } + sy++; } } return TRUE; diff --git a/reactos/subsys/win32k/dib/dib8bpp.c b/reactos/subsys/win32k/dib/dib8bpp.c index a68b2657120..62b9e2695b6 100644 --- a/reactos/subsys/win32k/dib/dib8bpp.c +++ b/reactos/subsys/win32k/dib/dib8bpp.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dib8bpp.c,v 1.6 2003/08/31 07:56:24 gvg Exp $ */ +/* $Id: dib8bpp.c,v 1.7 2003/10/06 16:25:53 gvg Exp $ */ #undef WIN32_LEAN_AND_MEAN #include #include @@ -301,7 +301,7 @@ DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, Source = 0; for (k = 0; k < 4; k++) { - Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + i + k, sy, ColorTranslation) << (k * 8)); + Source |= (DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left) + k, sy, ColorTranslation) << (k * 8)); } } if (UsesPattern) @@ -321,7 +321,7 @@ DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, { if (UsesSource) { - Source = DIB_GetSource(SourceSurf, SourceGDI, sx + i, sy, ColorTranslation); + Source = DIB_GetSource(SourceSurf, SourceGDI, sx + (i - DestRect->left), sy, ColorTranslation); } if (UsesPattern) { @@ -335,6 +335,7 @@ DIB_8BPP_BitBlt(SURFOBJ *DestSurf, SURFOBJ *SourceSurf, Dest >>= 8; } } + sy++; } } return TRUE; diff --git a/reactos/subsys/win32k/objects/cursoricon.c b/reactos/subsys/win32k/objects/cursoricon.c index 5a5d2be8f1d..6b7f1c79fbc 100644 --- a/reactos/subsys/win32k/objects/cursoricon.c +++ b/reactos/subsys/win32k/objects/cursoricon.c @@ -15,105 +15,8 @@ #define NDEBUG #include -BOOL FASTCALL IconCursor_InternalDelete( PICONCURSOROBJ pIconCursor ) -{ - ASSERT( pIconCursor ); - if( pIconCursor->ANDBitmap.bmBits ) - ExFreePool(pIconCursor->ANDBitmap.bmBits); - if( pIconCursor->XORBitmap.bmBits ) - ExFreePool(pIconCursor->XORBitmap.bmBits); - return TRUE; -} - - /* - * @implemented - */ -HICON -STDCALL -NtGdiCreateIcon(BOOL fIcon, - INT Width, - INT Height, - UINT Planes, - UINT BitsPerPel, - DWORD xHotspot, - DWORD yHotspot, - CONST VOID *ANDBits, - CONST VOID *XORBits) -{ - PICONCURSOROBJ icon; - HICON hIcon; - - Planes = (BYTE) Planes; - BitsPerPel = (BYTE) BitsPerPel; - - /* Check parameters */ - if (!Height || !Width) - { - return 0; - } - if (Planes != 1) - { - UNIMPLEMENTED; - return 0; - } - - /* Create the ICONCURSOROBJ object*/ - hIcon = ICONCURSOROBJ_AllocIconCursor (); - if (!hIcon) - { - DPRINT("NtGdiCreateIcon: ICONCURSOROBJ_AllocIconCursor(hIcon == 0x%x) returned 0\n", hIcon); - return 0; - } - - icon = ICONCURSOROBJ_LockIconCursor(hIcon); - - /* Set up the basic icon stuff */ - icon->fIcon = TRUE; - icon->xHotspot = xHotspot; - icon->yHotspot = yHotspot; - - /* Setup the icon mask and icon color bitmaps */ - icon->ANDBitmap.bmType = 0; - icon->ANDBitmap.bmWidth = Width; - icon->ANDBitmap.bmHeight = Height; - icon->ANDBitmap.bmPlanes = 1; - icon->ANDBitmap.bmBitsPixel = 1; - icon->ANDBitmap.bmWidthBytes = BITMAPOBJ_GetWidthBytes (Width, 1); - icon->ANDBitmap.bmBits = NULL; - - icon->XORBitmap.bmType = 0; - icon->XORBitmap.bmWidth = Width; - icon->XORBitmap.bmHeight = Height; - icon->XORBitmap.bmPlanes = Planes; - icon->XORBitmap.bmBitsPixel = BitsPerPel; - icon->XORBitmap.bmWidthBytes = BITMAPOBJ_GetWidthBytes (Width, BitsPerPel); - icon->XORBitmap.bmBits = NULL; - - /* allocate memory for the icon mask and icon color bitmaps, - this will be freed in IconCursor_InternalDelete */ - icon->ANDBitmap.bmBits = ExAllocatePool(PagedPool, Height * icon->ANDBitmap.bmWidthBytes); - icon->XORBitmap.bmBits = ExAllocatePool(PagedPool, Height * icon->XORBitmap.bmWidthBytes); - - /* set the bits of the mask and color bitmaps */ - if (ANDBits) - { - memcpy(icon->ANDBitmap.bmBits, (PVOID)ANDBits, Height * icon->ANDBitmap.bmWidthBytes); - } - - if (XORBits) - { - memcpy(icon->XORBitmap.bmBits, (PVOID)XORBits, Height * icon->XORBitmap.bmWidthBytes); - } - - ICONCURSOROBJ_UnlockIconCursor( hIcon ); - - return hIcon; -} - - -/* - * @implemented + * @unimplemented */ DWORD STDCALL @@ -125,43 +28,14 @@ NtUserGetIconInfo( HBITMAP *hbmMask, HBITMAP *hbmColor) { - PICONCURSOROBJ icon; + UNIMPLEMENTED - icon = ICONCURSOROBJ_LockIconCursor(hIcon); - - if (!icon) - { - DPRINT1("NtUserGetIconInfo: ICONCURSOROBJ_LockIconCursor(hIcon == 0x%x) returned 0\n", hIcon); - return FALSE; - } - - *fIcon = icon->fIcon ; - *xHotspot = icon->xHotspot; - *yHotspot = icon->yHotspot; - - *hbmMask = NtGdiCreateBitmap(icon->ANDBitmap.bmWidth, - icon->ANDBitmap.bmHeight, - icon->ANDBitmap.bmPlanes, - icon->ANDBitmap.bmBitsPixel, - icon->ANDBitmap.bmBits); - - *hbmColor = NtGdiCreateBitmap(icon->XORBitmap.bmWidth, - icon->XORBitmap.bmHeight, - icon->XORBitmap.bmPlanes, - icon->XORBitmap.bmBitsPixel, - icon->XORBitmap.bmBits); - - ICONCURSOROBJ_UnlockIconCursor(hIcon); - - if (!*hbmMask || !*hbmColor) - return FALSE; - - return TRUE; + return FALSE; } /* - * @implemented + * @unimplemented */ BOOL STDCALL @@ -171,26 +45,9 @@ NtUserGetIconSize( LONG *Width, LONG *Height) { - PICONCURSOROBJ icon; - - if (!hIcon || !Width || !Width) - return FALSE; + UNIMPLEMENTED - icon = ICONCURSOROBJ_LockIconCursor(hIcon); - - if (!icon) - { - DPRINT1("NtUserGetIconInfo: ICONCURSOROBJ_LockIconCursor() returned 0\n"); - return FALSE; - } - - if(fIcon) *fIcon = icon->fIcon; - *Width = icon->ANDBitmap.bmWidth; - *Width = icon->ANDBitmap.bmHeight; - - ICONCURSOROBJ_UnlockIconCursor(hIcon); - - return TRUE; + return FALSE; } diff --git a/reactos/subsys/win32k/objects/dc.c b/reactos/subsys/win32k/objects/dc.c index 5593bd14dec..af9afa389f7 100644 --- a/reactos/subsys/win32k/objects/dc.c +++ b/reactos/subsys/win32k/objects/dc.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: dc.c,v 1.86 2003/10/04 20:26:43 gvg Exp $ +/* $Id: dc.c,v 1.87 2003/10/06 16:25:53 gvg Exp $ * * DC.C - Device context functions * @@ -132,6 +132,7 @@ NtGdiCreateCompatableDC(HDC hDC) HDC hNewDC; HRGN hVisRgn; BITMAPOBJ *pb; + PSURFGDI SurfGDI; if (hDC == NULL) { @@ -166,6 +167,8 @@ NtGdiCreateCompatableDC(HDC hDC) sizeof(NewDC->FillPatternSurfaces)); NewDC->GDIInfo = &PrimarySurface.GDIInfo; NewDC->DevInfo = &PrimarySurface.DevInfo; + SurfGDI = (PSURFGDI)AccessInternalObject((ULONG) PrimarySurface.Handle); + NewDC->w.bitsPerPixel = SurfGDI->BitsPerPixel; } else { @@ -176,6 +179,7 @@ NtGdiCreateCompatableDC(HDC hDC) sizeof OrigDC->FillPatternSurfaces); NewDC->GDIInfo = OrigDC->GDIInfo; NewDC->DevInfo = OrigDC->DevInfo; + NewDC->w.bitsPerPixel = OrigDC->w.bitsPerPixel; } /* DriverName is copied in the AllocDC routine */ @@ -197,7 +201,7 @@ NtGdiCreateCompatableDC(HDC hDC) } /* Create default bitmap */ - if (!(hBitmap = NtGdiCreateBitmap( 1, 1, 1, 1, NULL ))) + if (!(hBitmap = NtGdiCreateBitmap( 1, 1, 1, NewDC->w.bitsPerPixel, NULL ))) { DC_UnlockDc( hDC ); DC_UnlockDc( hNewDC ); @@ -205,7 +209,6 @@ NtGdiCreateCompatableDC(HDC hDC) return NULL; } NewDC->w.flags = DC_MEMORY; - NewDC->w.bitsPerPixel = 1; NewDC->w.hBitmap = hBitmap; NewDC->w.hFirstBitmap = hBitmap; pb = BITMAPOBJ_LockBitmap(hBitmap);