Merge from trunk:
It's possible to select an (indexed) palette into a bitfield (e.g. 16 bit
deep) DC. This palette will be used when calling CreateDIBSection with
DIB_PAL_COLORS usage. Fixes bug 1077.
Modified: branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/color.c
Modified: branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/dc.c
Modified: branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/dib.c

Modified: branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/color.c
--- branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/color.c	2005-12-08 17:34:48 UTC (rev 19967)
+++ branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/color.c	2005-12-08 17:41:57 UTC (rev 19968)
@@ -509,6 +509,12 @@
               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);

Modified: branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/dc.c
--- branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/dc.c	2005-12-08 17:34:48 UTC (rev 19967)
+++ branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/dc.c	2005-12-08 17:41:57 UTC (rev 19968)
@@ -222,6 +222,7 @@
   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 @@
 
   if (! CreateAsIC)
   {
+    NewDC->PalIndexed = NtGdiGetStockObject(DEFAULT_PALETTE);
     NewDC->w.hPalette = NewDC->DevInfo->hpalDefault;
     NewDC->w.ROPmode = R2_COPYPEN;
 
@@ -1315,6 +1317,7 @@
 #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 @@
 	dc->vportOrgY          = dcs->vportOrgY;
 	dc->vportExtX          = dcs->vportExtX;
 	dc->vportExtY          = dcs->vportExtY;
+        dc->PalIndexed         = dcs->PalIndexed;
 
 	if (!(dc->w.flags & DC_MEMORY))
 	{

Modified: branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/dib.c
--- branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/dib.c	2005-12-08 17:34:48 UTC (rev 19967)
+++ branches/ros-branch-0_2_9/reactos/subsys/win32k/objects/dib.c	2005-12-08 17:41:57 UTC (rev 19968)
@@ -1108,7 +1108,11 @@
   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;