ReactOS  0.4.14-dev-593-g1793dcc
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 
42 BOOL
43 WINAPI
44 AnimatePalette(HPALETTE hpal,
45  UINT iStartIndex,
46  UINT cEntries,
47  const PALETTEENTRY *ppe)
48 {
49  return NtGdiDoPalette(hpal, iStartIndex, cEntries, (PALETTEENTRY*)ppe, GdiPalAnimate, TRUE);
50 }
51 
52 HPALETTE
53 WINAPI
55 {
57 }
58 
59 /*
60  * @implemented
61  */
62 UINT
63 WINAPI
64 GetPaletteEntries(HPALETTE hpal,
65  UINT iStartIndex,
66  UINT cEntries,
67  LPPALETTEENTRY ppe)
68 {
69  return NtGdiDoPalette(hpal, iStartIndex, cEntries, ppe, GdiPalGetEntries, FALSE);
70 }
71 
72 UINT
73 WINAPI
74 SetPaletteEntries(HPALETTE hpal,
75  UINT iStartIndex,
76  UINT cEntries,
77  const PALETTEENTRY *ppe)
78 {
79  return NtGdiDoPalette(hpal, iStartIndex, cEntries, (PALETTEENTRY*)ppe, GdiPalSetEntries, TRUE);
80 }
81 
82 UINT
83 WINAPI
85  UINT iStartIndex,
86  UINT cEntries,
87  LPPALETTEENTRY ppe)
88 {
89  PALETTEENTRY ippe[256];
90 
91  if ((INT)cEntries >= 0)
92  {
94  {
95  return NtGdiDoPalette(hDC,
96  iStartIndex,
97  cEntries,
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 
121 UINT
122 WINAPI
124  UINT iStartIndex,
125  UINT cEntries,
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  */
136 UINT
137 WINAPI
139  _In_ HDC hdc) /* [in] Handle of device context */
140 {
142 
144  {
145  return GDI_ERROR;
146  }
147 
148  return UserRealizePalette(hdc);
149 }
150 
151 /*
152  * @implemented
153  */
154 BOOL
155 WINAPI
157  HPALETTE hPalette,
158  UINT nEntries
159 )
160 {
161  return NtGdiResizePalette(hPalette, nEntries);
162 }
163 
164 /*
165  * @implemented
166  */
167 UINT
168 WINAPI
170  UINT iStartIndex,
171  UINT cEntries,
172  const RGBQUAD *pColors)
173 {
174  UINT retValue=0;
175 
176  if (cEntries)
177  {
178  retValue = NtGdiDoPalette(hDC, iStartIndex, cEntries, (RGBQUAD*)pColors, GdiPalSetColorTable, TRUE);
179  }
180 
181  return retValue;
182 }
183 
184 /*
185  * @implemented
186  */
187 BOOL
188 WINAPI
190  HDC hdc
191 )
192 {
193  ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0;
194  return NtGdiUpdateColors(hdc);
195 }
196 
197 /*
198  * @unimplemented
199  */
200 BOOL
201 WINAPI
202 ColorCorrectPalette(HDC hDC,HPALETTE hPalette,DWORD dwFirstEntry,DWORD dwNumOfEntries)
203 {
206  return 0;
207 }
208 
209 /* EOF */
#define HANDLE_METADC0P(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:606
UINT WINAPI GetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:64
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BOOL APIENTRY NtGdiResizePalette(HPALETTE hpal, UINT Entries)
Definition: palette.c:595
UINT WINAPI SetDIBColorTable(HDC hDC, UINT iStartIndex, UINT cEntries, const RGBQUAD *pColors)
Definition: palette.c:169
HPALETTE WINAPI CreatePalette(CONST LOGPALETTE *plpal)
Definition: palette.c:54
HPALETTE APIENTRY NtGdiCreatePaletteInternal(IN LPLOGPALETTE plogpalUser, IN UINT cEntries)
Definition: palette.c:477
UINT WINAPI UserRealizePalette(HDC hDC)
Definition: painting.c:2336
static HDC
Definition: imagelist.c:92
struct _W32CLIENTINFO * PW32CLIENTINFO
UINT WINAPI SetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, const PALETTEENTRY *ppe)
Definition: palette.c:74
BOOL WINAPI AnimatePalette(HPALETTE hpal, UINT iStartIndex, UINT cEntries, const PALETTEENTRY *ppe)
Definition: palette.c:44
#define RASTERCAPS
Definition: wingdi.h:744
int32_t INT
Definition: typedefs.h:56
unsigned int BOOL
Definition: ntddk_ex.h:94
UINT WINAPI GetDIBColorTable(HDC hDC, UINT iStartIndex, UINT cEntries, RGBQUAD *pColors)
Definition: palette.c:123
#define NB_RESERVED_COLORS
Definition: palette.c:7
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
UINT WINAPI RealizePalette(_In_ HDC hdc)
Definition: palette.c:138
BOOL WINAPI UpdateColors(HDC hdc)
Definition: palette.c:189
#define RC_PALETTE
Definition: wingdi.h:789
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:417
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3619
UINT WINAPI GetSystemPaletteEntries(HDC hDC, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:84
__kernel_entry 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 pUnsafeEntries, _In_ DWORD iFunc, _In_ BOOL bInbound)
Definition: palette.c:1077
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
BOOL WINAPI ResizePalette(HPALETTE hPalette, UINT nEntries)
Definition: palette.c:156
#define _In_
Definition: no_sal2.h:204
static HDC hDC
Definition: 3dtext.c:33
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
BOOL WINAPI ColorCorrectPalette(HDC hDC, HPALETTE hPalette, DWORD dwFirstEntry, DWORD dwNumOfEntries)
Definition: palette.c:202
static const PALETTEENTRY sys_pal_template[NB_RESERVED_COLORS]
Definition: palette.c:9
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define UNIMPLEMENTED
Definition: debug.h:114
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
WORD palNumEntries
Definition: wingdi.h:1833
BOOL APIENTRY NtGdiUpdateColors(HDC hDC)
Definition: palette.c:1210
#define GDI_ERROR
Definition: wingdi.h:1308
#define CONST
Definition: pedump.c:81