15#define PAL_SETPOWNER 0x8000
16#define MAX_PALCOLORS 65536
57 for (wBits = 0; dwMask; dwMask = dwMask & (dwMask - 1))
129 lpPalE[
i].peFlags =
PC_SYS_USED | (lpPalE[
i].peFlags & 0x07);
150 if ((cColors == 0) || (cColors > 1024))
return NULL;
194 if ((flRed == 0x7c00) && (flGreen == 0x3E0) && (flBlue == 0x1F))
196 else if ((flRed == 0xF800) && (flGreen == 0x7E0) && (flBlue == 0x1F))
198 else if ((flRed == 0xFF0000) && (flGreen == 0xFF00) && (flBlue == 0xFF))
200 else if ((flRed == 0xFF) && (flGreen == 0xFF00) && (flBlue == 0xFF0000))
221 if (!ppal)
return NULL;
226 DPRINT1(
"Could not insert palette into handle table.\n");
263 ULONG ulDiff, ulColorDiff, ulMinimalDiff = 0xFFFFFF;
272 ulColorDiff = ulDiff * ulDiff;
274 ulColorDiff += ulDiff * ulDiff;
276 ulColorDiff += ulDiff * ulDiff;
279 if (ulColorDiff < ulMinimalDiff)
282 ulMinimalDiff = ulColorDiff;
285 if (ulMinimalDiff == 0)
break;
328 pulColors[0] =
RGB(0xFF, 0x00, 0x00);
329 pulColors[1] =
RGB(0x00, 0xFF, 0x00);
330 pulColors[2] =
RGB(0x00, 0x00, 0xFF);
334 pulColors[0] =
RGB(0x00, 0x00, 0xFF);
335 pulColors[1] =
RGB(0x00, 0xFF, 0x00);
336 pulColors[2] =
RGB(0xFF, 0x00, 0x00);
387 if (!ppal)
return NULL;
392 DPRINT1(
"Could not insert palette into handle table.\n");
411 if (!ppal)
return FALSE;
452 HPALETTE hpal =
NULL;
458 pLogPal->palPalEntry,
481 HPALETTE hpal =
NULL;
524 HPALETTE hpal =
NULL;
536 for (
i = 0;
i < 10;
i++)
555 for (
r = 0;
r < 6;
r++)
557 for (
g = 0;
g < 6;
g++)
559 for (
b = 0;
b < 6;
b++)
561 i =
r +
g*6 +
b*36 + 10;
569 for (
i = 216;
i < 246;
i++)
571 int v = (
i - 216) << 3;
680 if(
dc->dclevel.pSurface ==
NULL)
683 ppal =
dc->dclevel.pSurface->ppal;
693 RGB(0xff, 0xff, 0xff),
744 if (!pdc->dclevel.pSurface)
761 ppalSurf = pdc->dclevel.pSurface->ppal;
762 ppalDC = pdc->dclevel.ppal;
772 DPRINT1(
"RealizePalette unimplemented for %s\n",
773 (pdc->dctype ==
DCTYPE_MEMORY ?
"memory managed DCs" :
"device DCs"));
795 if (!palPtr)
return FALSE;
805 for (NumEntries += StartIndex; StartIndex < NumEntries; StartIndex++, pptr++)
835 if (
dc->dclevel.hpal == hPal)
868 if (numEntries < StartIndex +
Entries)
870 Entries = numEntries - StartIndex;
872 if (numEntries <= StartIndex)
896 UINT EntriesSize = 0;
907 EntriesSize =
Entries *
sizeof(pe[0]);
908 if (
Entries != EntriesSize /
sizeof(pe[0]))
940 Ret =
dc->ppdev->gdiinfo.ulNumPalReg;
970 if (!palGDI)
return 0;
973 if (
Start >= numEntries)
1000 ULONG i, iEndIndex, iResult = 0;
1010 psurf = pdc->dclevel.pSurface;
1027 (iStartIndex < ppal->NumColors))
1036 for (
i = iStartIndex;
i < iEndIndex;
i++, prgbColors++)
1050 for (
i = iStartIndex;
i < iEndIndex;
i++, prgbColors++)
1055 prgbColors->rgbReserved = 0;
1060 iResult = iEndIndex - iStartIndex;
1150 if (!bInbound && (
ret > 0))
1213 if (!calledFromUser){
1222 if (!calledFromUser){
1233 if (!calledFromUser){
1253 if (!palGDI)
return FALSE;
1275 HPALETTE hPal =
NULL;
1282 pulcSafe = ulColors;
static const ENTRY Entries[]
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
ULONG TranslateCOLORREF(PDC pdc, COLORREF crColor)
FORCEINLINE PDC DC_LockDc(HDC hdc)
HWND FASTCALL IntWindowFromDC(HDC hDc)
#define ERROR_INVALID_PARAMETER
#define ERROR_INVALID_HANDLE
static void cleanup(void)
#define ExAllocatePoolWithTag(hernya, size, tag)
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
#define GDI_OBJECT_TYPE_PALETTE
#define GDI_HANDLE_IS_TYPE(h, t)
#define GDI_HANDLE_IS_STOCKOBJ(h)
GLdouble GLdouble GLdouble r
GLboolean GLboolean GLboolean b
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Must_inspect_result_ _In_ USAGE _In_ USHORT _In_ USAGE Usage
#define EXCEPTION_EXECUTE_HANDLER
_Check_return_ unsigned int __cdecl _rotl(_In_ unsigned int _Value, _In_ int _Shift)
struct _PDEVOBJ * PPDEVOBJ
#define memcpy(s1, s2, n)
#define ExFreePoolWithTag(_P, _T)
#define _In_reads_bytes_(size)
#define _Out_writes_bytes_(size)
#define _When_(expr, annos)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiUpdateColors(_In_ HDC hdc)
__kernel_entry W32KAPI INT APIENTRY NtGdiGetDeviceCaps(_In_ HDC hdc, _In_ INT i)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiResizePalette(_In_ HPALETTE hpal, _In_ UINT cEntry)
__kernel_entry W32KAPI HPALETTE APIENTRY NtGdiCreatePaletteInternal(_In_reads_bytes_(cEntries *4+4) LPLOGPALETTE pLogPal, _In_ UINT cEntries)
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiGetStockObject(_In_ INT iObject)
__kernel_entry W32KAPI LONG APIENTRY NtGdiDoPalette(_In_ HGDIOBJ hObj, _In_ WORD iStart, _In_ WORD cEntries, _When_(bInbound!=0, _In_reads_bytes_(cEntries *sizeof(PALETTEENTRY))) _When_(bInbound==0, _Out_writes_bytes_(cEntries *sizeof(PALETTEENTRY))) LPVOID pEntries, _In_ DWORD iFunc, _In_ BOOL bInbound)
#define GDI_OBJ_HMGR_POWNED
#define GDI_OBJ_HMGR_PUBLIC
BOOL FASTCALL UserIsEntered(VOID)
VOID FASTCALL UserLeave(VOID)
VOID FASTCALL UserEnterExclusive(VOID)
static __inline VOID UserDerefObjectCo(PVOID obj)
static __inline VOID UserRefObjectCo(PVOID obj, PUSER_REFERENCE_ENTRY UserReferenceEntry)
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define _SEH2_YIELD(__stmt)
PALETTEENTRY * IndexedColors
PALETTEENTRY apalColors[0]
struct _PALETTE *const ppal
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
PWND FASTCALL UserGetWindowObject(HWND hWnd)
HDC FASTCALL UserGetWindowDC(PWND Wnd)
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
#define NB_RESERVED_COLORS
VOID NTAPI GDIOBJ_vFreeObject(POBJ pobj)
HGDIOBJ NTAPI GDIOBJ_hInsertObject(POBJ pobj, ULONG ulOwner)
POBJ NTAPI GDIOBJ_AllocateObject(UCHAR objt, ULONG cjSize, FLONG fl)
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
VOID NTAPI GDIOBJ_vReferenceObjectByPointer(POBJ pobj)
ULONG APIENTRY GreGetSetColorTable(HDC hdc, ULONG iStartIndex, ULONG cEntries, RGBQUAD *prgbColors, BOOL bSet)
COLORREF APIENTRY NtGdiGetNearestColor(_In_ HDC hDC, _In_ COLORREF Color)
const PALETTEENTRY g_sysPalTemplate[NB_RESERVED_COLORS]
UINT APIENTRY IntGetPaletteEntries(HPALETTE hpal, UINT StartIndex, UINT Entries, LPPALETTEENTRY pe)
VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY *lpPalE, INT size)
unsigned short GetNumberOfBits(unsigned int dwMask)
BOOL APIENTRY NtGdiSetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT pca)
INT FASTCALL PALETTE_GetObject(PPALETTE ppal, INT cbCount, LPLOGBRUSH lpBuffer)
BOOL APIENTRY NtGdiUnrealizeObject(HGDIOBJ hgdiobj)
VOID NTAPI PALETTE_vCleanup(PVOID ObjectBody)
PPALETTE appalSurfaceDefault[11]
ULONG NTAPI PALETTE_ulGetNearestBitFieldsIndex(PALETTE *ppal, ULONG ulColor)
__kernel_entry BOOL APIENTRY NtGdiEngDeletePalette(_In_ HPALETTE hPal)
UINT FASTCALL IntGdiRealizePalette(HDC hDC)
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
HPALETTE NTAPI GreCreatePaletteInternal(IN LPLOGPALETTE pLogPal, IN UINT cEntries)
VOID FASTCALL ColorCorrection(PPALETTE PalGDI, PPALETTEENTRY PaletteEntry, ULONG Colors)
PPALETTE NTAPI PALETTE_AllocPalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
NTSTATUS NTAPI InitPaletteImpl(VOID)
HPALETTE APIENTRY NtGdiCreateHalftonePalette(HDC hDC)
static UINT SystemPaletteUse
BOOL APIENTRY NtGdiGetColorAdjustment(HDC hdc, LPCOLORADJUSTMENT pca)
UINT APIENTRY NtGdiSetSystemPaletteUse(HDC hDC, UINT Usage)
UINT APIENTRY IntSetPaletteEntries(HPALETTE hpal, UINT Start, UINT Entries, CONST LPPALETTEENTRY pe)
UINT APIENTRY IntGetSystemPaletteEntries(HDC hDC, UINT StartIndex, UINT Entries, LPPALETTEENTRY pe)
ULONG NTAPI PALETTE_ulGetNearestIndex(PALETTE *ppal, ULONG ulColor)
UINT APIENTRY IntAnimatePalette(HPALETTE hPal, UINT StartIndex, UINT NumEntries, CONST PPALETTEENTRY PaletteColors)
UINT APIENTRY NtGdiGetSystemPaletteUse(HDC hDC)
UINT APIENTRY NtGdiGetNearestPaletteIndex(HPALETTE hpal, COLORREF crColor)
VOID NTAPI PALETTE_vGetBitMasks(PPALETTE ppal, PULONG pulColors)
__kernel_entry HPALETTE APIENTRY NtGdiEngCreatePalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_ ULONG *pulColors, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
ULONG NTAPI PALETTE_ulGetNearestPaletteIndex(PALETTE *ppal, ULONG iColor)
struct _PALETTE * PPALETTE
#define PALETTE_UnlockPalette(pPalette)
FORCEINLINE VOID PALETTE_vSetRGBColorForIndex(PPALETTE ppal, ULONG ulIndex, COLORREF crColor)
FORCEINLINE ULONG CalculateShift(ULONG ulMask1, ULONG ulMask2)
#define PALETTE_ShareLockPalette(hpal)
#define PALETTE_ShareUnlockPalette(ppal)
PWND FASTCALL UserGetDesktopWindow(VOID)
struct _GAMMARAMP * PGAMMARAMP
ENGAPI ULONG APIENTRY XLATEOBJ_iXlate(_In_ XLATEOBJ *pxlo, _In_ ULONG iColor)
_Inout_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_opt_ COLORADJUSTMENT * pca
ENGAPI BOOL APIENTRY EngDeletePalette(_In_ _Post_ptr_invalid_ HPALETTE hpal)
ENGAPI ULONG APIENTRY PALOBJ_cGetColors(_In_ PALOBJ *ppalo, _In_ ULONG iStart, _In_ ULONG cColors, _Out_writes_(cColors) ULONG *pulColors)
#define WINDDI_MAXSETPALETTECOLORS
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
_Must_inspect_result_ ENGAPI HPALETTE APIENTRY EngCreatePalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_ ULONG *pulColors, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
#define ERROR_INVALID_WINDOW_HANDLE
struct tagPALETTEENTRY PALETTEENTRY
struct tagPALETTEENTRY * PPALETTEENTRY
_In_ UINT _In_ UINT cEntries
#define SYSPAL_NOSTATIC256
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)