Alexandre Julliard : gdi32: Avoid accessing the internal palette object from dib.c.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Nov 17 11:48:55 CST 2006


Module: wine
Branch: master
Commit: c60757b7d8b57f4e6b697e9c93cdc275075445a7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c60757b7d8b57f4e6b697e9c93cdc275075445a7

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Nov 17 14:34:20 2006 +0100

gdi32: Avoid accessing the internal palette object from dib.c.

---

 dlls/gdi32/dib.c |   44 ++++++++++++++++++++------------------------
 1 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/dlls/gdi32/dib.c b/dlls/gdi32/dib.c
index a3d559c..c23e861 100644
--- a/dlls/gdi32/dib.c
+++ b/dlls/gdi32/dib.c
@@ -638,33 +638,33 @@ INT WINAPI GetDIBits(
         else {
             if(bpp >= bmp->bitmap.bmBitsPixel) {
                 /* Generate the color map from the selected palette */
-                PALETTEENTRY * palEntry;
-                PALETTEOBJ * palette;
-                if (!(palette = (PALETTEOBJ*)GDI_GetObjPtr( dc->hPalette, PALETTE_MAGIC ))) {
+                PALETTEENTRY palEntry[256];
+
+                memset( palEntry, 0, sizeof(palEntry) );
+                if (!GetPaletteEntries( dc->hPalette, 0, 1 << bmp->bitmap.bmBitsPixel, palEntry ))
+                {
                     GDI_ReleaseObj( hdc );
                     GDI_ReleaseObj( hbitmap );
                     return 0;
                 }
-                palEntry = palette->logpalette.palPalEntry;
-                for (i = 0; i < (1 << bmp->bitmap.bmBitsPixel); i++, palEntry++) {
+                for (i = 0; i < (1 << bmp->bitmap.bmBitsPixel); i++) {
                     if (coloruse == DIB_RGB_COLORS) {
                         if (core_header)
                         {
-                            rgbTriples[i].rgbtRed   = palEntry->peRed;
-                            rgbTriples[i].rgbtGreen = palEntry->peGreen;
-                            rgbTriples[i].rgbtBlue  = palEntry->peBlue;
+                            rgbTriples[i].rgbtRed   = palEntry[i].peRed;
+                            rgbTriples[i].rgbtGreen = palEntry[i].peGreen;
+                            rgbTriples[i].rgbtBlue  = palEntry[i].peBlue;
                         }
                         else
                         {
-                            rgbQuads[i].rgbRed      = palEntry->peRed;
-                            rgbQuads[i].rgbGreen    = palEntry->peGreen;
-                            rgbQuads[i].rgbBlue     = palEntry->peBlue;
+                            rgbQuads[i].rgbRed      = palEntry[i].peRed;
+                            rgbQuads[i].rgbGreen    = palEntry[i].peGreen;
+                            rgbQuads[i].rgbBlue     = palEntry[i].peBlue;
                             rgbQuads[i].rgbReserved = 0;
                         }
                     }
                     else ((WORD *)colorPtr)[i] = (WORD)i;
                 }
-                GDI_ReleaseObj( dc->hPalette );
             } else {
                 switch (bpp) {
                 case 1:
@@ -1189,21 +1189,17 @@ static void DIB_CopyColorTable( DC *dc,
     }
     else
     {
-        PALETTEOBJ *palette;
+        PALETTEENTRY entries[256];
         const WORD *index = (const WORD*) ((const BYTE*) info + (WORD) info->bmiHeader.biSize);
+        UINT count = GetPaletteEntries( dc->hPalette, 0, colors, entries );
 
-        if ((palette = GDI_GetObjPtr( dc->hPalette, PALETTE_MAGIC )))
+        for (i = 0; i < colors; i++, index++)
         {
-            UINT entries = palette->logpalette.palNumEntries;
-            for (i = 0; i < colors; i++, index++)
-            {
-                PALETTEENTRY *entry = &palette->logpalette.palPalEntry[*index % entries];
-                colorTable[i].rgbRed = entry->peRed;
-                colorTable[i].rgbGreen = entry->peGreen;
-                colorTable[i].rgbBlue = entry->peBlue;
-                colorTable[i].rgbReserved = 0;
-            }
-            GDI_ReleaseObj( dc->hPalette );
+            PALETTEENTRY *entry = &entries[*index % count];
+            colorTable[i].rgbRed = entry->peRed;
+            colorTable[i].rgbGreen = entry->peGreen;
+            colorTable[i].rgbBlue = entry->peBlue;
+            colorTable[i].rgbReserved = 0;
         }
     }
     bmp->color_table = colorTable;




More information about the wine-cvs mailing list