From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Huw Davies huw@codeweavers.com --- dlls/gdi32/bitblt.c | 8 ++++---- dlls/gdi32/bitmap.c | 30 ++++++++++++------------------ dlls/gdi32/objects.c | 13 +++++++++++++ include/ntgdi.h | 1 + 4 files changed, 30 insertions(+), 22 deletions(-)
diff --git a/dlls/gdi32/bitblt.c b/dlls/gdi32/bitblt.c index 54c923236ee..dcc2c932453 100644 --- a/dlls/gdi32/bitblt.c +++ b/dlls/gdi32/bitblt.c @@ -789,7 +789,7 @@ BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest,
/* make bitmap */ hDC1 = NtGdiCreateCompatibleDC( hdcDest ); - hBitmap1 = CreateCompatibleBitmap(hdcDest, nWidth, nHeight); + hBitmap1 = NtGdiCreateCompatibleBitmap( hdcDest, nWidth, nHeight ); hOldBitmap1 = NtGdiSelectBitmap(hDC1, hBitmap1);
/* draw using bkgnd rop */ @@ -800,7 +800,7 @@ BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest,
/* make bitmap */ hDC2 = NtGdiCreateCompatibleDC( hdcDest ); - hBitmap2 = CreateCompatibleBitmap(hdcDest, nWidth, nHeight); + hBitmap2 = NtGdiCreateCompatibleBitmap( hdcDest, nWidth, nHeight ); hOldBitmap2 = NtGdiSelectBitmap(hDC2, hBitmap2);
/* draw using foregnd rop */ @@ -879,7 +879,7 @@ BOOL WINAPI GdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest, info.bmiHeader.biCompression = BI_RGB; bmpWork = CreateDIBSection( 0, &info, DIB_RGB_COLORS, NULL, NULL, 0 ); } - else bmpWork = CreateCompatibleBitmap(hdcDest, widthDest, heightDest); + else bmpWork = NtGdiCreateCompatibleBitmap( hdcDest, widthDest, heightDest ); oldWork = NtGdiSelectBitmap(hdcWork, bmpWork); if(!StretchBlt(hdcWork, 0, 0, widthDest, heightDest, hdcSrc, xSrc, ySrc, widthSrc, heightSrc, SRCCOPY)) { TRACE("Failed to stretch\n"); @@ -889,7 +889,7 @@ BOOL WINAPI GdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest,
/* Create mask */ hdcMask = NtGdiCreateCompatibleDC( hdcDest ); - bmpMask = CreateCompatibleBitmap(hdcMask, widthDest, heightDest); + bmpMask = NtGdiCreateCompatibleBitmap( hdcMask, widthDest, heightDest ); oldMask = NtGdiSelectBitmap(hdcMask, bmpMask); if(!BitBlt(hdcMask, 0, 0, widthDest, heightDest, hdcWork, 0, 0, SRCCOPY)) { TRACE("Failed to create mask\n"); diff --git a/dlls/gdi32/bitmap.c b/dlls/gdi32/bitmap.c index 8866ec0af8a..472efdec295 100644 --- a/dlls/gdi32/bitmap.c +++ b/dlls/gdi32/bitmap.c @@ -44,44 +44,38 @@ static const struct gdi_obj_funcs bitmap_funcs =
/****************************************************************************** - * CreateCompatibleBitmap [GDI32.@] + * NtGdiCreateCompatibleBitmap (win32u.@) * * Creates a bitmap compatible with the DC. - * - * PARAMS - * hdc [I] Handle to device context - * width [I] Width of bitmap - * height [I] Height of bitmap - * - * RETURNS - * Success: Handle to bitmap - * Failure: 0 */ -HBITMAP WINAPI CreateCompatibleBitmap( HDC hdc, INT width, INT height) +HBITMAP WINAPI NtGdiCreateCompatibleBitmap( HDC hdc, INT width, INT height ) { char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; BITMAPINFO *bi = (BITMAPINFO *)buffer; DIBSECTION dib;
- TRACE("(%p,%d,%d)\n", hdc, width, height); + TRACE( "(%p,%d,%d)\n", hdc, width, height ); + + if (!width || !height) return 0;
if (GetObjectType( hdc ) != OBJ_MEMDC) - return CreateBitmap( width, height, - GetDeviceCaps(hdc, PLANES), GetDeviceCaps(hdc, BITSPIXEL), NULL ); + return NtGdiCreateBitmap( width, height, + NtGdiGetDeviceCaps( hdc, PLANES ), + NtGdiGetDeviceCaps( hdc, BITSPIXEL ), NULL );
- switch (GetObjectW( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(dib), &dib )) + switch (NtGdiExtGetObjectW( GetCurrentObject( hdc, OBJ_BITMAP ), sizeof(dib), &dib )) { case sizeof(BITMAP): /* A device-dependent bitmap is selected in the DC */ - return CreateBitmap( width, height, dib.dsBm.bmPlanes, dib.dsBm.bmBitsPixel, NULL ); + return NtGdiCreateBitmap( width, height, dib.dsBm.bmPlanes, dib.dsBm.bmBitsPixel, NULL );
case sizeof(DIBSECTION): /* A DIB section is selected in the DC */ bi->bmiHeader = dib.dsBmih; bi->bmiHeader.biWidth = width; bi->bmiHeader.biHeight = height; if (dib.dsBmih.biCompression == BI_BITFIELDS) /* copy the color masks */ - memcpy(bi->bmiColors, dib.dsBitfields, sizeof(dib.dsBitfields)); + memcpy( bi->bmiColors, dib.dsBitfields, sizeof(dib.dsBitfields) ); else if (dib.dsBmih.biBitCount <= 8) /* copy the color table */ - GetDIBColorTable(hdc, 0, 256, bi->bmiColors); + NtGdiDoPalette( hdc, 0, 256, bi->bmiColors, NtGdiGetDIBColorTable, FALSE ); return CreateDIBSection( hdc, bi, DIB_RGB_COLORS, NULL, NULL, 0 );
default: diff --git a/dlls/gdi32/objects.c b/dlls/gdi32/objects.c index 70cf1d6a0a5..58ac32ed576 100644 --- a/dlls/gdi32/objects.c +++ b/dlls/gdi32/objects.c @@ -524,6 +524,19 @@ HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes, return NtGdiCreateBitmap( width, height, planes, bpp, bits ); }
+/****************************************************************************** + * CreateCompatibleBitmap (GDI32.@) + * + * Creates a bitmap compatible with the DC. + */ +HBITMAP WINAPI CreateCompatibleBitmap( HDC hdc, INT width, INT height ) +{ + if (!width || !height) + return GetStockObject( STOCK_LAST + 1 ); /* default 1x1 bitmap */ + + return NtGdiCreateCompatibleBitmap( hdc, width, height ); +} + /****************************************************************************** * CreateDiscardableBitmap (GDI32.@) * diff --git a/include/ntgdi.h b/include/ntgdi.h index f8dd944a185..25ac5ee505f 100644 --- a/include/ntgdi.h +++ b/include/ntgdi.h @@ -216,6 +216,7 @@ INT WINAPI NtGdiCombineRgn( HRGN dest, HRGN src1, HRGN src2, INT mode ); BOOL WINAPI NtGdiComputeXformCoefficients( HDC hdc ); HBITMAP WINAPI NtGdiCreateBitmap( INT width, INT height, UINT planes, UINT bpp, const void *bits ); +HBITMAP WINAPI NtGdiCreateCompatibleBitmap( HDC hdc, INT width, INT height ); HPALETTE WINAPI NtGdiCreateHalftonePalette( HDC hdc ); HBRUSH WINAPI NtGdiCreateHatchBrushInternal( INT style, COLORREF color, BOOL pen ); HDC WINAPI NtGdiCreateMetafileDC( HDC hdc );