[win32k]
authorGregor Schneider <grschneider@gmail.com>
Sun, 27 Dec 2009 15:08:41 +0000 (15:08 +0000)
committerGregor Schneider <grschneider@gmail.com>
Sun, 27 Dec 2009 15:08:41 +0000 (15:08 +0000)
- Set the number of mapped colors depending on the usage parameter
- Use pure PALETTERGB color values when no palette is selected
- Fixes true color issue mentioned in r44712

svn path=/trunk/; revision=44769

reactos/subsystems/win32/win32k/objects/bitmaps.c
reactos/subsystems/win32/win32k/objects/dibobj.c

index 0bae35a..12f3c2d 100644 (file)
@@ -667,7 +667,7 @@ VOID IntHandleSpecialColorType(HDC hDC, COLORREF* Color)
         case 0x10: /* DIBINDEX */
             if (IntGetDIBColorTable(hDC, LOWORD(*Color), 1, &quad) == 1) 
             {
         case 0x10: /* DIBINDEX */
             if (IntGetDIBColorTable(hDC, LOWORD(*Color), 1, &quad) == 1) 
             {
-                *Color = RGB(quad.rgbRed, quad.rgbGreen, quad.rgbBlue);                
+                *Color = RGB(quad.rgbRed, quad.rgbGreen, quad.rgbBlue);
             }
             else
             {
             }
             else
             {
@@ -677,10 +677,16 @@ VOID IntHandleSpecialColorType(HDC hDC, COLORREF* Color)
             break;
         case 0x02: /* PALETTERGB */
             pdc = DC_LockDc(hDC);
             break;
         case 0x02: /* PALETTERGB */
             pdc = DC_LockDc(hDC);
-            index = NtGdiGetNearestPaletteIndex(pdc->dclevel.hpal, *Color);
-            if (IntGetPaletteEntries(pdc->dclevel.hpal, index, 1, &palEntry) == 1)
+            if (pdc->dclevel.hpal != NtGdiGetStockObject(DEFAULT_PALETTE))
             {
             {
-                *Color = RGB(palEntry.peRed, palEntry.peGreen, palEntry.peBlue);            
+                index = NtGdiGetNearestPaletteIndex(pdc->dclevel.hpal, *Color);
+                IntGetPaletteEntries(pdc->dclevel.hpal, index, 1, &palEntry);
+                *Color = RGB(palEntry.peRed, palEntry.peGreen, palEntry.peBlue);
+            }
+            else
+            {
+                /* Use the pure color */
+                *Color = *Color & 0x00FFFFFF;
             }
             DC_UnlockDc(pdc);
             break;
             }
             DC_UnlockDc(pdc);
             break;
@@ -688,7 +694,7 @@ VOID IntHandleSpecialColorType(HDC hDC, COLORREF* Color)
             pdc = DC_LockDc(hDC);
             if (IntGetPaletteEntries(pdc->dclevel.hpal, LOWORD(*Color), 1, &palEntry) == 1)
             {
             pdc = DC_LockDc(hDC);
             if (IntGetPaletteEntries(pdc->dclevel.hpal, LOWORD(*Color), 1, &palEntry) == 1)
             {
-                *Color = RGB(palEntry.peRed, palEntry.peGreen, palEntry.peBlue);            
+                *Color = RGB(palEntry.peRed, palEntry.peGreen, palEntry.peBlue);
             }
             DC_UnlockDc(pdc);
             break;
             }
             DC_UnlockDc(pdc);
             break;
index 04c00c0..cc2a16e 100644 (file)
@@ -1442,14 +1442,15 @@ DIB_CreateDIBSection(
     if (usage == DIB_PAL_COLORS)
     {
         lpRGB = DIB_MapPaletteColors(dc, bmi);
     if (usage == DIB_PAL_COLORS)
     {
         lpRGB = DIB_MapPaletteColors(dc, bmi);
+        ColorCount = bi->biClrUsed;
+        if (ColorCount == 0)
+        {
+            ColorCount = 1 << bi->biBitCount;
+        }
     }
     else
     {
         lpRGB = bmi->bmiColors;
     }
     else
     {
         lpRGB = bmi->bmiColors;
-    }
-    ColorCount = bi->biClrUsed;
-    if (ColorCount == 0)
-    {
         ColorCount = 1 << bi->biBitCount;
     }
 
         ColorCount = 1 << bi->biBitCount;
     }