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