From ed7952a360d6c26386bbae4c1b1b35aa8fa4a706 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Mon, 29 Dec 2014 13:11:59 +0000 Subject: [PATCH] [WIN32K] - Implement NtGdiGetObjectBitmapHandle - Set BR_IS_DIBPALCOLORS in IntGdiCreateDIBBrush svn path=/trunk/; revision=65884 --- reactos/win32ss/gdi/eng/stubs.c | 38 -------------- reactos/win32ss/gdi/ntgdi/brush.c | 85 ++++++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 44 deletions(-) diff --git a/reactos/win32ss/gdi/eng/stubs.c b/reactos/win32ss/gdi/eng/stubs.c index d54fd6f6df5..9a567234f70 100644 --- a/reactos/win32ss/gdi/eng/stubs.c +++ b/reactos/win32ss/gdi/eng/stubs.c @@ -923,18 +923,6 @@ NtGdiGetUFI( return FALSE; } -/* - * @unimplemented - */ -HBRUSH -APIENTRY -NtGdiClearBrushAttributes( - IN HBRUSH hbm, - IN DWORD dwFlags) -{ - UNIMPLEMENTED; - return NULL; -} /* * @unimplemented @@ -1256,19 +1244,6 @@ NtGdiGetLinkedUFIs( return 0; } -/* - * @unimplemented - */ -HBITMAP -APIENTRY -NtGdiGetObjectBitmapHandle( - IN HBRUSH hbr, - OUT UINT *piUsage) -{ - UNIMPLEMENTED; - return 0; -} - /* * @unimplemented */ @@ -1410,19 +1385,6 @@ NtGdiSetupPublicCFONT( return 0; } -/* - * @unimplemented - */ -HBRUSH -APIENTRY -NtGdiSetBrushAttributes( - IN HBRUSH hbm, - IN DWORD dwFlags) -{ - UNIMPLEMENTED; - return NULL; -} - /* * @unimplemented */ diff --git a/reactos/win32ss/gdi/ntgdi/brush.c b/reactos/win32ss/gdi/ntgdi/brush.c index b079a288046..486fb4331eb 100644 --- a/reactos/win32ss/gdi/ntgdi/brush.c +++ b/reactos/win32ss/gdi/ntgdi/brush.c @@ -200,10 +200,10 @@ BRUSH_GetObject(PBRUSH pbrush, INT cjSize, LPLOGBRUSH plogbrush) HBRUSH APIENTRY IntGdiCreateDIBBrush( - CONST BITMAPINFO *BitmapInfo, - UINT ColorSpec, + const BITMAPINFO *BitmapInfo, + UINT uUsage, UINT BitmapInfoSize, - CONST VOID *PackedDIB) + const VOID* pvClient) { HBRUSH hBrush; PBRUSH pbrush; @@ -217,9 +217,9 @@ IntGdiCreateDIBBrush( return NULL; } - DataPtr = (ULONG_PTR)BitmapInfo + DIB_BitmapInfoSize(BitmapInfo, ColorSpec); + DataPtr = (ULONG_PTR)BitmapInfo + DIB_BitmapInfoSize(BitmapInfo, uUsage); - hPattern = DIB_CreateDIBSection(NULL, BitmapInfo, ColorSpec, &pvDIBits, NULL, 0, 0); + hPattern = DIB_CreateDIBSection(NULL, BitmapInfo, uUsage, &pvDIBits, NULL, 0, 0); if (hPattern == NULL) { EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -241,8 +241,10 @@ IntGdiCreateDIBBrush( hBrush = pbrush->BaseObject.hHmgr; pbrush->flAttrs |= BR_IS_BITMAP | BR_IS_DIB; + if (uUsage == DIB_PAL_COLORS) + pbrush->flAttrs |= BR_IS_DIBPALCOLORS; pbrush->hbmPattern = hPattern; - pbrush->hbmClient = (HBITMAP)PackedDIB; + pbrush->hbmClient = (HBITMAP)pvClient; /* FIXME: Fill in the rest of fields!!! */ GreSetObjectOwner(hPattern, GDI_OBJ_HMGR_PUBLIC); @@ -460,5 +462,76 @@ NtGdiCreateSolidBrush(COLORREF Color, return IntGdiCreateSolidBrush(Color); } +HBITMAP +APIENTRY +NtGdiGetObjectBitmapHandle( + _In_ HBRUSH hbr, + _Out_ UINT *piUsage) +{ + HBITMAP hbmPattern; + PBRUSH pbr; + + /* Lock the brush */ + pbr = BRUSH_ShareLockBrush(hbr); + if (pbr == NULL) + { + DPRINT1("Could not lock brush\n"); + return NULL; + } + + /* Get the pattern bitmap handle */ + hbmPattern = pbr->hbmPattern; + + _SEH2_TRY + { + ProbeForWrite(piUsage, sizeof(*piUsage), sizeof(*piUsage)); + + /* Set usage according to flags */ + if (pbr->flAttrs & BR_IS_DIBPALCOLORS) + *piUsage = DIB_PAL_COLORS; + else + *piUsage = DIB_RGB_COLORS; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + DPRINT1("Got exception!\n"); + hbmPattern = NULL; + } + _SEH2_END; + + /* Unlock the brush */ + BRUSH_ShareUnlockBrush(pbr); + + /* Return the pattern bitmap handle */ + return hbmPattern; +} + +/* + * @unimplemented + */ +HBRUSH +APIENTRY +NtGdiSetBrushAttributes( + IN HBRUSH hbm, + IN DWORD dwFlags) +{ + UNIMPLEMENTED; + return NULL; +} + + +/* + * @unimplemented + */ +HBRUSH +APIENTRY +NtGdiClearBrushAttributes( + IN HBRUSH hbr, + IN DWORD dwFlags) +{ + UNIMPLEMENTED; + return NULL; +} + /* EOF */