[2/2] gdi32/dib: Fix palette of 1bpp DIB in GetDIBits

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


Windows always generates a black/white palette for 1 bit DIBs
generated from DDBs. Copying from the current palette only takes
place for color DDBs (not explicitly mentioned in MSDN), and only
if depth equal (MSDN states it, explicitly).
---
As mentioned in [1/2], this series is intended to fix #6519, but a
third patch is needed additionally to these two patches. The patch
by Eric in the buglog does that job, but I think there is an "more
obviously correct" solution to it. I let Eric submit a patch if he
wants, as he tracked down the problem. If he tells me to go on, I
will submit my version myself instead.

 dlls/gdi32/dib.c          |    6 ++++--
 dlls/gdi32/tests/bitmap.c |    1 -
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index 46be0f0..677cda5 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -705,8 +705,10 @@ INT WINAPI GetDIBits(
                 for (i = 0; i < (1 << bpp); i++)
                     ((WORD *)colorPtr)[i] = (WORD)i;
             }
-            else if(bpp >= bmp->bitmap.bmBitsPixel) {
-                /* Generate the color map from the selected palette */
+            else if(bpp > 1 && bpp == bmp->bitmap.bmBitsPixel) {
+                /* For color DDBs in native depth (mono DDBs always have
+                   a black/white palette):
+                   Generate the color map from the selected palette */
                 PALETTEENTRY palEntry[256];
 
                 memset( palEntry, 0, sizeof(palEntry) );
diff --git a/dlls/gdi32/tests/bitmap.c b/dlls/gdi32/tests/bitmap.c
index 6685ae6..83bc498 100644
--- a/dlls/gdi32/tests/bitmap.c
+++ b/dlls/gdi32/tests/bitmap.c
@@ -1485,7 +1485,6 @@ static void test_GetDIBits(void)
        "expected bmiColors[0] 0,0,0,0 - got %x %x %x %x\n",
        bi->bmiColors[0].rgbRed, bi->bmiColors[0].rgbGreen,
        bi->bmiColors[0].rgbBlue, bi->bmiColors[0].rgbReserved);
-todo_wine
     ok(bi->bmiColors[1].rgbRed == 0xff && bi->bmiColors[1].rgbGreen == 0xff &&
        bi->bmiColors[1].rgbBlue == 0xff && bi->bmiColors[1].rgbReserved == 0,
        "expected bmiColors[0] 0xff,0xff,0xff,0 - got %x %x %x %x\n",
-- 
1.5.5.1




More information about the wine-patches mailing list