mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
[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
This commit is contained in:
parent
e90543ae55
commit
7be39c2aba
1 changed files with 10 additions and 11 deletions
|
@ -1725,14 +1725,14 @@ INT FASTCALL DIB_BitmapInfoSize(const BITMAPINFO * info, WORD coloruse)
|
||||||
|
|
||||||
HPALETTE
|
HPALETTE
|
||||||
FASTCALL
|
FASTCALL
|
||||||
DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi)
|
DIB_MapPaletteColors(PPALETTE ppalDc, CONST BITMAPINFO* lpbmi)
|
||||||
{
|
{
|
||||||
PALETTEENTRY* ppalEntries;
|
PPALETTE ppalNew;
|
||||||
ULONG nNumColors,i;
|
ULONG nNumColors,i;
|
||||||
USHORT *lpIndex;
|
USHORT *lpIndex;
|
||||||
HPALETTE hpal;
|
HPALETTE hpal;
|
||||||
|
|
||||||
if (!(ppal->flFlags & PAL_INDEXED))
|
if (!(ppalDc->flFlags & PAL_INDEXED))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1743,10 +1743,10 @@ DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi)
|
||||||
nNumColors = min(nNumColors, lpbmi->bmiHeader.biClrUsed);
|
nNumColors = min(nNumColors, lpbmi->bmiHeader.biClrUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
ppalEntries = ExAllocatePoolWithTag(PagedPool, sizeof(PALETTEENTRY) * nNumColors, TAG_COLORMAP);
|
ppalNew = PALETTE_AllocPalWithHandle(PAL_INDEXED, nNumColors, NULL, 0, 0, 0);
|
||||||
if (ppalEntries == NULL)
|
if (ppalNew == NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("Could not allocate palette entries\n");
|
DPRINT1("Could not allocate palette\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1754,14 +1754,13 @@ DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi)
|
||||||
|
|
||||||
for (i = 0; i < nNumColors; i++)
|
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++;
|
lpIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
hpal = PALETTE_AllocPalette(PAL_INDEXED, nNumColors, (ULONG*)ppalEntries, 0, 0, 0);
|
hpal = ppalNew->BaseObject.hHmgr;
|
||||||
|
PALETTE_UnlockPalette(ppalNew);
|
||||||
ExFreePoolWithTag(ppalEntries, TAG_COLORMAP);
|
|
||||||
|
|
||||||
return hpal;
|
return hpal;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue