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

This commit is contained in:
Alexandre Julliard 2007-03-21 15:56:10 +01:00
parent 11e01b17de
commit f143010038

View file

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