[WIN32K]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 9 Jun 2010 20:36:04 +0000 (20:36 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Wed, 9 Jun 2010 20:36:04 +0000 (20:36 +0000)
- Improve readability in SetBMIColor
- Only when BitCount is <= 8, calculate the number of colors in the table
- Fixes a crash with VBox driver

svn path=/branches/reactos-yarotows/; revision=47724

subsystems/win32/win32k/objects/dibobj.c

index 212e6d6..8b6cf8e 100644 (file)
@@ -1746,13 +1746,16 @@ FORCEINLINE
 VOID
 SetBMIColor(CONST BITMAPINFO* pbmi, DWORD* color, INT i)
 {
+    PVOID pvColors = ((PBYTE)pbmi + pbmi->bmiHeader.biSize);
     if(pbmi->bmiHeader.biSize == sizeof(BITMAPCOREHEADER))
     {
-        *(RGBTRIPLE*)((PBYTE)pbmi + pbmi->bmiHeader.biSize + i*sizeof(RGBTRIPLE)) = *(RGBTRIPLE*)color;
+        RGBTRIPLE *pColor = pvColors;
+        pColor[i] = *(RGBTRIPLE*)color;
     }
     else
     {
-        *(RGBQUAD*)((PBYTE)pbmi + pbmi->bmiHeader.biSize + i*sizeof(RGBQUAD)) = *(RGBQUAD*)color;
+        RGBQUAD *pColor = pvColors;
+        pColor[i] = *(RGBQUAD*)color;
     }
 }
 
@@ -1954,7 +1957,7 @@ GetBMIFromBitmapV5Info(IN PBITMAPV5INFO pbmiSrc,
         ULONG cColorsUsed;
 
         cColorsUsed = pbmiSrc->bmiHeader.bV5ClrUsed;
-        if (cColorsUsed == 0) 
+        if (cColorsUsed == 0 && pbmiSrc->bmiHeader.bV5BitCount <= 8
             cColorsUsed = (1 << pbmiSrc->bmiHeader.bV5BitCount);
 
         if(dwColorUse == DIB_PAL_COLORS)