[PATCH] GetPaletteEntries shouldn't filter peFlags as shown by the attached test. This prevents directdraw/direct3d problems as it is allowed to abuse peFlags for storing e.g. the alpha component.

Roderick Colenbrander thunderbird2k at gmx.net
Sun Feb 17 07:57:16 CST 2008


---
 dlls/gdi32/palette.c       |    3 ---
 dlls/gdi32/tests/palette.c |   26 ++++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/dlls/gdi32/palette.c b/dlls/gdi32/palette.c
index b55a6f8..abf4234 100644
--- a/dlls/gdi32/palette.c
+++ b/dlls/gdi32/palette.c
@@ -301,9 +301,6 @@ UINT WINAPI GetPaletteEntries(
       }
       memcpy( entries, &palPtr->logpalette.palPalEntry[start],
 	      count * sizeof(PALETTEENTRY) );
-      for( numEntries = 0; numEntries < count ; numEntries++ )
-	   if (entries[numEntries].peFlags & 0xF0)
-	       entries[numEntries].peFlags = 0;
     }
 
     GDI_ReleaseObj( hpalette );
diff --git a/dlls/gdi32/tests/palette.c b/dlls/gdi32/tests/palette.c
index 40e6c7c..4f94338 100644
--- a/dlls/gdi32/tests/palette.c
+++ b/dlls/gdi32/tests/palette.c
@@ -120,7 +120,33 @@ static void test_DIB_PAL_COLORS(void) {
     ReleaseDC( NULL, hdc );
 }
 
+static void test_palette_entries()
+{
+    char logpalettebuf[sizeof(LOGPALETTE) + sizeof(logpalettedata)];
+    PLOGPALETTE logpalette = (PLOGPALETTE)logpalettebuf;
+    HPALETTE hpal;
+    UINT res=0;
+    PALETTEENTRY palEntry = { 0x1, 0x2, 0x3, 0xff };
+    PALETTEENTRY getEntryResult;
+
+    /* Initalize the logical palette with a few colours */
+    logpalette->palVersion = 0x300;
+    logpalette->palNumEntries = 8;
+    memcpy( logpalette->palPalEntry, logpalettedata, sizeof(logpalettedata) );
+    hpal = CreatePalette( logpalette ); 
+
+    /* Set a new entry with peFlags to 0xff */
+    SetPaletteEntries(hpal, 0, 1, &palEntry);
+
+    /* Retrieve the entry to see if GDI32 performs any filtering on peFlags */
+    res = GetPaletteEntries(hpal, 0, 1, &getEntryResult);
+    ok(res == 1, "GetPaletteEntries should have returned 1 but returned %d\n", res);
+
+    ok( palEntry.peFlags == getEntryResult.peFlags, "palEntry.peFlags (%#x) != getEntryResult.peFlags (%#x)\n", palEntry.peFlags, getEntryResult.peFlags );
+}
+
 START_TEST(palette)
 {
     test_DIB_PAL_COLORS();
+    test_palette_entries();
 }
-- 
1.5.3.8


--========GMX202731203253366472101--



More information about the wine-patches mailing list