3 #define PALETTE_FIXED 0x0001 /* read-only colormap - have to use XAllocColor (if not virtual) */
4 #define PALETTE_VIRTUAL 0x0002 /* no mapping needed - pixel == pixel color */
6 #define PALETTE_PRIVATE 0x1000 /* private colormap, identity mapping */
7 #define PALETTE_WHITESET 0x2000
10 #ifndef __WINDDI_H // Defined in ddk/winddi.h
11 #define PAL_INDEXED 0x00000001 // Indexed palette
12 #define PAL_BITFIELDS 0x00000002 // Bit fields used for DIB, DIB section
13 #define PAL_RGB 0x00000004 // Red, green, blue
14 #define PAL_BGR 0x00000008 // Blue, green, red
15 #define PAL_CMYK 0x00000010 // Cyan, magenta, yellow, black
17 #define PAL_DC 0x00000100
18 #define PAL_FIXED 0x00000200 // Can't be changed
19 #define PAL_FREE 0x00000400
20 #define PAL_MANAGED 0x00000800
21 #define PAL_NOSTATIC 0x00001000
22 #define PAL_MONOCHROME 0x00002000 // Two colors only
23 #define PAL_BRUSHHACK 0x00004000
24 #define PAL_DIBSECTION 0x00008000 // Used for a DIB section
25 #define PAL_NOSTATIC256 0x00010000
26 #define PAL_HT 0x00100000 // Halftone palette
27 #define PAL_RGB16_555 0x00200000 // 16-bit RGB in 555 format
28 #define PAL_RGB16_565 0x00400000 // 16-bit RGB in 565 format
29 #define PAL_GAMMACORRECTION 0x00800000 // Correct colors
32 typedef struct _PALETTE
34 /* Header for all gdi objects in the handle table.
35 Do not (re)move this. */
36 BASEOBJECT BaseObject
;
39 XLATEOBJ
*logicalToSystem
;
41 FLONG flFlags
; // PAL_INDEXED, PAL_BITFIELDS, PAL_RGB, PAL_BGR
43 PALETTEENTRY
*IndexedColors
;
53 extern PALETTE gpalRGB
, gpalBGR
, gpalMono
, gpalRGB555
, gpalRGB565
, *gppalDefault
;
54 extern PPALETTE appalSurfaceDefault
[];
56 HPALETTE FASTCALL
PALETTE_AllocPalette(ULONG Mode
,
62 HPALETTE FASTCALL
PALETTE_AllocPaletteIndexedRGB(ULONG NumColors
,
63 CONST RGBQUAD
*Colors
);
64 #define PALETTE_FreePalette(pPalette) GDIOBJ_FreeObj((POBJ)pPalette, GDIObjType_PAL_TYPE)
65 #define PALETTE_FreePaletteByHandle(hPalette) GDIOBJ_FreeObjByHandle((HGDIOBJ)hPalette, GDI_OBJECT_TYPE_PALETTE)
66 #define PALETTE_UnlockPalette(pPalette) GDIOBJ_vUnlockObject((POBJ)pPalette)
68 #define PALETTE_ShareLockPalette(hpal) \
69 ((PPALETTE)GDIOBJ_ShareLockObj((HGDIOBJ)hpal, GDI_OBJECT_TYPE_PALETTE))
70 #define PALETTE_ShareUnlockPalette(ppal) \
71 GDIOBJ_vDereferenceObject(&ppal->BaseObject)
73 BOOL NTAPI
PALETTE_Cleanup(PVOID ObjectBody
);
74 INIT_FUNCTION NTSTATUS NTAPI
InitPaletteImpl(VOID
);
75 VOID FASTCALL
PALETTE_ValidateFlags (PALETTEENTRY
* lpPalE
, INT size
);
76 INT FASTCALL
PALETTE_ToPhysical (PDC dc
, COLORREF color
);
78 INT FASTCALL
PALETTE_GetObject(PPALETTE pGdiObject
, INT cbCount
, LPLOGBRUSH lpBuffer
);
79 ULONG NTAPI
PALETTE_ulGetNearestPaletteIndex(PALETTE
* ppal
, ULONG iColor
);
80 ULONG NTAPI
PALETTE_ulGetNearestIndex(PALETTE
* ppal
, ULONG iColor
);
81 ULONG NTAPI
PALETTE_ulGetNearestBitFieldsIndex(PALETTE
* ppal
, ULONG ulColor
);
82 VOID NTAPI
PALETTE_vGetBitMasks(PPALETTE ppal
, PULONG pulColors
);
84 PPALETTEENTRY FASTCALL
ReturnSystemPalette (VOID
);
85 HPALETTE FASTCALL
GdiSelectPalette(HDC
, HPALETTE
, BOOL
);
89 CalculateShift(ULONG ulMask1
, ULONG ulMask2
)
91 ULONG ulShift1
, ulShift2
;
92 BitScanReverse(&ulShift1
, ulMask1
);
93 BitScanReverse(&ulShift2
, ulMask2
);
95 if ((INT
)ulShift2
< 0) ulShift2
+= 32;
101 PALETTE_ulGetRGBColorFromIndex(PPALETTE ppal
, ULONG ulIndex
)
103 return RGB(ppal
->IndexedColors
[ulIndex
].peRed
,
104 ppal
->IndexedColors
[ulIndex
].peGreen
,
105 ppal
->IndexedColors
[ulIndex
].peBlue
);