Jacek Caban : gdi32: Use NtGdiCreateDIBitmapInternal for CreateDIBitmap.
Alexandre Julliard
julliard at winehq.org
Tue Aug 31 15:40:22 CDT 2021
Module: wine
Branch: master
Commit: b2522bfb90e23ed84d1ec2dc03069a28d937b32f
URL: https://source.winehq.org/git/wine.git/?a=commit;h=b2522bfb90e23ed84d1ec2dc03069a28d937b32f
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Aug 31 13:18:36 2021 +0100
gdi32: Use NtGdiCreateDIBitmapInternal for CreateDIBitmap.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/gdi32/dib.c | 29 ++++++++++++-----------------
dlls/gdi32/objects.c | 31 ++++++++++++++++++++++++++++++-
include/ntgdi.h | 4 ++++
3 files changed, 46 insertions(+), 18 deletions(-)
diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 976e6060955..fa736223aae 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -1418,35 +1418,30 @@ done:
/***********************************************************************
- * CreateDIBitmap (GDI32.@)
+ * NtGdiCreateDIBitmapInternal (win32u.@)
*
* Creates a DDB (device dependent bitmap) from a DIB.
* The DDB will have the same color depth as the reference DC.
*/
-HBITMAP WINAPI CreateDIBitmap( HDC hdc, const BITMAPINFOHEADER *header,
- DWORD init, LPCVOID bits, const BITMAPINFO *data,
- UINT coloruse )
+HBITMAP WINAPI NtGdiCreateDIBitmapInternal( HDC hdc, INT width, INT height, DWORD init,
+ const void *bits, const BITMAPINFO *data,
+ UINT coloruse, UINT max_info, UINT max_bits,
+ ULONG flags, HANDLE xform )
{
- BITMAPINFOHEADER info;
HBITMAP handle;
- LONG height;
- if (!bitmapinfoheader_from_user_bitmapinfo( &info, header )) return 0;
- if (info.biCompression == BI_JPEG || info.biCompression == BI_PNG) return 0;
- if (coloruse > DIB_PAL_COLORS + 1) return 0;
- if (info.biWidth < 0) return 0;
+ if (coloruse > DIB_PAL_COLORS + 1 || width < 0) return 0;
/* Top-down DIBs have a negative height */
- height = abs( info.biHeight );
+ height = abs( height );
- TRACE("hdc=%p, header=%p, init=%u, bits=%p, data=%p, coloruse=%u (bitmap: width=%d, height=%d, bpp=%u, compr=%u)\n",
- hdc, header, init, bits, data, coloruse, info.biWidth, info.biHeight,
- info.biBitCount, info.biCompression);
+ TRACE( "hdc=%p, init=%u, bits=%p, data=%p, coloruse=%u (bitmap: width=%d, height=%d)\n",
+ hdc, init, bits, data, coloruse, width, height );
if (hdc == NULL)
- handle = CreateBitmap( info.biWidth, height, 1, 1, NULL );
+ handle = NtGdiCreateBitmap( width, height, 1, 1, NULL );
else
- handle = CreateCompatibleBitmap( hdc, info.biWidth, height );
+ handle = NtGdiCreateCompatibleBitmap( hdc, width, height );
if (handle)
{
@@ -1454,7 +1449,7 @@ HBITMAP WINAPI CreateDIBitmap( HDC hdc, const BITMAPINFOHEADER *header,
{
if (SetDIBits( hdc, handle, 0, height, bits, data, coloruse ) == 0)
{
- DeleteObject( handle );
+ NtGdiDeleteObjectApp( handle );
handle = 0;
}
}
diff --git a/dlls/gdi32/objects.c b/dlls/gdi32/objects.c
index 03985737b51..055994a1680 100644
--- a/dlls/gdi32/objects.c
+++ b/dlls/gdi32/objects.c
@@ -725,7 +725,36 @@ UINT WINAPI GetSystemPaletteEntries( HDC hdc, UINT start, UINT count, PALETTEENT
}
/***********************************************************************
- * GetDIBits (GDI32.@)
+ * CreateDIBitmap (GDI32.@)
+ */
+HBITMAP WINAPI CreateDIBitmap( HDC hdc, const BITMAPINFOHEADER *header, DWORD init,
+ const void *bits, const BITMAPINFO *data, UINT coloruse )
+{
+ int width, height;
+
+ if (!header) return 0;
+
+ if (header->biSize == sizeof(BITMAPCOREHEADER))
+ {
+ const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)header;
+ width = core->bcWidth;
+ height = core->bcHeight;
+ }
+ else if (header->biSize >= sizeof(BITMAPINFOHEADER))
+ {
+ if (header->biCompression == BI_JPEG || header->biCompression == BI_PNG) return 0;
+ width = header->biWidth;
+ height = header->biHeight;
+ }
+ else return 0;
+
+ if (!width || !height) return GetStockObject( STOCK_LAST + 1 ); /* default 1x1 bitmap */
+ return NtGdiCreateDIBitmapInternal( hdc, width, height, init, bits, data, coloruse,
+ 0, 0, 0, 0 );
+}
+
+/***********************************************************************
+ * GetDIBits (win32u.@)
*/
INT WINAPI DECLSPEC_HOTPATCH GetDIBits( HDC hdc, HBITMAP hbitmap, UINT startscan, UINT lines,
void *bits, BITMAPINFO *info, UINT coloruse )
diff --git a/include/ntgdi.h b/include/ntgdi.h
index fbe168a73bd..72427a20295 100644
--- a/include/ntgdi.h
+++ b/include/ntgdi.h
@@ -218,6 +218,10 @@ 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 );
+HBITMAP WINAPI NtGdiCreateDIBitmapInternal( HDC hdc, INT width, INT height, DWORD init,
+ const void *bits, const BITMAPINFO *data,
+ UINT coloruse, UINT max_info, UINT max_bits,
+ ULONG flags, HANDLE xform );
HPALETTE WINAPI NtGdiCreateHalftonePalette( HDC hdc );
HBRUSH WINAPI NtGdiCreateHatchBrushInternal( INT style, COLORREF color, BOOL pen );
HDC WINAPI NtGdiCreateMetafileDC( HDC hdc );
More information about the wine-cvs
mailing list