From 57af3eb9c8efd0bccc5baf86ce8ad2e4a0746dda Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sat, 20 Dec 2003 10:31:32 +0000 Subject: [PATCH] - Palette fixes. svn path=/trunk/; revision=7130 --- reactos/include/ddk/winddi.h | 1 - reactos/subsys/win32k/eng/palette.c | 7 +- reactos/subsys/win32k/eng/xlate.c | 29 ++- reactos/subsys/win32k/include/color.h | 1 - reactos/subsys/win32k/include/palette.h | 2 +- reactos/subsys/win32k/objects/color.c | 240 ++++++++---------------- reactos/subsys/win32k/objects/dib.c | 24 +-- reactos/subsys/win32k/objects/palette.c | 19 +- 8 files changed, 119 insertions(+), 204 deletions(-) diff --git a/reactos/include/ddk/winddi.h b/reactos/include/ddk/winddi.h index 2f697149d32..cb143321ef1 100644 --- a/reactos/include/ddk/winddi.h +++ b/reactos/include/ddk/winddi.h @@ -721,7 +721,6 @@ typedef struct _PALOBJ ULONG ulReserved; PXLATEOBJ logicalToSystem; int *mapping; - PLOGPALETTE logpalette; /* _MUST_ be the last field */ } PALOBJ, *PPALOBJ; typedef struct _PATHOBJ diff --git a/reactos/subsys/win32k/eng/palette.c b/reactos/subsys/win32k/eng/palette.c index 1f7254e03c0..5440d0f8ef1 100644 --- a/reactos/subsys/win32k/eng/palette.c +++ b/reactos/subsys/win32k/eng/palette.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: palette.c,v 1.19 2003/11/26 22:24:04 gvg Exp $ +/* $Id: palette.c,v 1.20 2003/12/20 10:31:32 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -85,7 +85,10 @@ PALOBJ_cGetColors(PALOBJ *PalObj, for(i=Start; iIndexedColors[i]; + PaletteEntry[i] = RGB( + PalGDI->IndexedColors[i].peRed, + PalGDI->IndexedColors[i].peGreen, + PalGDI->IndexedColors[i].peBlue); } return Colors; diff --git a/reactos/subsys/win32k/eng/xlate.c b/reactos/subsys/win32k/eng/xlate.c index d0a35121ff1..15f8eca69fb 100644 --- a/reactos/subsys/win32k/eng/xlate.c +++ b/reactos/subsys/win32k/eng/xlate.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: xlate.c,v 1.26 2003/12/19 22:58:47 navaraf Exp $ +/* $Id: xlate.c,v 1.27 2003/12/20 10:31:32 navaraf Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -83,11 +83,10 @@ static ULONG FASTCALL ShiftAndMask(XLATEGDI *XlateGDI, ULONG Color) // Takes indexed palette and a ULONG STDCALL -ClosestColorMatch(XLATEGDI *XlateGDI, ULONG SourceColor, ULONG *DestColors, - ULONG NumColors) +ClosestColorMatch(XLATEGDI *XlateGDI, ULONG SourceColor, + PALETTEENTRY *DestColors, ULONG NumColors) { - PVIDEO_CLUTDATA cSourceColor; - PVIDEO_CLUTDATA cDestColors; + LPPALETTEENTRY cSourceColor; LONG idx = 0; ULONG i; ULONG SourceRGB; @@ -106,25 +105,23 @@ ClosestColorMatch(XLATEGDI *XlateGDI, ULONG SourceColor, ULONG *DestColors, { /* FIXME: must use bitfields */ SourceRGB = ShiftAndMask(XlateGDI, SourceColor); - cSourceColor = (PVIDEO_CLUTDATA) &SourceRGB; + cSourceColor = (LPPALETTEENTRY) &SourceRGB; } else { - cSourceColor = (PVIDEO_CLUTDATA)&SourceColor; + cSourceColor = (LPPALETTEENTRY)&SourceColor; } - SourceRed = cSourceColor->Red; - SourceGreen = cSourceColor->Green; - SourceBlue = cSourceColor->Blue; + SourceRed = cSourceColor->peRed; + SourceGreen = cSourceColor->peGreen; + SourceBlue = cSourceColor->peBlue; for (i=0; iRed); + cxRed = (SourceRed - DestColors[i].peRed); cxRed *= cxRed; //compute cxRed squared - cxGreen = (SourceGreen - cDestColors->Green); + cxGreen = (SourceGreen - DestColors[i].peGreen); cxGreen *= cxGreen; - cxBlue = (SourceBlue - cDestColors->Blue); + cxBlue = (SourceBlue - DestColors[i].peBlue); cxBlue *= cxBlue; rt = /* sqrt */ (cxRed + cxGreen + cxBlue); @@ -152,7 +149,7 @@ IndexedToIndexedTranslationTable(XLATEGDI *XlateGDI, ULONG *TranslationTable, Trivial = TRUE; for(i=0; iNumColors; i++) { - TranslationTable[i] = ClosestColorMatch(XlateGDI, PalSource->IndexedColors[i], PalDest->IndexedColors, PalDest->NumColors); + TranslationTable[i] = ClosestColorMatch(XlateGDI, *((ULONG*)&PalSource->IndexedColors[i]), PalDest->IndexedColors, PalDest->NumColors); Trivial = Trivial && (TranslationTable[i] == i); } if (Trivial) diff --git a/reactos/subsys/win32k/include/color.h b/reactos/subsys/win32k/include/color.h index 5aaed89a0bd..6b56cc593c7 100644 --- a/reactos/subsys/win32k/include/color.h +++ b/reactos/subsys/win32k/include/color.h @@ -5,7 +5,6 @@ const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate (VOID); COLORREF STDCALL COLOR_LookupNearestColor (PALETTEENTRY* palPalEntry, INT size, COLORREF color); INT STDCALL COLOR_PaletteLookupExactIndex (PALETTEENTRY* palPalEntry, INT size, COLORREF col); INT STDCALL COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size, PXLATEOBJ XlateObj, COLORREF col, BOOL skipReserved); -ULONG FASTCALL NtGdiGetSysColor(int nIndex); HBRUSH STDCALL NtGdiGetSysColorBrush(int nIndex); #endif /* _WIN32K_COLOR_H */ diff --git a/reactos/subsys/win32k/include/palette.h b/reactos/subsys/win32k/include/palette.h index a194c4071d7..dca8ddd6b63 100644 --- a/reactos/subsys/win32k/include/palette.h +++ b/reactos/subsys/win32k/include/palette.h @@ -19,7 +19,7 @@ typedef struct _PALGDI { HPALETTE Self; ULONG Mode; // PAL_INDEXED, PAL_BITFIELDS, PAL_RGB, PAL_BGR ULONG NumColors; - ULONG *IndexedColors; + PALETTEENTRY *IndexedColors; ULONG RedMask; ULONG GreenMask; ULONG BlueMask; diff --git a/reactos/subsys/win32k/objects/color.c b/reactos/subsys/win32k/objects/color.c index 53a66d39dc2..7f181479264 100644 --- a/reactos/subsys/win32k/objects/color.c +++ b/reactos/subsys/win32k/objects/color.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: color.c,v 1.30 2003/12/19 22:58:47 navaraf Exp $ */ +/* $Id: color.c,v 1.31 2003/12/20 10:31:32 navaraf Exp $ */ // FIXME: Use PXLATEOBJ logicalToSystem instead of int *mapping @@ -28,11 +28,13 @@ #include #include #include +#include #include "../eng/handle.h" #include #include #include #include +#include #define NDEBUG #include @@ -109,48 +111,6 @@ const COLORREF SysColours[] = RGB(181, 181, 181) /* COLOR_GRADIENTINACTIVECAPTION */, }; -ULONG FASTCALL NtGdiGetSysColor(int nIndex) -{ -#if 0 - const PALETTEENTRY *p = COLOR_sysPalTemplate + (nIndex * sizeof(PALETTEENTRY)); - return RGB(p->peRed, p->peGreen, p->peBlue); -#else - if (nIndex < 0 || sizeof(SysColours) / sizeof(SysColours[0]) < nIndex) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; - } - - return SysColours[nIndex]; -#endif -} - -HPEN STDCALL NtGdiGetSysColorPen(int nIndex) -{ -#if 0 - COLORREF Col; - memcpy(&Col, COLOR_sysPalTemplate + nIndex, sizeof(COLORREF)); - return(NtGdiCreatePen(PS_SOLID, 1, Col)); -#else - static HPEN SysPens[sizeof(SysColours) / sizeof(SysColours[0])]; - - if (nIndex < 0 || sizeof(SysColours) / sizeof(SysColours[0]) < nIndex) - { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return NULL; - } - - /* FIXME should register this object with DeleteObject() so it - can't be deleted */ - if (NULL == SysPens[nIndex]) - { - SysPens[nIndex] = (HPEN)((DWORD)NtGdiCreatePen(PS_SOLID, 0, SysColours[nIndex]) | 0x00800000); - } - - return SysPens[nIndex]; -#endif -} - HBRUSH STDCALL NtGdiGetSysColorBrush(int nIndex) { static HBRUSH SysBrushes[sizeof(SysColours) / sizeof(SysColours[0])]; @@ -174,92 +134,70 @@ HBRUSH STDCALL NtGdiGetSysColorBrush(int nIndex) return SysBrushes[nIndex]; } - - const PALETTEENTRY* FASTCALL COLOR_GetSystemPaletteTemplate(void) { - return (const PALETTEENTRY*)&COLOR_sysPalTemplate; + return (const PALETTEENTRY*)&COLOR_sysPalTemplate; } -BOOL STDCALL NtGdiAnimatePalette(HPALETTE hpal, - UINT StartIndex, - UINT Entries, - CONST PPALETTEENTRY ppe) +BOOL STDCALL NtGdiAnimatePalette(HPALETTE hPalette, UINT uStartIndex, + UINT uEntries, CONST PPALETTEENTRY ppe) { -/* - if( hPal != NtGdiGetStockObject(DEFAULT_PALETTE) ) - { - PALETTEOBJ* palPtr = (PALETTEOBJ *)GDI_GetObjPtr(hPal, PALETTE_MAGIC); - if (!palPtr) return FALSE; - - if( (StartIndex + NumEntries) <= palPtr->logpalette->palNumEntries ) - { - UINT u; - for( u = 0; u < NumEntries; u++ ) - palPtr->logpalette->palPalEntry[u + StartIndex] = PaletteColors[u]; - PALETTE_Driver->pSetMapping(palPtr, StartIndex, NumEntries, hPal != hPrimaryPalette ); - GDI_ReleaseObj(hPal); - return TRUE; - } - GDI_ReleaseObj(hPal); - } - return FALSE; -*/ - UNIMPLEMENTED; + UNIMPLEMENTED; + SetLastWin32Error(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; } HPALETTE STDCALL NtGdiCreateHalftonePalette(HDC hDC) { - int i, r, g, b; - struct { - WORD Version; - WORD NumberOfEntries; - PALETTEENTRY aEntries[256]; - } Palette; + int i, r, g, b; + struct { + WORD Version; + WORD NumberOfEntries; + PALETTEENTRY aEntries[256]; + } Palette; - Palette.Version = 0x300; - Palette.NumberOfEntries = 256; - NtGdiGetSystemPaletteEntries(hDC, 0, 256, Palette.aEntries); - - for (r = 0; r < 6; r++) { - for (g = 0; g < 6; g++) { - for (b = 0; b < 6; b++) { - i = r + g*6 + b*36 + 10; - Palette.aEntries[i].peRed = r * 51; - Palette.aEntries[i].peGreen = g * 51; - Palette.aEntries[i].peBlue = b * 51; - } - } + Palette.Version = 0x300; + Palette.NumberOfEntries = 256; + if (NtGdiGetSystemPaletteEntries(hDC, 0, 256, Palette.aEntries) == 0) + { + return 0; } - for (i = 216; i < 246; i++) { - int v = (i - 216) * 8; - Palette.aEntries[i].peRed = v; - Palette.aEntries[i].peGreen = v; - Palette.aEntries[i].peBlue = v; - } + for (r = 0; r < 6; r++) + for (g = 0; g < 6; g++) + for (b = 0; b < 6; b++) + { + i = r + g*6 + b*36 + 10; + Palette.aEntries[i].peRed = r * 51; + Palette.aEntries[i].peGreen = g * 51; + Palette.aEntries[i].peBlue = b * 51; + } - return NtGdiCreatePalette((LOGPALETTE *)&Palette); + for (i = 216; i < 246; i++) + { + int v = (i - 216) * 8; + Palette.aEntries[i].peRed = v; + Palette.aEntries[i].peGreen = v; + Palette.aEntries[i].peBlue = v; + } + + return NtGdiCreatePalette((LOGPALETTE *)&Palette); } HPALETTE STDCALL NtGdiCreatePalette(CONST PLOGPALETTE palette) { - PPALOBJ PalObj; + PPALGDI PalGDI; HPALETTE NewPalette = PALETTE_AllocPalette( PAL_INDEXED, palette->palNumEntries, (PULONG)palette->palPalEntry, 0, 0, 0); - ULONG size; - PalObj = (PPALOBJ) PALETTE_LockPalette(NewPalette); + PalGDI = (PPALGDI) PALETTE_LockPalette(NewPalette); - size = sizeof(LOGPALETTE) + (palette->palNumEntries * sizeof(PALETTEENTRY)); - PalObj->logpalette = ExAllocatePool(NonPagedPool, size); - memcpy(PalObj->logpalette, palette, size); - PALETTE_ValidateFlags(PalObj->logpalette->palPalEntry, PalObj->logpalette->palNumEntries); - PalObj->logicalToSystem = NULL; + PALETTE_ValidateFlags(PalGDI->IndexedColors, PalGDI->NumColors); + PalGDI->PalObj.logicalToSystem = NULL; PALETTE_UnlockPalette(NewPalette); @@ -277,21 +215,21 @@ COLORREF STDCALL NtGdiGetNearestColor(HDC hDC, { COLORREF nearest = CLR_INVALID; PDC dc; - PPALOBJ palObj; + PPALGDI palGDI; dc = DC_LockDc(hDC); if (NULL != dc) { HPALETTE hpal = (dc->w.hPalette) ? dc->w.hPalette : NtGdiGetStockObject(DEFAULT_PALETTE); - palObj = (PPALOBJ) PALETTE_LockPalette(hpal); - if (!palObj) + palGDI = (PPALGDI) PALETTE_LockPalette(hpal); + if (!palGDI) { DC_UnlockDc(hDC); return nearest; } - nearest = COLOR_LookupNearestColor(palObj->logpalette->palPalEntry, - palObj->logpalette->palNumEntries, Color); + nearest = COLOR_LookupNearestColor(palGDI->IndexedColors, + palGDI->NumColors, Color); PALETTE_UnlockPalette(hpal); DC_UnlockDc( hDC ); } @@ -302,7 +240,6 @@ COLORREF STDCALL NtGdiGetNearestColor(HDC hDC, UINT STDCALL NtGdiGetNearestPaletteIndex(HPALETTE hpal, COLORREF Color) { -#if 1 PPALGDI palGDI = (PPALGDI) PALETTE_LockPalette(hpal); UINT index = 0; @@ -314,20 +251,6 @@ UINT STDCALL NtGdiGetNearestPaletteIndex(HPALETTE hpal, } return index; -#else - PPALOBJ palObj = (PPALOBJ) PALETTE_LockPalette(hpal); - UINT index = 0; - - if (NULL != palObj) - { - /* Return closest match for the given RGB color */ - ASSERT(palObj->logpalette != NULL); - index = COLOR_PaletteLookupPixel(palObj->logpalette->palPalEntry, palObj->logpalette->palNumEntries, NULL, Color, FALSE); - PALETTE_UnlockPalette(hpal); - } - - return index; -#endif } UINT STDCALL NtGdiGetPaletteEntries(HPALETTE hpal, @@ -335,16 +258,16 @@ UINT STDCALL NtGdiGetPaletteEntries(HPALETTE hpal, UINT Entries, LPPALETTEENTRY pe) { - PPALOBJ palPtr; + PPALGDI palGDI; UINT numEntries; - palPtr = (PPALOBJ) PALETTE_LockPalette(hpal); - if (NULL == palPtr) + palGDI = (PPALGDI) PALETTE_LockPalette(hpal); + if (NULL == palGDI) { return 0; } - numEntries = palPtr->logpalette->palNumEntries; + numEntries = palGDI->NumColors; if (numEntries < StartIndex + Entries) { Entries = numEntries - StartIndex; @@ -356,7 +279,7 @@ UINT STDCALL NtGdiGetPaletteEntries(HPALETTE hpal, PALETTE_UnlockPalette(hpal); return 0; } - memcpy(pe, &palPtr->logpalette->palPalEntry[StartIndex], Entries * sizeof(PALETTEENTRY)); + memcpy(pe, &palGDI->IndexedColors[StartIndex], Entries * sizeof(PALETTEENTRY)); for (numEntries = 0; numEntries < Entries; numEntries++) { if (pe[numEntries].peFlags & 0xF0) @@ -448,7 +371,7 @@ UINT STDCALL NtGdiRealizePalette(HDC hDC) palPtr = (PPALOBJ) palGDI; // Step 1: Create mapping of system palette\DC palette - realized = PALETTE_SetMapping(palPtr, 0, palPtr->logpalette->palNumEntries, + realized = PALETTE_SetMapping(palPtr, 0, palGDI->NumColors, (dc->w.hPalette != hPrimaryPalette) || (dc->w.hPalette == NtGdiGetStockObject(DEFAULT_PALETTE))); @@ -466,7 +389,7 @@ UINT STDCALL NtGdiRealizePalette(HDC hDC) } else { if(SurfGDI->SetPalette) { - success = SurfGDI->SetPalette(dc->PDev, sysPtr, 0, 0, sysPtr->logpalette->palNumEntries); + success = SurfGDI->SetPalette(dc->PDev, sysPtr, 0, 0, sysGDI->NumColors); } } @@ -583,13 +506,13 @@ UINT STDCALL NtGdiSetPaletteEntries(HPALETTE hpal, UINT Entries, CONST LPPALETTEENTRY pe) { - PPALOBJ palPtr; + PPALGDI palGDI; WORD numEntries; - palPtr = (PPALOBJ)PALETTE_LockPalette(hpal); - if (!palPtr) return 0; + palGDI = PALETTE_LockPalette(hpal); + if (!palGDI) return 0; - numEntries = palPtr->logpalette->palNumEntries; + numEntries = palGDI->NumColors; if (Start >= numEntries) { PALETTE_UnlockPalette(hpal); @@ -599,46 +522,39 @@ UINT STDCALL NtGdiSetPaletteEntries(HPALETTE hpal, { Entries = numEntries - Start; } - memcpy(&palPtr->logpalette->palPalEntry[Start], pe, Entries * sizeof(PALETTEENTRY)); - PALETTE_ValidateFlags(palPtr->logpalette->palPalEntry, palPtr->logpalette->palNumEntries); - ExFreePool(palPtr->logicalToSystem); - palPtr->logicalToSystem = NULL; + memcpy(&palGDI->IndexedColors[Start], pe, Entries * sizeof(PALETTEENTRY)); + PALETTE_ValidateFlags(palGDI->IndexedColors, palGDI->NumColors); + ExFreePool(palGDI->PalObj.logicalToSystem); + palGDI->PalObj.logicalToSystem = NULL; PALETTE_UnlockPalette(hpal); return Entries; } -UINT STDCALL NtGdiSetSystemPaletteUse(HDC hDC, - UINT Usage) +UINT STDCALL +NtGdiSetSystemPaletteUse(HDC hDC, UINT Usage) { - UNIMPLEMENTED; + UNIMPLEMENTED; } -BOOL STDCALL NtGdiUnrealizeObject(HGDIOBJ hgdiobj) +BOOL STDCALL +NtGdiUnrealizeObject(HGDIOBJ hgdiobj) { - UNIMPLEMENTED; + UNIMPLEMENTED; } -BOOL STDCALL NtGdiUpdateColors(HDC hDC) +BOOL STDCALL +NtGdiUpdateColors(HDC hDC) { - //PDC dc; - //HWND hWnd; - //int size; -/* - if (!(dc = AccessUserObject(hDC))) return 0; - size = dc->GDIInfo->ulNumPalReg; -// GDI_ReleaseObj( hDC ); + HWND hWnd; - if (Callout.WindowFromDC) - { - hWnd = Callout.WindowFromDC( hDC ); - - // Docs say that we have to remap current drawable pixel by pixel - // but it would take forever given the speed of XGet/PutPixel. - if (hWnd && size) Callout.RedrawWindow( hWnd, NULL, 0, RDW_INVALIDATE ); - } */ - // FIXME UNIMPLEMENTED - return 0x666; + hWnd = IntWindowFromDC(hDC); + if (hWnd == NULL) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + return FALSE; + } + return NtUserRedrawWindow(hWnd, NULL, 0, RDW_INVALIDATE); } INT STDCALL COLOR_PaletteLookupPixel(PALETTEENTRY *palPalEntry, INT size, diff --git a/reactos/subsys/win32k/objects/dib.c b/reactos/subsys/win32k/objects/dib.c index 58005b20f3d..82a8f8dd367 100644 --- a/reactos/subsys/win32k/objects/dib.c +++ b/reactos/subsys/win32k/objects/dib.c @@ -1,5 +1,5 @@ /* - * $Id: dib.c,v 1.37 2003/12/07 10:31:56 navaraf Exp $ + * $Id: dib.c,v 1.38 2003/12/20 10:31:32 navaraf Exp $ * * ReactOS W32 Subsystem * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team @@ -44,12 +44,12 @@ UINT STDCALL NtGdiSetDIBColorTable(HDC hDC, { PDC dc; PALETTEENTRY * palEntry; - PPALOBJ palette; + PPALGDI palette; const RGBQUAD *end; if (!(dc = (PDC)AccessUserObject((ULONG)hDC))) return 0; - if (!(palette = (PPALOBJ)PALETTE_LockPalette((ULONG)dc->DevInfo->hpalDefault))) + if (!(palette = PALETTE_LockPalette((ULONG)dc->DevInfo->hpalDefault))) { // GDI_ReleaseObj( hdc ); return 0; @@ -59,12 +59,12 @@ UINT STDCALL NtGdiSetDIBColorTable(HDC hDC, if (dc->w.bitsPerPixel <= 8) { - palEntry = palette->logpalette->palPalEntry + StartIndex; + palEntry = palette->IndexedColors + StartIndex; if (StartIndex + Entries > (UINT) (1 << dc->w.bitsPerPixel)) Entries = (1 << dc->w.bitsPerPixel) - StartIndex; - if (StartIndex + Entries > palette->logpalette->palNumEntries) - Entries = palette->logpalette->palNumEntries - StartIndex; + if (StartIndex + Entries > palette->NumColors) + Entries = palette->NumColors - StartIndex; for (end = Colors + Entries; Colors < end; palEntry++, Colors++) { @@ -892,11 +892,11 @@ DIB_MapPaletteColors(PDC dc, CONST BITMAPINFO* lpbmi) RGBQUAD *lpRGB; ULONG nNumColors,i; DWORD *lpIndex; - PPALOBJ palObj; + PPALGDI palGDI; - palObj = (PPALOBJ) PALETTE_LockPalette(dc->DevInfo->hpalDefault); + palGDI = PALETTE_LockPalette(dc->DevInfo->hpalDefault); - if (NULL == palObj) + if (NULL == palGDI) { // RELEASEDCINFO(hDC); return NULL; @@ -913,9 +913,9 @@ DIB_MapPaletteColors(PDC dc, CONST BITMAPINFO* lpbmi) for (i = 0; i < nNumColors; i++) { - lpRGB[i].rgbRed = palObj->logpalette->palPalEntry[*lpIndex].peRed; - lpRGB[i].rgbGreen = palObj->logpalette->palPalEntry[*lpIndex].peGreen; - lpRGB[i].rgbBlue = palObj->logpalette->palPalEntry[*lpIndex].peBlue; + lpRGB[i].rgbRed = palGDI->IndexedColors[*lpIndex].peRed; + lpRGB[i].rgbGreen = palGDI->IndexedColors[*lpIndex].peGreen; + lpRGB[i].rgbBlue = palGDI->IndexedColors[*lpIndex].peBlue; lpIndex++; } // RELEASEDCINFO(hDC); diff --git a/reactos/subsys/win32k/objects/palette.c b/reactos/subsys/win32k/objects/palette.c index d68430b634d..9168d0d5691 100644 --- a/reactos/subsys/win32k/objects/palette.c +++ b/reactos/subsys/win32k/objects/palette.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: palette.c,v 1.13 2003/09/25 15:15:03 fireball Exp $ */ +/* $Id: palette.c,v 1.14 2003/12/20 10:31:32 navaraf Exp $ */ #undef WIN32_LEAN_AND_MEAN #include @@ -185,9 +185,10 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO int index, iRemapped = 0; int *mapping; HPALETTE hSysPal = NtGdiGetStockObject(DEFAULT_PALETTE); - PPALOBJ pSysPal = (PPALOBJ)PALETTE_LockPalette(hSysPal); + PPALGDI pSysPal = PALETTE_LockPalette(hSysPal); + PPALGDI palGDI = (PPALGDI) palPtr; - COLOR_sysPal = pSysPal->logpalette->palPalEntry; + COLOR_sysPal = pSysPal->IndexedColors; PALETTE_UnlockPalette(hSysPal); // FIXME: Is this a right way to obtain pointer to the system palette? @@ -200,7 +201,7 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO //mapping = HeapReAlloc( GetProcessHeap(), 0, palPtr->mapping, // sizeof(int)*palPtr->logpalette->palNumEntries); ExFreePool(palPtr->mapping); - mapping = ExAllocatePool(NonPagedPool, sizeof(int)*palPtr->logpalette->palNumEntries); + mapping = ExAllocatePool(NonPagedPool, sizeof(int)*palGDI->NumColors); palPtr->mapping = mapping; @@ -209,11 +210,11 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO index = -1; flag = PC_SYS_USED; - switch( palPtr->logpalette->palPalEntry[uStart].peFlags & 0x07 ) + switch( palGDI->IndexedColors[uStart].peFlags & 0x07 ) { case PC_EXPLICIT: // palette entries are indices into system palette // The PC_EXPLICIT flag is used to copy an entry from the system palette into the logical palette - index = *(WORD*)(palPtr->logpalette->palPalEntry + uStart); + index = *(WORD*)(palGDI->IndexedColors + uStart); if(index > 255 || (index >= COLOR_gapStart && index <= COLOR_gapEnd)) { DbgPrint("Win32k: PC_EXPLICIT: idx %d out of system palette, assuming black.\n", index); @@ -228,7 +229,7 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO // fall through default: // try to collapse identical colors index = COLOR_PaletteLookupExactIndex(COLOR_sysPal, 256, - *(COLORREF*)(palPtr->logpalette->palPalEntry + uStart)); + *(COLORREF*)(palGDI->IndexedColors + uStart)); // fall through case PC_NOCOLLAPSE: @@ -271,9 +272,9 @@ INT STDCALL PALETTE_SetMapping(PPALOBJ palPtr, UINT uStart, UINT uNum, BOOL mapO // we have to map to existing entry in the system palette index = COLOR_PaletteLookupPixel(COLOR_sysPal, 256, NULL, - *(COLORREF*)(palPtr->logpalette->palPalEntry + uStart), TRUE); + *(COLORREF*)(palGDI->IndexedColors + uStart), TRUE); } - palPtr->logpalette->palPalEntry[uStart].peFlags |= PC_SYS_USED; + palGDI->IndexedColors[uStart].peFlags |= PC_SYS_USED; /* if(PALETTE_PaletteToXPixel) index = PALETTE_PaletteToXPixel[index]; FIXME */ break;