ReactOS 0.4.15-dev-5664-g3bf4ef6
NtGdiDoPalette.c File Reference
#include <win32nt.h>
Include dependency graph for NtGdiDoPalette.c:

Go to the source code of this file.

Functions

HPALETTE CreateTestPalette ()
 
void Test_NtGdiDoPalette_GdiPalAnimate (void)
 
void Test_NtGdiDoPalette_GdiPalSetEntries (void)
 
void Test_NtGdiDoPalette_GdiPalGetEntries (void)
 
void Test_NtGdiDoPalette_GetSystemPalette (void)
 
void Test_NtGdiDoPalette_GetBIBColorTable (void)
 
void Test_NtGdiDoPalette_SetDIBColorTable (void)
 
 START_TEST (NtGdiDoPalette)
 

Function Documentation

◆ CreateTestPalette()

HPALETTE CreateTestPalette ( )

Definition at line 11 of file NtGdiDoPalette.c.

12{
13 struct
14 {
15 LOGPALETTE logpal;
17 } palstruct =
18 { {0x300,5,
19 { {1,2,3,0} }},
20 { {22,33,44,PC_RESERVED},
21 {11,55,77,PC_EXPLICIT},
22 {00,77,66,PC_RESERVED | PC_NOCOLLAPSE},
23 {12,34,56,78}} };
24
25 return CreatePalette((LOGPALETTE*)&palstruct);
26}
uint32_t entry
Definition: isohybrid.c:63
#define PC_RESERVED
Definition: wingdi.h:882
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
#define PC_EXPLICIT
Definition: wingdi.h:880
#define PC_NOCOLLAPSE
Definition: wingdi.h:881

Referenced by Test_NtGdiDoPalette_GdiPalAnimate(), Test_NtGdiDoPalette_GdiPalGetEntries(), and Test_NtGdiDoPalette_GdiPalSetEntries().

◆ START_TEST()

START_TEST ( NtGdiDoPalette  )

Definition at line 277 of file NtGdiDoPalette.c.

278{
285}
void Test_NtGdiDoPalette_GdiPalSetEntries(void)
void Test_NtGdiDoPalette_GetSystemPalette(void)
void Test_NtGdiDoPalette_GdiPalAnimate(void)
void Test_NtGdiDoPalette_SetDIBColorTable(void)
void Test_NtGdiDoPalette_GdiPalGetEntries(void)
void Test_NtGdiDoPalette_GetBIBColorTable(void)

◆ Test_NtGdiDoPalette_GdiPalAnimate()

void Test_NtGdiDoPalette_GdiPalAnimate ( void  )

Definition at line 29 of file NtGdiDoPalette.c.

30{
31 HPALETTE hPal;
32 PALETTEENTRY palEntries[5] = {
33 {0,0,0,0},
34 {0xff,0xff,0xff,0},
35 {0x33,0x66,0x99,0},
36 {0x25,0x84,0x14,0},
37 {0x12,0x34,0x56,0x11}};
38 PALETTEENTRY palEntries2[5];
39
40 /* Test stock palette */
44
45
46 /* Test pEntries = NULL */
47 hPal = CreateTestPalette();
48 ok_long(NtGdiDoPalette(hPal, 0, 1, NULL, GdiPalAnimate, TRUE), 0);
50 DeleteObject(hPal);
51
52 /* Test PC_RESERVED */
53 hPal = CreateTestPalette();
54 ok_long(NtGdiDoPalette(hPal, 0, 5, palEntries, GdiPalAnimate, TRUE), 2);
55 DeleteObject(hPal);
56
57 hPal = CreateTestPalette();
58 ok_long(NtGdiDoPalette(hPal, 1, 5, palEntries, GdiPalAnimate, TRUE), 2);
59 DeleteObject(hPal);
60
61 hPal = CreateTestPalette();
62 ok_long(NtGdiDoPalette(hPal, 2, 5, palEntries, GdiPalAnimate, TRUE), 1);
63 DeleteObject(hPal);
64
65 hPal = CreateTestPalette();
66 ok_long(NtGdiDoPalette(hPal, 3, 5, palEntries, GdiPalAnimate, TRUE), 1);
67 DeleteObject(hPal);
68
69 hPal = CreateTestPalette();
70 ok_long(NtGdiDoPalette(hPal, 4, 5, palEntries, GdiPalAnimate, TRUE), 0);
71 DeleteObject(hPal);
72
73 hPal = CreateTestPalette();
74 ok_long(NtGdiDoPalette(hPal, 5, 5, palEntries, GdiPalAnimate, TRUE), 0);
75 DeleteObject(hPal);
76
77 hPal = CreateTestPalette();
78 ok_long(NtGdiDoPalette(hPal, 0, 5, palEntries, GdiPalAnimate, FALSE), 2);
79 DeleteObject(hPal);
80
81 hPal = CreateTestPalette();
82 ok_long(NtGdiDoPalette(hPal, 3, 5, palEntries, GdiPalAnimate, FALSE), 1);
83 DeleteObject(hPal);
84
85 /* Test if entries are set correctly */
86 hPal = CreateTestPalette();
87 NtGdiDoPalette(hPal, 0, 5, palEntries, GdiPalAnimate, TRUE);
88 NtGdiDoPalette(hPal, 0, 5, palEntries2, GdiPalGetEntries, FALSE);
89 ok_int(palEntries2[0].peRed, 1);
90 ok_int(palEntries2[0].peGreen, 2);
91 ok_int(palEntries2[0].peBlue, 3);
92 ok_int(palEntries2[0].peFlags, 0);
93 ok_int(palEntries2[1].peRed, palEntries[1].peRed);
94 ok_int(palEntries2[1].peGreen, palEntries[1].peGreen);
95 ok_int(palEntries2[1].peBlue, palEntries[1].peBlue);
96 ok_int(palEntries2[1].peFlags, palEntries[1].peFlags);
97 ok_int(palEntries2[2].peRed, 11);
98 ok_int(palEntries2[2].peGreen, 55);
99 ok_int(palEntries2[2].peBlue, 77);
100 ok_int(palEntries2[2].peFlags, PC_EXPLICIT);
101 ok_int(palEntries2[3].peRed, palEntries[3].peRed);
102 ok_int(palEntries2[3].peGreen, palEntries[3].peGreen);
103 ok_int(palEntries2[3].peBlue, palEntries[3].peBlue);
104 ok_int(palEntries2[3].peFlags, palEntries[3].peFlags);
105 DeleteObject(hPal);
106
107}
HPALETTE CreateTestPalette()
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok_int(expression, result)
Definition: atltest.h:134
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define SetLastError(x)
Definition: compat.h:752
pKey DeleteObject()
__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
@ GdiPalAnimate
Definition: ntgdityp.h:28
@ GdiPalGetEntries
Definition: ntgdityp.h:30
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DEFAULT_PALETTE
Definition: wingdi.h:913

Referenced by START_TEST().

◆ Test_NtGdiDoPalette_GdiPalGetEntries()

void Test_NtGdiDoPalette_GdiPalGetEntries ( void  )

Definition at line 180 of file NtGdiDoPalette.c.

181{
182 HPALETTE hPal;
183
184 hPal = CreateTestPalette();
185
186 /* Test pEntries = NULL */
191 ok_long(NtGdiDoPalette(hPal, -20, 1, NULL, GdiPalGetEntries, FALSE), 5);
193
194
195// Test flags 0xf0
196
197}

Referenced by START_TEST().

◆ Test_NtGdiDoPalette_GdiPalSetEntries()

void Test_NtGdiDoPalette_GdiPalSetEntries ( void  )

Definition at line 110 of file NtGdiDoPalette.c.

111{
112 HDC hDC;
113 HPALETTE hPal, hOldPal;
114 PALETTEENTRY palEntries[5] = {
115 {0,0,0,0},
116 {0xff,0xff,0xff,0},
117 {0x33,0x66,0x99,0},
118 {0x25,0x84,0x14,0},
119 {0x12,0x34,0x56,0x11}};
120 PALETTEENTRY palEntries2[5];
121
122 hPal = CreateTestPalette();
123
124 /* Test invalid handle */
126 ok_long(NtGdiDoPalette((HPALETTE)23, 0, 1, palEntries, GdiPalSetEntries, TRUE), 0);
128
129 /* Test system palette */
132
133 ok_long(NtGdiDoPalette(hPal, 0, 1, palEntries, GdiPalSetEntries, TRUE), 1);
134 ok_long(NtGdiDoPalette(hPal, 0, 2, palEntries, GdiPalSetEntries, TRUE), 2);
135 ok_long(NtGdiDoPalette(hPal, 0, 3, palEntries, GdiPalSetEntries, TRUE), 3);
136 ok_long(NtGdiDoPalette(hPal, 0, 5, palEntries, GdiPalSetEntries, TRUE), 5);
137 ok_long(NtGdiDoPalette(hPal, 0, 6, palEntries, GdiPalSetEntries, TRUE), 5);
138 ok_long(NtGdiDoPalette(hPal, 3, 6, palEntries, GdiPalSetEntries, TRUE), 2);
139// TEST(NtGdiDoPalette(hPal, 4, 23247, palEntries, GdiPalSetEntries, TRUE), 0);
140
141 /* Test bInbound, FALSE */
142 NtGdiDoPalette(hPal, 0, 5, palEntries, GdiPalSetEntries, TRUE);
143 ZeroMemory(palEntries2, sizeof(palEntries2));
144 ok_long(NtGdiDoPalette(hPal, 0, 5, palEntries2, GdiPalSetEntries, FALSE), 5);
145 /* we should get the old values returned in our buffer! */
146 ok_int(memcmp(palEntries2, palEntries, sizeof(palEntries)), 0);
147
148 /* check what we have in our palette now */
149 ZeroMemory(palEntries2, sizeof(palEntries2));
150 ok_long(NtGdiDoPalette(hPal, 0, 5, palEntries2, GdiPalGetEntries, FALSE), 5);
151 ok_int(memcmp(palEntries2, palEntries, sizeof(palEntries)), 0);
152
153 ok_long(NtGdiDoPalette(hPal, 0, 4, palEntries2, GdiPalSetEntries, TRUE), 4);
155
156 /* Test if entries are set correctly */
157 hPal = CreateTestPalette();
158 NtGdiDoPalette(hPal, 0, 5, palEntries, GdiPalSetEntries, TRUE);
159 NtGdiDoPalette(hPal, 0, 5, palEntries2, GdiPalGetEntries, FALSE);
160 ok_int(palEntries2[0].peRed, 0);
161 ok_int(palEntries2[0].peGreen, 0);
162 ok_int(palEntries2[0].peBlue, 0);
163 ok_int(palEntries2[0].peFlags, 0);
164
165 /* Test that the buffer was not changed */
166
167
168 /* Test with palette selected into dc */
170 hOldPal = SelectPalette(hDC, hPal, 0);
171 ok_long(NtGdiDoPalette(hPal, 0, 4, palEntries, GdiPalSetEntries, TRUE), 4);
172 SelectPalette(hDC, hOldPal, 0);
173
174 /* Test pEntries = NULL */
176
177}
static HDC hDC
Definition: 3dtext.c:33
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
static HDC
Definition: imagelist.c:92
@ GdiPalSetEntries
Definition: ntgdityp.h:29
#define ZeroMemory
Definition: winbase.h:1670
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)

Referenced by START_TEST().

◆ Test_NtGdiDoPalette_GetBIBColorTable()

void Test_NtGdiDoPalette_GetBIBColorTable ( void  )

Definition at line 206 of file NtGdiDoPalette.c.

207{
208
209}

Referenced by START_TEST().

◆ Test_NtGdiDoPalette_GetSystemPalette()

void Test_NtGdiDoPalette_GetSystemPalette ( void  )

Definition at line 200 of file NtGdiDoPalette.c.

201{
202
203}

Referenced by START_TEST().

◆ Test_NtGdiDoPalette_SetDIBColorTable()

void Test_NtGdiDoPalette_SetDIBColorTable ( void  )

Definition at line 212 of file NtGdiDoPalette.c.

213{
214 HDC hdc;
216 BYTE *pjBits;
217
218 struct
219 {
220 BITMAPINFOHEADER bmiHeader;
221 ULONG bmiColors[10];
222 } bmi;
223
225 ok(hdc != NULL, "hdc was NULL.\n");
226
227 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
228 bmi.bmiHeader.biWidth = 10;
229 bmi.bmiHeader.biHeight = 10;
230 bmi.bmiHeader.biPlanes = 1;
231 bmi.bmiHeader.biBitCount = 8;
232 bmi.bmiHeader.biCompression = BI_RGB;
233 bmi.bmiHeader.biSizeImage = 0;
234 bmi.bmiHeader.biXPelsPerMeter = 1;
235 bmi.bmiHeader.biYPelsPerMeter = 1;
236 bmi.bmiHeader.biClrUsed = 9;
237 bmi.bmiHeader.biClrImportant = 9;
238 bmi.bmiColors[0] = 0x000000;
239 bmi.bmiColors[1] = 0x202020;
240 bmi.bmiColors[2] = 0x404040;
241 bmi.bmiColors[3] = 0x606060;
242 bmi.bmiColors[4] = 0x808080;
243 bmi.bmiColors[5] = 0xA0A0A0;
244 bmi.bmiColors[6] = 0xC0C0C0;
245 bmi.bmiColors[7] = 0xE0E0E0;
246 bmi.bmiColors[8] = 0xffffff;
247 hbmp = CreateDIBSection(hdc, (BITMAPINFO*)&bmi, DIB_PAL_COLORS, (PVOID*)&pjBits, NULL, 0);
248 ok(hbmp != NULL, "hbmp was NULL.\n");
249 ok(pjBits != NULL, "pjBits was NULL.\n");
250
252
253 pjBits[0] = 8;
254 pjBits[1] = 1;
255 pjBits[2] = 2;
256 pjBits[3] = 3;
257
258 bmi.bmiColors[8] = 0x000000;
259 bmi.bmiColors[7] = 0x202020;
260 bmi.bmiColors[6] = 0x404040;
261 bmi.bmiColors[5] = 0x606060;
262 bmi.bmiColors[4] = 0x808080;
263 bmi.bmiColors[3] = 0xA0A0A0;
264 bmi.bmiColors[2] = 0xC0C0C0;
265 bmi.bmiColors[1] = 0xE0E0E0;
266 bmi.bmiColors[0] = 0xffffff;
268
269 SetDCPenColor(hdc, 0xE0E0E0);
270 SetDCBrushColor(hdc, 0x202020);
271 Rectangle(hdc, 0, 0, 10, 10);
272
273 DeleteDC(hdc);
275}
#define ok(value,...)
Definition: atltest.h:57
HBITMAP hbmp
#define BI_RGB
Definition: precomp.h:47
unsigned int ULONG
Definition: retypes.h:1
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
@ GdiPalSetColorTable
Definition: ntgdityp.h:32
RGBQUAD bmiColors[1]
Definition: wingdi.h:1477
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:199
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:941
COLORREF WINAPI SetDCBrushColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:905
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define DIB_PAL_COLORS
Definition: wingdi.h:366
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI DeleteDC(_In_ HDC)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().