From f14301003854352b9c67714d9e878ea862d5f9cf Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 21 Mar 2007 15:56:10 +0100 Subject: [PATCH] winex11.drv: Relax the bitmap depth check in CreateBitmap to accept some compatible formats. --- dlls/winex11.drv/bitmap.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/dlls/winex11.drv/bitmap.c b/dlls/winex11.drv/bitmap.c index 75623e4a6b3..053c95910f5 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;hpixmap_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;hpixmap_depth); + FIXME("Unhandled bits:%d\n", bitmap.bmBitsPixel); } XPutImage( gdi_display, physBitmap->pixmap, BITMAP_GC(physBitmap),