Commit 9c03e8ae authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

gdi32: Use NtGdiCreateCompatibleBitmap for CreateCompatibleBitmap.

parent e4bb7972
...@@ -789,7 +789,7 @@ BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest, ...@@ -789,7 +789,7 @@ BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest,
/* make bitmap */ /* make bitmap */
hDC1 = NtGdiCreateCompatibleDC( hdcDest ); hDC1 = NtGdiCreateCompatibleDC( hdcDest );
hBitmap1 = CreateCompatibleBitmap(hdcDest, nWidth, nHeight); hBitmap1 = NtGdiCreateCompatibleBitmap( hdcDest, nWidth, nHeight );
hOldBitmap1 = NtGdiSelectBitmap(hDC1, hBitmap1); hOldBitmap1 = NtGdiSelectBitmap(hDC1, hBitmap1);
/* draw using bkgnd rop */ /* draw using bkgnd rop */
...@@ -800,7 +800,7 @@ BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest, ...@@ -800,7 +800,7 @@ BOOL WINAPI MaskBlt(HDC hdcDest, INT nXDest, INT nYDest,
/* make bitmap */ /* make bitmap */
hDC2 = NtGdiCreateCompatibleDC( hdcDest ); hDC2 = NtGdiCreateCompatibleDC( hdcDest );
hBitmap2 = CreateCompatibleBitmap(hdcDest, nWidth, nHeight); hBitmap2 = NtGdiCreateCompatibleBitmap( hdcDest, nWidth, nHeight );
hOldBitmap2 = NtGdiSelectBitmap(hDC2, hBitmap2); hOldBitmap2 = NtGdiSelectBitmap(hDC2, hBitmap2);
/* draw using foregnd rop */ /* draw using foregnd rop */
...@@ -879,7 +879,7 @@ BOOL WINAPI GdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest, ...@@ -879,7 +879,7 @@ BOOL WINAPI GdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest,
info.bmiHeader.biCompression = BI_RGB; info.bmiHeader.biCompression = BI_RGB;
bmpWork = CreateDIBSection( 0, &info, DIB_RGB_COLORS, NULL, NULL, 0 ); 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); oldWork = NtGdiSelectBitmap(hdcWork, bmpWork);
if(!StretchBlt(hdcWork, 0, 0, widthDest, heightDest, hdcSrc, xSrc, ySrc, widthSrc, heightSrc, SRCCOPY)) { if(!StretchBlt(hdcWork, 0, 0, widthDest, heightDest, hdcSrc, xSrc, ySrc, widthSrc, heightSrc, SRCCOPY)) {
TRACE("Failed to stretch\n"); TRACE("Failed to stretch\n");
...@@ -889,7 +889,7 @@ BOOL WINAPI GdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest, ...@@ -889,7 +889,7 @@ BOOL WINAPI GdiTransparentBlt( HDC hdcDest, int xDest, int yDest, int widthDest,
/* Create mask */ /* Create mask */
hdcMask = NtGdiCreateCompatibleDC( hdcDest ); hdcMask = NtGdiCreateCompatibleDC( hdcDest );
bmpMask = CreateCompatibleBitmap(hdcMask, widthDest, heightDest); bmpMask = NtGdiCreateCompatibleBitmap( hdcMask, widthDest, heightDest );
oldMask = NtGdiSelectBitmap(hdcMask, bmpMask); oldMask = NtGdiSelectBitmap(hdcMask, bmpMask);
if(!BitBlt(hdcMask, 0, 0, widthDest, heightDest, hdcWork, 0, 0, SRCCOPY)) { if(!BitBlt(hdcMask, 0, 0, widthDest, heightDest, hdcWork, 0, 0, SRCCOPY)) {
TRACE("Failed to create mask\n"); TRACE("Failed to create mask\n");
......
...@@ -44,44 +44,38 @@ static const struct gdi_obj_funcs bitmap_funcs = ...@@ -44,44 +44,38 @@ static const struct gdi_obj_funcs bitmap_funcs =
/****************************************************************************** /******************************************************************************
* CreateCompatibleBitmap [GDI32.@] * NtGdiCreateCompatibleBitmap (win32u.@)
* *
* Creates a bitmap compatible with the DC. * 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] )]; char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )];
BITMAPINFO *bi = (BITMAPINFO *)buffer; BITMAPINFO *bi = (BITMAPINFO *)buffer;
DIBSECTION dib; 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) if (GetObjectType( hdc ) != OBJ_MEMDC)
return CreateBitmap( width, height, return NtGdiCreateBitmap( width, height,
GetDeviceCaps(hdc, PLANES), GetDeviceCaps(hdc, BITSPIXEL), NULL ); 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 */ 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 */ case sizeof(DIBSECTION): /* A DIB section is selected in the DC */
bi->bmiHeader = dib.dsBmih; bi->bmiHeader = dib.dsBmih;
bi->bmiHeader.biWidth = width; bi->bmiHeader.biWidth = width;
bi->bmiHeader.biHeight = height; bi->bmiHeader.biHeight = height;
if (dib.dsBmih.biCompression == BI_BITFIELDS) /* copy the color masks */ 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 */ 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 ); return CreateDIBSection( hdc, bi, DIB_RGB_COLORS, NULL, NULL, 0 );
default: default:
......
...@@ -525,6 +525,19 @@ HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes, ...@@ -525,6 +525,19 @@ HBITMAP WINAPI CreateBitmap( INT width, INT height, UINT planes,
} }
/****************************************************************************** /******************************************************************************
* 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.@) * CreateDiscardableBitmap (GDI32.@)
* *
* Creates a discardable bitmap. * Creates a discardable bitmap.
......
...@@ -216,6 +216,7 @@ INT WINAPI NtGdiCombineRgn( HRGN dest, HRGN src1, HRGN src2, INT mode ); ...@@ -216,6 +216,7 @@ INT WINAPI NtGdiCombineRgn( HRGN dest, HRGN src1, HRGN src2, INT mode );
BOOL WINAPI NtGdiComputeXformCoefficients( HDC hdc ); BOOL WINAPI NtGdiComputeXformCoefficients( HDC hdc );
HBITMAP WINAPI NtGdiCreateBitmap( INT width, INT height, UINT planes, HBITMAP WINAPI NtGdiCreateBitmap( INT width, INT height, UINT planes,
UINT bpp, const void *bits ); UINT bpp, const void *bits );
HBITMAP WINAPI NtGdiCreateCompatibleBitmap( HDC hdc, INT width, INT height );
HPALETTE WINAPI NtGdiCreateHalftonePalette( HDC hdc ); HPALETTE WINAPI NtGdiCreateHalftonePalette( HDC hdc );
HBRUSH WINAPI NtGdiCreateHatchBrushInternal( INT style, COLORREF color, BOOL pen ); HBRUSH WINAPI NtGdiCreateHatchBrushInternal( INT style, COLORREF color, BOOL pen );
HDC WINAPI NtGdiCreateMetafileDC( HDC hdc ); HDC WINAPI NtGdiCreateMetafileDC( HDC hdc );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment