ReactOS 0.4.15-dev-8413-gc1c91f2
palette.c
Go to the documentation of this file.
1#include <precomp.h>
2
3#define NDEBUG
4#include <debug.h>
5
6
7#define NB_RESERVED_COLORS 20 /* number of fixed colors in system palette */
8
10{
11 /* first 10 entries in the system palette */
12 /* red green blue flags */
13 { 0x00, 0x00, 0x00, 0 },
14 { 0x80, 0x00, 0x00, 0 },
15 { 0x00, 0x80, 0x00, 0 },
16 { 0x80, 0x80, 0x00, 0 },
17 { 0x00, 0x00, 0x80, 0 },
18 { 0x80, 0x00, 0x80, 0 },
19 { 0x00, 0x80, 0x80, 0 },
20 { 0xc0, 0xc0, 0xc0, 0 },
21 { 0xc0, 0xdc, 0xc0, 0 },
22 { 0xa6, 0xca, 0xf0, 0 },
23
24 /* ... c_min/2 dynamic colorcells */
25
26 /* ... gap (for sparse palettes) */
27
28 /* ... c_min/2 dynamic colorcells */
29
30 { 0xff, 0xfb, 0xf0, 0 },
31 { 0xa0, 0xa0, 0xa4, 0 },
32 { 0x80, 0x80, 0x80, 0 },
33 { 0xff, 0x00, 0x00, 0 },
34 { 0x00, 0xff, 0x00, 0 },
35 { 0xff, 0xff, 0x00, 0 },
36 { 0x00, 0x00, 0xff, 0 },
37 { 0xff, 0x00, 0xff, 0 },
38 { 0x00, 0xff, 0xff, 0 },
39 { 0xff, 0xff, 0xff, 0 } /* last 10 */
40};
41
42BOOL
44AnimatePalette(HPALETTE hpal,
45 UINT iStartIndex,
47 const PALETTEENTRY *ppe)
48{
49 return NtGdiDoPalette(hpal, iStartIndex, cEntries, (PALETTEENTRY*)ppe, GdiPalAnimate, TRUE);
50}
51
52HPALETTE
55{
56 return NtGdiCreatePaletteInternal((LPLOGPALETTE)plpal, plpal->palNumEntries);
57}
58
59/*
60 * @implemented
61 */
62UINT
64GetPaletteEntries(HPALETTE hpal,
65 UINT iStartIndex,
68{
69 return NtGdiDoPalette(hpal, iStartIndex, cEntries, ppe, GdiPalGetEntries, FALSE);
70}
71
72UINT
74SetPaletteEntries(HPALETTE hpal,
75 UINT iStartIndex,
77 const PALETTEENTRY *ppe)
78{
79 return NtGdiDoPalette(hpal, iStartIndex, cEntries, (PALETTEENTRY*)ppe, GdiPalSetEntries, TRUE);
80}
81
82UINT
85 UINT iStartIndex,
88{
89 PALETTEENTRY ippe[256];
90
91 if ((INT)cEntries >= 0)
92 {
94 {
95 return NtGdiDoPalette(hDC,
96 iStartIndex,
98 ppe,
100 FALSE);
101 }
102 else if (ppe)
103 {
104 RtlCopyMemory(ippe, sys_pal_template, 10 * sizeof(PALETTEENTRY));
105 RtlCopyMemory(&ippe[246], &sys_pal_template[10], 10 * sizeof(PALETTEENTRY));
106 RtlZeroMemory(&ippe[10], sizeof(ippe) - 20 * sizeof(PALETTEENTRY));
107
108 if (iStartIndex < 256)
109 {
110 RtlCopyMemory(ppe,
111 &ippe[iStartIndex],
112 min(256 - iStartIndex, cEntries) *
113 sizeof(PALETTEENTRY));
114 }
115 }
116 }
117
118 return 0;
119}
120
121UINT
122WINAPI
124 UINT iStartIndex,
126 RGBQUAD *pColors)
127{
128 if (cEntries)
129 return NtGdiDoPalette(hDC, iStartIndex, cEntries, pColors, GdiPalGetColorTable, FALSE);
130 return 0;
131}
132
133/*
134 * @implemented
135 */
136UINT
137WINAPI
139 _In_ HDC hdc) /* [in] Handle of device context */
140{
142 {
144 }
145
147 {
148 return GDI_ERROR;
149 }
150
151 return UserRealizePalette(hdc);
152}
153
154/*
155 * @implemented
156 */
157BOOL
158WINAPI
160 HPALETTE hPalette,
161 UINT nEntries
162)
163{
164 return NtGdiResizePalette(hPalette, nEntries);
165}
166
167/*
168 * @implemented
169 */
170UINT
171WINAPI
173 UINT iStartIndex,
175 const RGBQUAD *pColors)
176{
177 UINT retValue=0;
178
179 if (cEntries)
180 {
181 retValue = NtGdiDoPalette(hDC, iStartIndex, cEntries, (RGBQUAD*)pColors, GdiPalSetColorTable, TRUE);
182 }
183
184 return retValue;
185}
186
187/*
188 * @implemented
189 */
190BOOL
191WINAPI
193 HDC hdc
194)
195{
196 ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0;
197 return NtGdiUpdateColors(hdc);
198}
199
200/*
201 * @unimplemented
202 */
203BOOL
204WINAPI
205ColorCorrectPalette(HDC hDC,HPALETTE hPalette,DWORD dwFirstEntry,DWORD dwNumOfEntries)
206{
209 return 0;
210}
211
212/* EOF */
static HDC hDC
Definition: 3dtext.c:33
#define UNIMPLEMENTED
Definition: debug.h:118
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define SetLastError(x)
Definition: compat.h:752
ULONG RGBQUAD
Definition: precomp.h:59
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL METADC_RealizePalette(HDC hdc) DECLSPEC_HIDDEN
Definition: metadc.c:1247
UINT WINAPI UserRealizePalette(HDC hDC)
Definition: painting.c:2345
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
@ GDILoObjType_LO_METADC16_TYPE
Definition: gdi_private.h:49
@ GDILoObjType_LO_DC_TYPE
Definition: gdi_private.h:34
#define NtCurrentTeb
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
#define min(a, b)
Definition: monoChain.cc:55
#define _In_
Definition: ms_sal.h:308
unsigned int UINT
Definition: ndis.h:50
__kernel_entry W32KAPI BOOL APIENTRY NtGdiUpdateColors(_In_ HDC hdc)
__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 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)
Definition: palette.c:1072
@ GdiPalSetColorTable
Definition: ntgdityp.h:32
@ GdiPalGetColorTable
Definition: ntgdityp.h:33
@ GdiPalSetEntries
Definition: ntgdityp.h:29
@ GdiPalAnimate
Definition: ntgdityp.h:28
@ GdiPalGetEntries
Definition: ntgdityp.h:30
@ GdiPalGetSystemEntries
Definition: ntgdityp.h:31
struct _W32CLIENTINFO * PW32CLIENTINFO
#define CONST
Definition: pedump.c:81
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
UINT WINAPI GetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:64
BOOL WINAPI ColorCorrectPalette(HDC hDC, HPALETTE hPalette, DWORD dwFirstEntry, DWORD dwNumOfEntries)
Definition: palette.c:205
UINT WINAPI GetDIBColorTable(HDC hDC, UINT iStartIndex, UINT cEntries, RGBQUAD *pColors)
Definition: palette.c:123
BOOL WINAPI AnimatePalette(HPALETTE hpal, UINT iStartIndex, UINT cEntries, const PALETTEENTRY *ppe)
Definition: palette.c:44
UINT WINAPI RealizePalette(_In_ HDC hdc)
Definition: palette.c:138
static const PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS]
Definition: palette.c:9
BOOL WINAPI ResizePalette(HPALETTE hPalette, UINT nEntries)
Definition: palette.c:159
#define NB_RESERVED_COLORS
Definition: palette.c:7
BOOL WINAPI UpdateColors(HDC hdc)
Definition: palette.c:192
#define WINAPI
Definition: msvc.h:6
#define RASTERCAPS
Definition: wingdi.h:745
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
UINT WINAPI GetSystemPaletteEntries(_In_ HDC hdc, _In_ UINT iStart, _In_ UINT cEntries, _Out_writes_opt_(cEntries) LPPALETTEENTRY pPalEntries)
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3621
#define GDI_ERROR
Definition: wingdi.h:1309
UINT WINAPI SetDIBColorTable(_In_ HDC hdc, _In_ UINT iStart, _In_ UINT cEntries, _In_reads_(cEntries) const RGBQUAD *prgbq)
UINT WINAPI SetPaletteEntries(_In_ HPALETTE hpal, _In_ UINT iStart, _In_ UINT cEntries, _In_reads_(cEntries) CONST PALETTEENTRY *pPalEntries)
#define RC_PALETTE
Definition: wingdi.h:790