4 #ifndef __WINDDI_H // Defined in ddk/winddi.h
5 #define PAL_INDEXED 0x00000001 // Indexed palette
6 #define PAL_BITFIELDS 0x00000002 // Bit fields used for DIB, DIB section
7 #define PAL_RGB 0x00000004 // Red, green, blue
8 #define PAL_BGR 0x00000008 // Blue, green, red
9 #define PAL_CMYK 0x00000010 // Cyan, magenta, yellow, black
11 #define PAL_DC 0x00000100
12 #define PAL_FIXED 0x00000200 // Can't be changed
13 #define PAL_FREE 0x00000400
14 #define PAL_MANAGED 0x00000800
15 #define PAL_NOSTATIC 0x00001000
16 #define PAL_MONOCHROME 0x00002000 // Two colors only
17 #define PAL_BRUSHHACK 0x00004000
18 #define PAL_DIBSECTION 0x00008000 // Used for a DIB section
19 #define PAL_NOSTATIC256 0x00010000
20 #define PAL_HT 0x00100000 // Halftone palette
21 #define PAL_RGB16_555 0x00200000 // 16-bit RGB in 555 format
22 #define PAL_RGB16_565 0x00400000 // 16-bit RGB in 565 format
23 #define PAL_GAMMACORRECTION 0x00800000 // Correct colors
25 typedef struct _PALETTE
27 /* Header for all gdi objects in the handle table.
28 Do not (re)move this. */
29 BASEOBJECT BaseObject
;
32 XLATEOBJ
*logicalToSystem
;
33 FLONG flFlags
; // PAL_INDEXED, PAL_BITFIELDS, PAL_RGB, PAL_BGR
35 PALETTEENTRY
*IndexedColors
;
43 PALETTEENTRY apalColors
[0];
46 extern PALETTE gpalRGB
, gpalBGR
, gpalMono
, gpalRGB555
, gpalRGB565
, *gppalDefault
;
47 extern PPALETTE appalSurfaceDefault
[];
49 #define PALETTE_UnlockPalette(pPalette) GDIOBJ_vUnlockObject((POBJ)pPalette)
50 #define PALETTE_ShareLockPalette(hpal) \
51 ((PPALETTE)GDIOBJ_ShareLockObj((HGDIOBJ)hpal, GDI_OBJECT_TYPE_PALETTE))
52 #define PALETTE_ShareUnlockPalette(ppal) \
53 GDIOBJ_vDereferenceObject(&ppal->BaseObject)
58 InitPaletteImpl(VOID
);
65 _In_ PULONG pulColors
,
72 PALETTE_AllocPalWithHandle(
75 _In_ PULONG pulColors
,
82 PALETTE_ValidateFlags(
95 PALETTE_ulGetNearestPaletteIndex(
101 PALETTE_ulGetNearestIndex(
107 PALETTE_ulGetNearestBitFieldsIndex(
113 PALETTE_vGetBitMasks(
119 PALETTE_Cleanup(PVOID ObjectBody
);
123 CalculateShift(ULONG ulMask1
, ULONG ulMask2
)
125 ULONG ulShift1
, ulShift2
;
126 BitScanReverse(&ulShift1
, ulMask1
);
127 BitScanReverse(&ulShift2
, ulMask2
);
128 ulShift2
-= ulShift1
;
129 if ((INT
)ulShift2
< 0) ulShift2
+= 32;
135 PALETTE_ulGetRGBColorFromIndex(PPALETTE ppal
, ULONG ulIndex
)
137 if (ulIndex
>= ppal
->NumColors
) return 0;
138 return RGB(ppal
->IndexedColors
[ulIndex
].peRed
,
139 ppal
->IndexedColors
[ulIndex
].peGreen
,
140 ppal
->IndexedColors
[ulIndex
].peBlue
);
145 GreCreatePaletteInternal(
146 IN LPLOGPALETTE pLogPal
,