Fix GetObject for bitmaps
Michael Kaufmann
hallo at michael-kaufmann.ch
Tue May 9 08:51:12 CDT 2006
GetObject() for bitmaps returns a BITMAP structure. Its bmBits member
must be NULL for device-dependent bitmaps, probably because the bits are
stored on the video card. Device-independent bitmaps (DIBs) return a
non-null pointer to the bitmap bits. References: MSDN and
http://www.codeproject.com/bitmap/DFB_vs_DIB.asp
I hope that it's OK to change the driver interface a bit, because X11DRV
can't use GetObject anymore to get the bitmap's bits.
Changelog:
- GetObject(): Set the bmBits member of the BITMAP structure to NULL for
device-dependent bitmaps
- New test case
-------------- next part --------------
Index: dlls/gdi/bitmap.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/bitmap.c,v
retrieving revision 1.13
diff -u -r1.13 bitmap.c
--- dlls/gdi/bitmap.c 5 Apr 2006 18:34:01 -0000 1.13
+++ dlls/gdi/bitmap.c 9 May 2006 13:19:36 -0000
@@ -528,7 +528,8 @@
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 @@
else
{
memcpy( buffer, &bmp->bitmap, sizeof(BITMAP) );
+ ((BITMAP *) buffer)->bmBits = NULL;
return sizeof(BITMAP);
}
}
Index: dlls/gdi/gdi_private.h
===================================================================
RCS file: /home/wine/wine/dlls/gdi/gdi_private.h,v
retrieving revision 1.32
diff -u -r1.32 gdi_private.h
--- dlls/gdi/gdi_private.h 19 Apr 2006 18:16:36 -0000 1.32
+++ dlls/gdi/gdi_private.h 9 May 2006 13:19:37 -0000
@@ -72,7 +72,7 @@
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);
Index: dlls/gdi/tests/bitmap.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/tests/bitmap.c,v
retrieving revision 1.14
diff -u -r1.14 bitmap.c
--- dlls/gdi/tests/bitmap.c 7 Apr 2006 18:31:16 -0000 1.14
+++ dlls/gdi/tests/bitmap.c 9 May 2006 13:19:37 -0000
@@ -1001,6 +1001,25 @@
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 @@
test_dibsections();
test_mono_dibsection();
test_bitmap();
+ test_bmBits();
}
Index: dlls/x11drv/bitmap.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/bitmap.c,v
retrieving revision 1.19
diff -u -r1.19 bitmap.c
--- dlls/x11drv/bitmap.c 20 Mar 2006 21:36:57 -0000 1.19
+++ dlls/x11drv/bitmap.c 9 May 2006 13:19:48 -0000
@@ -106,7 +106,7 @@
*
* 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 @@
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 */
{
Index: dlls/x11drv/winex11.drv.spec
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/winex11.drv.spec,v
retrieving revision 1.5
diff -u -r1.5 winex11.drv.spec
--- dlls/x11drv/winex11.drv.spec 27 Mar 2006 20:51:24 -0000 1.5
+++ dlls/x11drv/winex11.drv.spec 9 May 2006 13:19:48 -0000
@@ -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
More information about the wine-patches
mailing list