From 7be39c2aba994a05f37bcf75e131154c122f221b Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 2 May 2012 10:09:05 +0000 Subject: [PATCH] [WIN32K] Modify DIB_MapPaletteColors, first allocating a palette without initializing the colors, then setting up the colors. This wway we don't need to allocate an intermediate buffer. svn path=/trunk/; revision=56474 --- reactos/win32ss/gdi/ntgdi/dibobj.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/reactos/win32ss/gdi/ntgdi/dibobj.c b/reactos/win32ss/gdi/ntgdi/dibobj.c index 014141ad8af..768aa318b9f 100644 --- a/reactos/win32ss/gdi/ntgdi/dibobj.c +++ b/reactos/win32ss/gdi/ntgdi/dibobj.c @@ -1725,14 +1725,14 @@ INT FASTCALL DIB_BitmapInfoSize(const BITMAPINFO * info, WORD coloruse) HPALETTE FASTCALL -DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi) +DIB_MapPaletteColors(PPALETTE ppalDc, CONST BITMAPINFO* lpbmi) { - PALETTEENTRY* ppalEntries; + PPALETTE ppalNew; ULONG nNumColors,i; USHORT *lpIndex; HPALETTE hpal; - if (!(ppal->flFlags & PAL_INDEXED)) + if (!(ppalDc->flFlags & PAL_INDEXED)) { return NULL; } @@ -1743,10 +1743,10 @@ DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi) nNumColors = min(nNumColors, lpbmi->bmiHeader.biClrUsed); } - ppalEntries = ExAllocatePoolWithTag(PagedPool, sizeof(PALETTEENTRY) * nNumColors, TAG_COLORMAP); - if (ppalEntries == NULL) + ppalNew = PALETTE_AllocPalWithHandle(PAL_INDEXED, nNumColors, NULL, 0, 0, 0); + if (ppalNew == NULL) { - DPRINT1("Could not allocate palette entries\n"); + DPRINT1("Could not allocate palette\n"); return NULL; } @@ -1754,14 +1754,13 @@ DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi) for (i = 0; i < nNumColors; i++) { - ppalEntries[i] = ppal->IndexedColors[*lpIndex % ppal->NumColors]; - + ULONG iColorIndex = *lpIndex % ppalDc->NumColors; + ppalNew->IndexedColors[i] = ppalDc->IndexedColors[iColorIndex]; lpIndex++; } - hpal = PALETTE_AllocPalette(PAL_INDEXED, nNumColors, (ULONG*)ppalEntries, 0, 0, 0); - - ExFreePoolWithTag(ppalEntries, TAG_COLORMAP); + hpal = ppalNew->BaseObject.hHmgr; + PALETTE_UnlockPalette(ppalNew); return hpal; }