Three important DIB fixes for x11drv

Michael Kaufmann hallo at michael-kaufmann.ch
Sun Sep 26 10:25:21 CDT 2004


I've managed to fix these bugs:

- The X11 driver creates wrong color maps. They contain as many colors 
as supported by the destination device. If you call SetDIBits with a 
4-bit DIB and a monochrome destination bitmap, this will lead to a color 
map containing only 2 colors instead of 16.

- The color maps created for monochrome bitmaps contain the colors 0 and 
1 instead of 0 and 0xFFFFFF.


This patch makes Office 95 draw its icons correctly :-)
Some other bug needs to be fixed in OLE's storage code, but Office 95 
runs well if you remove some assertions there!


Changelog:
  - Add as many entries to the color map as specified by the DIB
  - Build correct color maps for monochrome bitmaps
  - Support bitmaps with a BITMAPV{4,5}HEADER
 
-------------- next part --------------
Index: dlls/x11drv/dib.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/dib.c,v
retrieving revision 1.17
diff -u -r1.17 dib.c
--- dlls/x11drv/dib.c	16 Sep 2004 19:10:14 -0000	1.17
+++ dlls/x11drv/dib.c	26 Sep 2004 14:16:25 -0000
@@ -241,8 +241,8 @@
 
             if (depth == 1)  /* Monochrome */
                 for (i = start; i < end; i++, rgb++)
-                    colorMapping[i] = (rgb->rgbRed + rgb->rgbGreen +
-                                       rgb->rgbBlue > 255*3/2);
+                    colorMapping[i] = ((rgb->rgbRed + rgb->rgbGreen +
+                                       rgb->rgbBlue > 255*3/2) ? 0xFFFFFF : 0);				    
             else
                 for (i = start; i < end; i++, rgb++)
                     colorMapping[i] = X11DRV_PALETTE_ToPhysical( physDev, RGB(rgb->rgbRed,
@@ -255,8 +255,8 @@
 
             if (depth == 1)  /* Monochrome */
                 for (i = start; i < end; i++, rgb++)
-                    colorMapping[i] = (rgb->rgbtRed + rgb->rgbtGreen +
-                                       rgb->rgbtBlue > 255*3/2);
+                    colorMapping[i] = ((rgb->rgbtRed + rgb->rgbtGreen +
+                                       rgb->rgbtBlue > 255*3/2) ? 0xFFFFFF : 0);
             else
                 for (i = start; i < end; i++, rgb++)
                     colorMapping[i] = X11DRV_PALETTE_ToPhysical( physDev, RGB(rgb->rgbtRed,
@@ -294,15 +294,16 @@
     const void *colorPtr;
     int *colorMapping;
 
-    if ((isInfo = (info->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))))
+    if ((isInfo = (info->bmiHeader.biSize != sizeof(BITMAPCOREHEADER))))
     {
+        /* assume BITMAPINFOHEADER */
         colors = info->bmiHeader.biClrUsed;
         if (!colors) colors = 1 << info->bmiHeader.biBitCount;
         colorPtr = info->bmiColors;
     }
-    else  /* assume BITMAPCOREINFO */
+    else  /* BITMAPCOREHEADER */
     {
-        colors = 1 << ((BITMAPCOREHEADER *)&info->bmiHeader)->bcBitCount;
+        colors = 1 << ((BITMAPCOREHEADER *)info)->bcBitCount;
         colorPtr = (WORD *)((BITMAPCOREINFO *)info)->bmciColors;
     }
 
@@ -3695,7 +3696,7 @@
        case 8:
                descr.colorMap = (RGBQUAD *)X11DRV_DIB_BuildColorMap(
                                             coloruse == DIB_PAL_COLORS ? physDev : NULL, coloruse,
-                                            physDev->depth, info, &descr.nColorMap );
+                                            descr.infoBpp, info, &descr.nColorMap );
                if (!descr.colorMap) return 0;
                descr.rMask = descr.gMask = descr.bMask = 0;
                break;
@@ -3778,8 +3779,7 @@
        case 8:
 	       descr.colorMap = (RGBQUAD *)X11DRV_DIB_BuildColorMap(
                         coloruse == DIB_PAL_COLORS ? descr.physDev : NULL, coloruse,
-                                                          bmp->bitmap.bmBitsPixel,
-                                                          info, &descr.nColorMap );
+                        descr.infoBpp, info, &descr.nColorMap );
                if (!descr.colorMap)
                {
                    GDI_ReleaseObj( hbitmap );


More information about the wine-patches mailing list