Alexandre Julliard : winex11.drv: Relax the bitmap depth check in CreateBitmap to accept some compatible formats .

Alexandre Julliard julliard at wine.codeweavers.com
Wed Mar 21 17:02:47 CDT 2007


Module: wine
Branch: master
Commit: f14301003854352b9c67714d9e878ea862d5f9cf
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f14301003854352b9c67714d9e878ea862d5f9cf

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Mar 21 15:56:10 2007 +0100

winex11.drv: Relax the bitmap depth check in CreateBitmap to accept some compatible formats.

---

 dlls/winex11.drv/bitmap.c |   33 ++++++++++++++++-----------------
 1 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/dlls/winex11.drv/bitmap.c b/dlls/winex11.drv/bitmap.c
index 75623e4..053c959 100644
--- a/dlls/winex11.drv/bitmap.c
+++ b/dlls/winex11.drv/bitmap.c
@@ -121,7 +121,13 @@ BOOL X11DRV_CreateBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, LPVOID bmBit
       /* Check parameters */
     if (bitmap.bmPlanes != 1) return FALSE;
 
-    if ((bitmap.bmBitsPixel != 1) && (bitmap.bmBitsPixel != screen_depth))
+    /* check if bpp is compatible with screen depth */
+    if (!((bitmap.bmBitsPixel == 1) ||
+          (bitmap.bmBitsPixel == screen_depth) ||
+          (bitmap.bmBitsPixel == 24 && screen_depth == 32) ||
+          (bitmap.bmBitsPixel == 32 && screen_depth == 24) ||
+          (bitmap.bmBitsPixel == 15 && screen_depth == 16) ||
+          (bitmap.bmBitsPixel == 16 && screen_depth == 15)))
     {
         ERR("Trying to make bitmap with planes=%d, bpp=%d\n",
             bitmap.bmPlanes, bitmap.bmBitsPixel);
@@ -139,9 +145,9 @@ BOOL X11DRV_CreateBitmap( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, LPVOID bmBit
 
       /* Create the pixmap */
     wine_tsx11_lock();
-    physBitmap->pixmap_depth = bitmap.bmBitsPixel;
+    physBitmap->pixmap_depth = (bitmap.bmBitsPixel == 1) ? 1 : screen_depth;
     physBitmap->pixmap = XCreatePixmap(gdi_display, root_window,
-                                       bitmap.bmWidth, bitmap.bmHeight, bitmap.bmBitsPixel);
+                                       bitmap.bmWidth, bitmap.bmHeight, physBitmap->pixmap_depth);
     wine_tsx11_unlock();
     if (!physBitmap->pixmap)
     {
@@ -178,7 +184,7 @@ LONG X11DRV_GetBitmapBits( HBITMAP hbitmap, void *buffer, LONG count )
 {
     BITMAP bitmap;
     X_PHYSBITMAP *physBitmap = X11DRV_get_phys_bitmap( hbitmap );
-    LONG old_height, height;
+    LONG height;
     XImage *image;
     LPBYTE tbuf, startline;
     int	h, w;
@@ -188,21 +194,14 @@ LONG X11DRV_GetBitmapBits( HBITMAP hbitmap, void *buffer, LONG count )
     TRACE("(bmp=%p, buffer=%p, count=0x%x)\n", hbitmap, buffer, count);
 
     wine_tsx11_lock();
-
-    /* Hack: change the bitmap height temporarily to avoid */
-    /*       getting unnecessary bitmap rows. */
-
-    old_height = bitmap.bmHeight;
-    height = bitmap.bmHeight = count / bitmap.bmWidthBytes;
-
+    height = count / bitmap.bmWidthBytes;
     image = XGetImage( gdi_display, physBitmap->pixmap, 0, 0,
-                       bitmap.bmWidth, bitmap.bmHeight, AllPlanes, ZPixmap );
-    bitmap.bmHeight = old_height;
+                       bitmap.bmWidth, height, AllPlanes, ZPixmap );
 
     /* copy XImage to 16 bit padded image buffer with real bitsperpixel */
 
     startline = buffer;
-    switch (physBitmap->pixmap_depth)
+    switch (bitmap.bmBitsPixel)
     {
     case 1:
         for (h=0;h<height;h++)
@@ -288,7 +287,7 @@ LONG X11DRV_GetBitmapBits( HBITMAP hbitmap, void *buffer, LONG count )
 	}
         break;
     default:
-        FIXME("Unhandled bits:%d\n", physBitmap->pixmap_depth);
+        FIXME("Unhandled bits:%d\n", bitmap.bmBitsPixel);
     }
     XDestroyImage( image );
     wine_tsx11_unlock();
@@ -334,7 +333,7 @@ LONG X11DRV_SetBitmapBits( HBITMAP hbitmap, const void *bits, LONG count )
 
     startline = bits;
 
-    switch (physBitmap->pixmap_depth)
+    switch (bitmap.bmBitsPixel)
     {
     case 1:
         for (h=0;h<height;h++)
@@ -408,7 +407,7 @@ LONG X11DRV_SetBitmapBits( HBITMAP hbitmap, const void *bits, LONG count )
         }
         break;
     default:
-      FIXME("Unhandled bits:%d\n", physBitmap->pixmap_depth);
+      FIXME("Unhandled bits:%d\n", bitmap.bmBitsPixel);
 
     }
     XPutImage( gdi_display, physBitmap->pixmap, BITMAP_GC(physBitmap),




More information about the wine-cvs mailing list