Author: tkreuzer
Date: Wed May 2 10:09:05 2012
New Revision: 56474
URL:
http://svn.reactos.org/svn/reactos?rev=56474&view=rev
Log:
[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.
Modified:
trunk/reactos/win32ss/gdi/ntgdi/dibobj.c
Modified: trunk/reactos/win32ss/gdi/ntgdi/dibobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dibobj.c…
==============================================================================
--- trunk/reactos/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] Wed May 2 10:09:05 2012
@@ -1725,14 +1725,14 @@
HPALETTE
FASTCALL
-DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi)
-{
- PALETTEENTRY* ppalEntries;
+DIB_MapPaletteColors(PPALETTE ppalDc, CONST BITMAPINFO* lpbmi)
+{
+ 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 @@
nNumColors = min(nNumColors, lpbmi->bmiHeader.biClrUsed);
}
- ppalEntries = ExAllocatePoolWithTag(PagedPool, sizeof(PALETTEENTRY) * nNumColors,
TAG_COLORMAP);
- if (ppalEntries == NULL)
- {
- DPRINT1("Could not allocate palette entries\n");
+ ppalNew = PALETTE_AllocPalWithHandle(PAL_INDEXED, nNumColors, NULL, 0, 0, 0);
+ if (ppalNew == NULL)
+ {
+ DPRINT1("Could not allocate palette\n");
return NULL;
}
@@ -1754,14 +1754,13 @@
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;
}