From f6097f5b5199e15544be7d2861d6461e6081ac18 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Tue, 9 May 2006 15:51:12 +0200 Subject: [PATCH] gdi: Fix GetObject for bitmaps. - GetObject(): Set the bmBits member of the BITMAP structure to NULL for device-dependent bitmaps. - New test case. --- dlls/gdi/bitmap.c | 4 +++- dlls/gdi/gdi_private.h | 2 +- dlls/gdi/tests/bitmap.c | 20 ++++++++++++++++++++ dlls/x11drv/bitmap.c | 6 +++--- dlls/x11drv/winex11.drv.spec | 2 +- 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/dlls/gdi/bitmap.c b/dlls/gdi/bitmap.c index 3186443419..4d5cd71973 100644 --- a/dlls/gdi/bitmap.c +++ b/dlls/gdi/bitmap.c @@ -528,7 +528,8 @@ BOOL BITMAP_SetOwnerDC( HBITMAP hbitmap, DC *dc ) ret = TRUE; if (!bitmap->funcs) /* not owned by a DC yet */ { - if (dc->funcs->pCreateBitmap) ret = dc->funcs->pCreateBitmap( dc->physDev, hbitmap ); + if (dc->funcs->pCreateBitmap) ret = dc->funcs->pCreateBitmap( dc->physDev, hbitmap, + bitmap->bitmap.bmBits ); if (ret) bitmap->funcs = dc->funcs; } else if (bitmap->funcs != dc->funcs) @@ -705,6 +706,7 @@ static INT BITMAP_GetObject( HGDIOBJ handle, void *obj, INT count, LPVOID buffer else { memcpy( buffer, &bmp->bitmap, sizeof(BITMAP) ); + ((BITMAP *) buffer)->bmBits = NULL; return sizeof(BITMAP); } } diff --git a/dlls/gdi/gdi_private.h b/dlls/gdi/gdi_private.h index dfdb0085fe..fd06263238 100644 --- a/dlls/gdi/gdi_private.h +++ b/dlls/gdi/gdi_private.h @@ -72,7 +72,7 @@ typedef struct tagDC_FUNCS INT (*pChoosePixelFormat)(PHYSDEV,const PIXELFORMATDESCRIPTOR *); BOOL (*pChord)(PHYSDEV,INT,INT,INT,INT,INT,INT,INT,INT); BOOL (*pCloseFigure)(PHYSDEV); - BOOL (*pCreateBitmap)(PHYSDEV,HBITMAP); + BOOL (*pCreateBitmap)(PHYSDEV,HBITMAP,LPVOID); BOOL (*pCreateDC)(HDC,PHYSDEV *,LPCWSTR,LPCWSTR,LPCWSTR,const DEVMODEW*); HBITMAP (*pCreateDIBSection)(PHYSDEV,HBITMAP,const BITMAPINFO *,UINT); BOOL (*pDeleteBitmap)(HBITMAP); diff --git a/dlls/gdi/tests/bitmap.c b/dlls/gdi/tests/bitmap.c index ff16f8d1fb..af7a0d279f 100644 --- a/dlls/gdi/tests/bitmap.c +++ b/dlls/gdi/tests/bitmap.c @@ -1001,6 +1001,25 @@ static void test_bitmap(void) DeleteDC(hdc); } +static void test_bmBits(void) +{ + BYTE bits[4]; + HBITMAP hbmp; + BITMAP bmp; + + memset(bits, 0, sizeof(bits)); + hbmp = CreateBitmap(2, 2, 1, 4, bits); + ok(hbmp != NULL, "CreateBitmap failed\n"); + + memset(&bmp, 0xFF, sizeof(bmp)); + ok(GetObject(hbmp, sizeof(bmp), &bmp) == sizeof(bmp), + "GetObject failed or returned a wrong structure size\n"); + ok(!bmp.bmBits, "bmBits must be NULL for device-dependent bitmaps\n"); + + DeleteObject(hbmp); +} + + START_TEST(bitmap) { is_win9x = GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC) == 0; @@ -1009,4 +1028,5 @@ START_TEST(bitmap) test_dibsections(); test_mono_dibsection(); test_bitmap(); + test_bmBits(); } diff --git a/dlls/x11drv/bitmap.c b/dlls/x11drv/bitmap.c index 060102f74e..0f958d7e9a 100644 --- a/dlls/x11drv/bitmap.c +++ b/dlls/x11drv/bitmap.c @@ -106,7 +106,7 @@ HBITMAP X11DRV_SelectBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap ) * * Returns TRUE on success else FALSE */ -BOOL X11DRV_CreateBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap ) +BOOL X11DRV_CreateBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, LPVOID bmBits ) { X_PHYSBITMAP *physBitmap; BITMAP bitmap; @@ -145,9 +145,9 @@ BOOL X11DRV_CreateBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap ) return FALSE; } - if (bitmap.bmBits) /* Set bitmap bits */ + if (bmBits) /* Set bitmap bits */ { - X11DRV_SetBitmapBits( hbitmap, bitmap.bmBits, bitmap.bmHeight * bitmap.bmWidthBytes ); + X11DRV_SetBitmapBits( hbitmap, bmBits, bitmap.bmHeight * bitmap.bmWidthBytes ); } else /* else clear the bitmap */ { diff --git a/dlls/x11drv/winex11.drv.spec b/dlls/x11drv/winex11.drv.spec index 1a835a9b54..9c33ce4803 100644 --- a/dlls/x11drv/winex11.drv.spec +++ b/dlls/x11drv/winex11.drv.spec @@ -5,7 +5,7 @@ @ cdecl BitBlt(ptr long long long long ptr long long long) X11DRV_BitBlt @ cdecl ChoosePixelFormat(ptr ptr) X11DRV_ChoosePixelFormat @ cdecl Chord(ptr long long long long long long long long) X11DRV_Chord -@ cdecl CreateBitmap(ptr long) X11DRV_CreateBitmap +@ cdecl CreateBitmap(ptr long ptr) X11DRV_CreateBitmap @ cdecl CreateDC(long ptr wstr wstr wstr ptr) X11DRV_CreateDC @ cdecl CreateDIBSection(ptr long ptr long) X11DRV_CreateDIBSection @ cdecl DeleteBitmap(long) X11DRV_DeleteBitmap -- 2.32.0.93.g670b81a890