winex11/dib: Fix GetDIBits of 1 bit DDBs

Michael Karcher wine at mkarcher.dialup.fu-berlin.de
Sat Jun 7 18:26:59 CDT 2008


1 bpp DDBs seem to always carry an implicit palette of black and white,
regardless of what the DC says. Based on a patch from Eric Pouech,
available at <http://bugs.winehq.org/attachment.cgi?id=12492>.
---
 dlls/gdi32/tests/bitmap.c |    5 +----
 dlls/winex11.drv/dib.c    |   15 +++++++++++++--
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index 83bc498..a1c426f 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -1176,10 +1176,7 @@ static void test_GetDIBits_selected_DIB(UINT bpp)
             break;
         }
     }
-    if (bpp != 1)
-        ok(equalContents, "GetDIBits with %d bpp DIB selected in DC: Invalid DIB bits\n",bpp);
-    else
-        todo_wine ok(equalContents, "GetDIBits with %d bpp DIB selected in DC: Invalid DIB bits\n",bpp);
+    ok(equalContents, "GetDIBits with %d bpp DIB selected in DC: Invalid DIB bits\n",bpp);
 
     HeapFree(GetProcessHeap(), 0, bits2);
     DeleteDC(dc);
diff --git a/dlls/winex11.drv/dib.c b/dlls/winex11.drv/dib.c
index 4b287ea..ee21ad6 100644
--- a/dlls/winex11.drv/dib.c
+++ b/dlls/winex11.drv/dib.c
@@ -4031,13 +4031,24 @@ INT X11DRV_GetDIBits( X11DRV_PDEVICE *physDev, HBITMAP hbitmap, UINT startscan,
   int bitmap_type;
   BOOL core_header;
   void* colorPtr;
-
-  GetPaletteEntries( GetCurrentObject( physDev->hdc, OBJ_PAL ), 0, 256, palette );
+  const PALETTEENTRY peBlack = {0,0,0,0};
+  const PALETTEENTRY peWhite = {255,255,255,0};
 
   if (!physBitmap) return 0;
   if (!(obj_size = GetObjectW( hbitmap, sizeof(dib), &dib ))) return 0;
 
   bitmap_type = DIB_GetBitmapInfo( (BITMAPINFOHEADER*)info, &width, &tempHeight, &descr.infoBpp, &descr.compression);
+
+  if (physDev->depth > 1)
+  {
+    GetPaletteEntries( GetCurrentObject( physDev->hdc, OBJ_PAL ), 0, 256, palette );
+  }
+  else 
+  {
+    palette[0] = peBlack;
+    palette[1] = peWhite;
+  }
+  
   if (bitmap_type == -1)
   {
       ERR("Invalid bitmap\n");
-- 
1.5.5.1


--=-/Kl5kXam3PI3pe5o86hv--




More information about the wine-devel mailing list