gdi: Fix GetObject for bitmaps.

- GetObject(): Set the bmBits member of the BITMAP structure to NULL
  for device-dependent bitmaps.
- New test case.
This commit is contained in:
Michael Kaufmann 2006-05-09 15:51:12 +02:00 committed by Alexandre Julliard
parent 6c233ef205
commit f6097f5b51
5 changed files with 28 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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();
}

View File

@ -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 */
{

View File

@ -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