ReactOS 0.4.16-dev-106-g10b08aa
palette.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef _MSC_VER
4#pragma warning(disable:4200) // zero-sized array in struct/union
5#endif // _MSC_VER
6
7// Palette mode flags
9{
10#ifndef _WINDDI_ // Defined in ddk/winddi.h
11 PAL_INDEXED = 0x00000001, // Indexed palette
12 PAL_BITFIELDS = 0x00000002, // Bit fields used for DIB, DIB section
13 PAL_RGB = 0x00000004, // Red, green, blue
14 PAL_BGR = 0x00000008, // Blue, green, red
15 PAL_CMYK = 0x00000010, // Cyan, magenta, yellow, black
16#endif
17 PAL_DC = 0x00000100,
18 PAL_FIXED = 0x00000200, // Can't be changed
19 PAL_FREE = 0x00000400,
20 PAL_MANAGED = 0x00000800,
21 PAL_NOSTATIC = 0x00001000,
22 PAL_MONOCHROME = 0x00002000, // Two colors only
23 PAL_BRUSHHACK = 0x00004000,
24 PAL_DIBSECTION = 0x00008000, // Used for a DIB section
25 PAL_NOSTATIC256 = 0x00010000,
26 PAL_HT = 0x00100000, // Halftone palette
27 PAL_RGB16_555 = 0x00200000, // 16-bit RGB in 555 format
28 PAL_RGB16_565 = 0x00400000, // 16-bit RGB in 565 format
29 PAL_GAMMACORRECTION = 0x00800000, // Correct colors
30};
31
32typedef struct _PALETTE
33{
34 /* Header for all gdi objects in the handle table.
35 Do not (re)move this. */
37
40 FLONG flFlags; // PAL_INDEXED, PAL_BITFIELDS, PAL_RGB, PAL_BGR
49 HDEV hPDev;
52
55
56#define PALETTE_UnlockPalette(pPalette) GDIOBJ_vUnlockObject((POBJ)pPalette)
57#define PALETTE_ShareLockPalette(hpal) \
58 ((PPALETTE)GDIOBJ_ShareLockObj((HGDIOBJ)hpal, GDI_OBJECT_TYPE_PALETTE))
59#define PALETTE_ShareUnlockPalette(ppal) \
60 GDIOBJ_vDereferenceObject(&ppal->BaseObject)
61
62CODE_SEG("INIT")
66
71 _In_ ULONG cColors,
72 _In_opt_ const PALETTEENTRY* pEntries,
73 _In_ FLONG flRed,
74 _In_ FLONG flGreen,
75 _In_ FLONG flBlue);
76
81 _In_ ULONG cColors,
82 _In_opt_ const PALETTEENTRY* pEntries,
83 _In_ FLONG flRed,
84 _In_ FLONG flGreen,
85 _In_ FLONG flBlue);
86
87VOID
90 PALETTEENTRY* lpPalE,
91 INT size);
92
93INT
96 PPALETTE pGdiObject,
99
100ULONG
101NTAPI
103 PPALETTE ppal,
104 ULONG iColor);
105
106ULONG
107NTAPI
109 PPALETTE ppal,
110 ULONG iColor);
111
112ULONG
113NTAPI
115 PPALETTE ppal,
116 ULONG ulColor);
117
118VOID
119NTAPI
121 PPALETTE ppal,
122 PULONG pulColors);
123
124VOID
125NTAPI
126PALETTE_vCleanup(PVOID ObjectBody);
127
129ULONG
130CalculateShift(ULONG ulMask1, ULONG ulMask2)
131{
132 ULONG ulShift1, ulShift2;
133 BitScanReverse(&ulShift1, ulMask1);
134 BitScanReverse(&ulShift2, ulMask2);
135 ulShift2 -= ulShift1;
136 if ((INT)ulShift2 < 0) ulShift2 += 32;
137 return ulShift2;
138}
139
141ULONG
143{
144 if (ulIndex >= ppal->NumColors) return 0;
145 return RGB(ppal->IndexedColors[ulIndex].peRed,
146 ppal->IndexedColors[ulIndex].peGreen,
147 ppal->IndexedColors[ulIndex].peBlue);
148}
149
151VOID
153{
154 if (ulIndex >= ppal->NumColors) return;
155 ppal->IndexedColors[ulIndex].peRed = GetRValue(crColor);
156 ppal->IndexedColors[ulIndex].peGreen = GetGValue(crColor);
157 ppal->IndexedColors[ulIndex].peBlue = GetBValue(crColor);
158}
159
160HPALETTE
161NTAPI
163 IN LPLOGPALETTE pLogPal,
165
#define CODE_SEG(...)
LONG NTSTATUS
Definition: precomp.h:26
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define RGB(r, g, b)
Definition: precomp.h:71
#define GetBValue(quad)
Definition: precomp.h:75
#define GetGValue(quad)
Definition: precomp.h:74
#define GetRValue(quad)
Definition: precomp.h:73
GLsizeiptr size
Definition: glext.h:5919
#define BitScanReverse
Definition: interlocked.h:6
static int cbCount
Definition: fiber.c:42
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
unsigned int UINT
Definition: ndis.h:50
#define FASTCALL
Definition: nt_native.h:50
unsigned long FLONG
Definition: ntbasedef.h:366
ULONG BlueMask
Definition: palette.h:45
HDEV hPDev
Definition: palette.h:49
ULONG GreenMask
Definition: palette.h:44
BASEOBJECT BaseObject
Definition: palette.h:36
ULONG NumColors
Definition: palette.h:41
ULONG ulGreenShift
Definition: palette.h:47
PALETTEENTRY * IndexedColors
Definition: palette.h:42
XLATEOBJ * logicalToSystem
Definition: palette.h:39
PALETTEENTRY apalColors[0]
Definition: palette.h:50
FLONG flFlags
Definition: palette.h:40
ULONG ulBlueShift
Definition: palette.h:48
ULONG ulRedShift
Definition: palette.h:46
ULONG RedMask
Definition: palette.h:43
PALOBJ PalObj
Definition: palette.h:38
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
int32_t INT
Definition: typedefs.h:58
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define FORCEINLINE
Definition: wdftypes.h:67
ULONG NTAPI PALETTE_ulGetNearestPaletteIndex(PPALETTE ppal, ULONG iColor)
struct _PALETTE * PPALETTE
struct _PALETTE PALETTE
VOID FASTCALL PALETTE_ValidateFlags(PALETTEENTRY *lpPalE, INT size)
Definition: palette.c:125
FORCEINLINE VOID PALETTE_vSetRGBColorForIndex(PPALETTE ppal, ULONG ulIndex, COLORREF crColor)
Definition: palette.h:152
_PALFLAGS
Definition: palette.h:9
@ PAL_DC
Definition: palette.h:17
@ PAL_NOSTATIC256
Definition: palette.h:25
@ PAL_MONOCHROME
Definition: palette.h:22
@ PAL_RGB16_565
Definition: palette.h:28
@ PAL_BGR
Definition: palette.h:14
@ PAL_INDEXED
Definition: palette.h:11
@ PAL_HT
Definition: palette.h:26
@ PAL_RGB
Definition: palette.h:13
@ PAL_BRUSHHACK
Definition: palette.h:23
@ PAL_FREE
Definition: palette.h:19
@ PAL_MANAGED
Definition: palette.h:20
@ PAL_NOSTATIC
Definition: palette.h:21
@ PAL_FIXED
Definition: palette.h:18
@ PAL_BITFIELDS
Definition: palette.h:12
@ PAL_RGB16_555
Definition: palette.h:27
@ PAL_CMYK
Definition: palette.h:15
@ PAL_GAMMACORRECTION
Definition: palette.h:29
@ PAL_DIBSECTION
Definition: palette.h:24
VOID NTAPI PALETTE_vCleanup(PVOID ObjectBody)
Definition: palette.c:236
FORCEINLINE ULONG CalculateShift(ULONG ulMask1, ULONG ulMask2)
Definition: palette.h:130
PALETTE * gppalMono
Definition: palette.h:53
PPALETTE NTAPI PALETTE_AllocPalWithHandle(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:209
HPALETTE NTAPI GreCreatePaletteInternal(IN LPLOGPALETTE pLogPal, IN UINT cEntries)
Definition: palette.c:448
PPALETTE NTAPI PALETTE_AllocPalette(_In_ ULONG iMode, _In_ ULONG cColors, _In_opt_ const PALETTEENTRY *pEntries, _In_ FLONG flRed, _In_ FLONG flGreen, _In_ FLONG flBlue)
Definition: palette.c:135
INT FASTCALL PALETTE_GetObject(PPALETTE pGdiObject, INT cbCount, LPLOGBRUSH lpBuffer)
Definition: palette.c:247
NTSTATUS NTAPI InitPaletteImpl(VOID)
Definition: palette.c:66
PALETTE gpalRGB555
Definition: palette.h:53
ULONG NTAPI PALETTE_ulGetNearestBitFieldsIndex(PPALETTE ppal, ULONG ulColor)
PALETTE gpalRGB
Definition: palette.c:20
PALETTE * gppalDefault
Definition: palette.h:53
PALETTE gpalBGR
Definition: palette.h:53
FORCEINLINE ULONG PALETTE_ulGetRGBColorFromIndex(PPALETTE ppal, ULONG ulIndex)
Definition: palette.h:142
VOID NTAPI PALETTE_vGetBitMasks(PPALETTE ppal, PULONG pulColors)
Definition: palette.c:322
ULONG NTAPI PALETTE_ulGetNearestIndex(PPALETTE ppal, ULONG iColor)
PALETTE gpalRGB565
Definition: palette.h:53
PPALETTE appalSurfaceDefault[]
Definition: palette.c:21
_In_ ULONG iMode
Definition: winddi.h:3520
DWORD COLORREF
Definition: windef.h:300
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3621
_In_ ULONG iColor
Definition: xlateobj.h:17
#define const
Definition: zconf.h:233