[ros-diffs] [tkreuzer] 56474: [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 b...

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Wed May 2 10:09:06 UTC 2012


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?rev=56474&r1=56473&r2=56474&view=diff
==============================================================================
--- 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;
 }




More information about the Ros-diffs mailing list