From: Gregor Schneider Date: Sun, 27 Dec 2009 13:02:19 +0000 (+0000) Subject: [win32k] X-Git-Tag: backups/aicom-network-stable@46924~154 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=5e86753986b3b317ba94649f70eb4f80808190fc;ds=sidebyside [win32k] - Create DIB section palettes with the number of colors mapped from the logical palette - Validate logical palette access, set to black for invalid indices - gdi32:palette test now succeeds svn path=/trunk/; revision=44768 --- diff --git a/reactos/subsystems/win32/win32k/objects/dibobj.c b/reactos/subsystems/win32/win32k/objects/dibobj.c index 00a5d4773d7..04c00c01c1b 100644 --- a/reactos/subsystems/win32/win32k/objects/dibobj.c +++ b/reactos/subsystems/win32/win32k/objects/dibobj.c @@ -1358,6 +1358,7 @@ DIB_CreateDIBSection( RGBQUAD *lpRGB; HANDLE hSecure; DWORD dsBitfields[3] = {0}; + ULONG ColorCount; DPRINT("format (%ld,%ld), planes %d, bpp %d, size %ld, colors %ld (%s)\n", bi->biWidth, bi->biHeight, bi->biPlanes, bi->biBitCount, @@ -1439,9 +1440,18 @@ DIB_CreateDIBSection( hSecure = (HANDLE)0x1; // HACK OF UNIMPLEMENTED KERNEL STUFF !!!! if (usage == DIB_PAL_COLORS) + { lpRGB = DIB_MapPaletteColors(dc, bmi); + } else + { lpRGB = bmi->bmiColors; + } + ColorCount = bi->biClrUsed; + if (ColorCount == 0) + { + ColorCount = 1 << bi->biBitCount; + } /* Set dsBitfields values */ if (usage == DIB_PAL_COLORS || bi->biBitCount <= 8) @@ -1528,12 +1538,16 @@ DIB_CreateDIBSection( bmp->biClrImportant = bi->biClrImportant; if (bi->biClrUsed != 0) - bmp->hDIBPalette = PALETTE_AllocPaletteIndexedRGB(bi->biClrUsed, lpRGB); + { + bmp->hDIBPalette = PALETTE_AllocPaletteIndexedRGB(ColorCount, lpRGB); + } else + { bmp->hDIBPalette = PALETTE_AllocPalette(PAL_BITFIELDS, 0, NULL, dsBitfields[0], dsBitfields[1], dsBitfields[2]); + } // Clean up in case of errors if (!res || !bmp || !bm.bmBits) @@ -1671,9 +1685,18 @@ DIB_MapPaletteColors(PDC dc, CONST BITMAPINFO* lpbmi) for (i = 0; i < nNumColors; i++) { - lpRGB[i].rgbRed = palGDI->IndexedColors[*lpIndex].peRed; - lpRGB[i].rgbGreen = palGDI->IndexedColors[*lpIndex].peGreen; - lpRGB[i].rgbBlue = palGDI->IndexedColors[*lpIndex].peBlue; + if (*lpIndex < palGDI->NumColors) + { + lpRGB[i].rgbRed = palGDI->IndexedColors[*lpIndex].peRed; + lpRGB[i].rgbGreen = palGDI->IndexedColors[*lpIndex].peGreen; + lpRGB[i].rgbBlue = palGDI->IndexedColors[*lpIndex].peBlue; + } + else + { + lpRGB[i].rgbRed = 0; + lpRGB[i].rgbGreen = 0; + lpRGB[i].rgbBlue = 0; + } lpRGB[i].rgbReserved = 0; lpIndex++; }