Commit f6097f5b authored by Michael Kaufmann's avatar Michael Kaufmann Committed by Alexandre Julliard

gdi: Fix GetObject for bitmaps.

- GetObject(): Set the bmBits member of the BITMAP structure to NULL for device-dependent bitmaps. - New test case.
parent 6c233ef2
......@@ -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);
}
}
......
......@@ -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);
......
......@@ -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();
}
......@@ -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 */
{
......
......@@ -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
......
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