It's possible to select an (indexed) palette into a bitfield (e.g. 16 bit
authorGé van Geldorp <ge@gse.nl>
Thu, 8 Dec 2005 17:34:48 +0000 (17:34 +0000)
committerGé van Geldorp <ge@gse.nl>
Thu, 8 Dec 2005 17:34:48 +0000 (17:34 +0000)
deep) DC. This palette will be used when calling CreateDIBSection with
DIB_PAL_COLORS usage. Fixes bug 1077.

svn path=/trunk/; revision=19967

reactos/include/win32k/dc.h
reactos/subsys/win32k/objects/color.c
reactos/subsys/win32k/objects/dc.c
reactos/subsys/win32k/objects/dib.c

index 74c4d09..efb71ab 100644 (file)
@@ -100,6 +100,8 @@ typedef struct _DC
   INT  saveLevel;
   BOOL IsIC;
 
+  HPALETTE PalIndexed;
+
   WIN_DC_INFO  w;
 } DC, *PDC;
 
index 10663f5..1d731ec 100644 (file)
@@ -509,6 +509,12 @@ HPALETTE STDCALL NtGdiSelectPalette(HDC  hDC,
               oldPal = dc->w.hPalette;
               dc->w.hPalette = hpal;
             }
+          else if (8 < dc->w.bitsPerPixel && PAL_INDEXED == PalGDI->Mode)
+            {
+              PALETTE_UnlockPalette(PalGDI);
+              oldPal = dc->PalIndexed;
+              dc->PalIndexed = hpal;
+            }
           else
             {
               PALETTE_UnlockPalette(PalGDI);
index e44b5df..bdf409c 100644 (file)
@@ -222,6 +222,7 @@ NtGdiCreateCompatibleDC(HDC hDC)
   NewDC->w.hFirstBitmap = hBitmap;
   NewDC->GDIDevice      = OrigDC->GDIDevice;
 
+  NewDC->PalIndexed = OrigDC->PalIndexed;
   NewDC->w.hPalette = OrigDC->w.hPalette;
   NewDC->w.textColor = OrigDC->w.textColor;
   NewDC->w.textAlign = OrigDC->w.textAlign;
@@ -905,6 +906,7 @@ IntGdiCreateDC(PUNICODE_STRING Driver,
 
   if (! CreateAsIC)
   {
+    NewDC->PalIndexed = NtGdiGetStockObject(DEFAULT_PALETTE);
     NewDC->w.hPalette = NewDC->DevInfo->hpalDefault;
     NewDC->w.ROPmode = R2_COPYPEN;
 
@@ -1315,6 +1317,7 @@ NtGdiGetDCState(HDC  hDC)
 #if 0
   newdc->w.hDevice          = dc->w.hDevice;
 #endif
+  newdc->PalIndexed         = dc->PalIndexed;
   newdc->w.hPalette         = dc->w.hPalette;
   newdc->w.totalExtent      = dc->w.totalExtent;
   newdc->w.bitsPerPixel     = dc->w.bitsPerPixel;
@@ -1440,6 +1443,7 @@ NtGdiSetDCState ( HDC hDC, HDC hDCSave )
        dc->vportOrgY          = dcs->vportOrgY;
        dc->vportExtX          = dcs->vportExtX;
        dc->vportExtY          = dcs->vportExtY;
+        dc->PalIndexed         = dcs->PalIndexed;
 
        if (!(dc->w.flags & DC_MEMORY))
        {
index cf165c7..3d8137f 100644 (file)
@@ -1108,7 +1108,11 @@ DIB_MapPaletteColors(PDC dc, CONST BITMAPINFO* lpbmi)
   if (palGDI->Mode != PAL_INDEXED)
     {
       PALETTE_UnlockPalette(palGDI);
-      return NULL;
+      palGDI = PALETTE_LockPalette(dc->PalIndexed);
+      if (palGDI->Mode != PAL_INDEXED)
+        {
+          return NULL;
+        }
     }
 
   nNumColors = 1 << lpbmi->bmiHeader.biBitCount;