ReactOS  0.4.15-dev-3316-g067ca88
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  {
143  return METADC_RealizePalette(hdc);
144  }
145 
147  {
148  return GDI_ERROR;
149  }
150 
151  return UserRealizePalette(hdc);
152 }
153 
154 /*
155  * @implemented
156  */
157 BOOL
158 WINAPI
160  HPALETTE hPalette,
161  UINT nEntries
162 )
163 {
164  return NtGdiResizePalette(hPalette, nEntries);
165 }
166 
167 /*
168  * @implemented
169  */
170 UINT
171 WINAPI
173  UINT iStartIndex,
174  UINT cEntries,
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  */
190 BOOL
191 WINAPI
193  HDC hdc
194 )
195 {
196  ((PW32CLIENTINFO)NtCurrentTeb()->Win32ClientInfo)->cSpins = 0;
197  return NtGdiUpdateColors(hdc);
198 }
199 
200 /*
201  * @unimplemented
202  */
203 BOOL
204 WINAPI
205 ColorCorrectPalette(HDC hDC,HPALETTE hPalette,DWORD dwFirstEntry,DWORD dwNumOfEntries)
206 {
209  return 0;
210 }
211 
212 /* EOF */
UINT WINAPI GetPaletteEntries(HPALETTE hpal, UINT iStartIndex, UINT cEntries, LPPALETTEENTRY ppe)
Definition: palette.c:64
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:172
HPALETTE WINAPI CreatePalette(CONST LOGPALETTE *plpal)
Definition: palette.c:54
#define TRUE
Definition: types.h:120
HPALETTE APIENTRY NtGdiCreatePaletteInternal(IN LPLOGPALETTE plogpalUser, IN UINT cEntries)
Definition: palette.c:477
UINT WINAPI UserRealizePalette(HDC hDC)
Definition: painting.c:2348
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:745
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _In_
Definition: ms_sal.h:308
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
ULONG RGBQUAD
Definition: precomp.h:50
BOOL WINAPI UpdateColors(HDC hdc)
Definition: palette.c:192
#define RC_PALETTE
Definition: wingdi.h:790
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
_In_ UINT _In_ UINT cEntries
Definition: wingdi.h:3620
BOOL METADC_RealizePalette(HDC hdc) DECLSPEC_HIDDEN
Definition: metadc.c:1247
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:1072
HDC hdc
Definition: main.c:9
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
BOOL WINAPI ResizePalette(HPALETTE hPalette, UINT nEntries)
Definition: palette.c:159
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:205
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:102
#define UNIMPLEMENTED
Definition: debug.h:115
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
WORD palNumEntries
Definition: wingdi.h:1834
BOOL APIENTRY NtGdiUpdateColors(HDC hDC)
Definition: palette.c:1205
#define GDI_ERROR
Definition: wingdi.h:1309
#define CONST
Definition: pedump.c:81