9031556f533dfddeb1f38fd47d13ac9bb819f822
[reactos.git] / modules / rostests / winetests / windowscodecs / palette.c
1 /*
2 * Copyright 2009 Vincent Povirk for CodeWeavers
3 * Copyright 2012 Dmitry Timoshkov
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20 #include "precomp.h"
21
22 static void test_custom_palette(void)
23 {
24 IWICImagingFactory *factory;
25 IWICPalette *palette, *palette2;
26 HRESULT hr;
27 WICBitmapPaletteType type=0xffffffff;
28 UINT count=1;
29 const WICColor initcolors[4]={0xff000000,0xff0000ff,0xffffff00,0xffffffff};
30 WICColor colors[4];
31 BOOL boolresult;
32
33 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
34 &IID_IWICImagingFactory, (void**)&factory);
35 ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
36 if (FAILED(hr)) return;
37
38 hr = IWICImagingFactory_CreatePalette(factory, &palette);
39 ok(SUCCEEDED(hr), "CreatePalette failed, hr=%x\n", hr);
40 if (SUCCEEDED(hr))
41 {
42 hr = IWICPalette_GetType(palette, &type);
43 ok(SUCCEEDED(hr), "GetType failed, hr=%x\n", hr);
44 ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %x\n", type);
45
46 hr = IWICPalette_GetColorCount(palette, &count);
47 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
48 ok(count == 0, "expected 0, got %u\n", count);
49
50 hr = IWICPalette_GetColors(palette, 0, colors, &count);
51 ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
52 ok(count == 0, "expected 0, got %u\n", count);
53
54 hr = IWICPalette_GetColors(palette, 4, colors, &count);
55 ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
56 ok(count == 0, "expected 0, got %u\n", count);
57
58 memcpy(colors, initcolors, sizeof(initcolors));
59 hr = IWICPalette_InitializeCustom(palette, colors, 4);
60 ok(SUCCEEDED(hr), "InitializeCustom failed, hr=%x\n", hr);
61
62 hr = IWICPalette_GetType(palette, &type);
63 ok(SUCCEEDED(hr), "GetType failed, hr=%x\n", hr);
64 ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %x\n", type);
65
66 hr = IWICPalette_GetColorCount(palette, &count);
67 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
68 ok(count == 4, "expected 4, got %u\n", count);
69
70 memset(colors, 0, sizeof(colors));
71 count = 0;
72 hr = IWICPalette_GetColors(palette, 4, colors, &count);
73 ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
74 ok(count == 4, "expected 4, got %u\n", count);
75 ok(!memcmp(colors, initcolors, sizeof(colors)), "got unexpected palette data\n");
76
77 memset(colors, 0, sizeof(colors));
78 count = 0;
79 hr = IWICPalette_GetColors(palette, 2, colors, &count);
80 ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
81 ok(count == 2, "expected 2, got %u\n", count);
82 ok(!memcmp(colors, initcolors, sizeof(WICColor)*2), "got unexpected palette data\n");
83
84 count = 0;
85 hr = IWICPalette_GetColors(palette, 6, colors, &count);
86 ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
87 ok(count == 4, "expected 4, got %u\n", count);
88
89 hr = IWICPalette_HasAlpha(palette, &boolresult);
90 ok(SUCCEEDED(hr), "HasAlpha failed, hr=%x\n", hr);
91 ok(!boolresult, "expected FALSE, got TRUE\n");
92
93 hr = IWICPalette_IsBlackWhite(palette, &boolresult);
94 ok(SUCCEEDED(hr), "IsBlackWhite failed, hr=%x\n", hr);
95 ok(!boolresult, "expected FALSE, got TRUE\n");
96
97 hr = IWICPalette_IsGrayscale(palette, &boolresult);
98 ok(SUCCEEDED(hr), "IsGrayscale failed, hr=%x\n", hr);
99 ok(!boolresult, "expected FALSE, got TRUE\n");
100
101 hr = IWICImagingFactory_CreatePalette(factory, &palette2);
102 ok(SUCCEEDED(hr), "CreatePalette failed, hr=%x\n", hr);
103
104 hr = IWICPalette_InitializeFromPalette(palette2, palette);
105 ok(SUCCEEDED(hr), "InitializeFromPalette failed, hr=%x\n", hr);
106
107 type = 0xdeadbeef;
108 hr = IWICPalette_GetType(palette2, &type);
109 ok(SUCCEEDED(hr), "GetType failed, hr=%x\n", hr);
110 ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %x\n", type);
111
112 count = 0xdeadbeef;
113 hr = IWICPalette_GetColorCount(palette2, &count);
114 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
115 ok(count == 4, "expected 4, got %u\n", count);
116
117 memset(colors, 0, sizeof(colors));
118 count = 0xdeadbeef;
119 hr = IWICPalette_GetColors(palette2, 4, colors, &count);
120 ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
121 ok(count == 4, "expected 4, got %u\n", count);
122 ok(!memcmp(colors, initcolors, sizeof(colors)), "got unexpected palette data\n");
123
124 /* try a palette with some alpha in it */
125 colors[2] = 0x80ffffff;
126 hr = IWICPalette_InitializeCustom(palette, colors, 4);
127 ok(SUCCEEDED(hr), "InitializeCustom failed, hr=%x\n", hr);
128
129 hr = IWICPalette_HasAlpha(palette, &boolresult);
130 ok(SUCCEEDED(hr), "HasAlpha failed, hr=%x\n", hr);
131 ok(boolresult, "expected TRUE, got FALSE\n");
132
133 /* setting to a 0-color palette is acceptable */
134 hr = IWICPalette_InitializeCustom(palette, NULL, 0);
135 ok(SUCCEEDED(hr), "InitializeCustom failed, hr=%x\n", hr);
136
137 type = 0xdeadbeef;
138 hr = IWICPalette_GetType(palette, &type);
139 ok(SUCCEEDED(hr), "GetType failed, hr=%x\n", hr);
140 ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %x\n", type);
141
142 count = 0xdeadbeef;
143 hr = IWICPalette_GetColorCount(palette, &count);
144 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
145 ok(count == 0, "expected 0, got %u\n", count);
146
147 count = 0xdeadbeef;
148 hr = IWICPalette_GetColors(palette, 4, colors, &count);
149 ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
150 ok(count == 0, "expected 0, got %u\n", count);
151
152 hr = IWICPalette_InitializeFromPalette(palette2, palette);
153 ok(SUCCEEDED(hr), "InitializeFromPalette failed, hr=%x\n", hr);
154
155 type = 0xdeadbeef;
156 hr = IWICPalette_GetType(palette2, &type);
157 ok(SUCCEEDED(hr), "GetType failed, hr=%x\n", hr);
158 ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %x\n", type);
159
160 count = 0xdeadbeef;
161 hr = IWICPalette_GetColorCount(palette2, &count);
162 ok(SUCCEEDED(hr), "GetColorCount failed, hr=%x\n", hr);
163 ok(count == 0, "expected 0, got %u\n", count);
164
165 memset(colors, 0, sizeof(colors));
166 count = 0xdeadbeef;
167 hr = IWICPalette_GetColors(palette2, 4, colors, &count);
168 ok(SUCCEEDED(hr), "GetColors failed, hr=%x\n", hr);
169 ok(count == 0, "expected 0, got %u\n", count);
170
171 /* IWICPalette is paranoid about NULL pointers */
172 hr = IWICPalette_GetType(palette, NULL);
173 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
174
175 hr = IWICPalette_GetColorCount(palette, NULL);
176 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
177
178 hr = IWICPalette_InitializeCustom(palette, NULL, 4);
179 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
180
181 hr = IWICPalette_GetColors(palette, 4, NULL, &count);
182 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
183
184 hr = IWICPalette_GetColors(palette, 4, colors, NULL);
185 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
186
187 hr = IWICPalette_HasAlpha(palette, NULL);
188 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
189
190 hr = IWICPalette_IsBlackWhite(palette, NULL);
191 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
192
193 hr = IWICPalette_IsGrayscale(palette, NULL);
194 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
195
196 hr = IWICPalette_InitializeFromPalette(palette, NULL);
197 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %x\n", hr);
198
199 IWICPalette_Release(palette2);
200 IWICPalette_Release(palette);
201 }
202
203 IWICImagingFactory_Release(factory);
204 }
205
206 static void generate_gray16_palette(DWORD *entries, UINT count)
207 {
208 UINT i;
209
210 assert(count == 16);
211
212 for (i = 0; i < 16; i++)
213 {
214 entries[i] = 0xff000000;
215 entries[i] |= (i << 20) | (i << 16) | (i << 12) | (i << 8) | (i << 4) | i;
216 }
217 }
218
219 static void generate_gray256_palette(DWORD *entries, UINT count)
220 {
221 UINT i;
222
223 assert(count == 256);
224
225 for (i = 0; i < 256; i++)
226 {
227 entries[i] = 0xff000000;
228 entries[i] |= (i << 16) | (i << 8) | i;
229 }
230 }
231
232 static void generate_halftone8_palette(DWORD *entries, UINT count, BOOL add_transparent)
233 {
234 UINT i;
235
236 if (add_transparent)
237 ok(count == 17, "expected 17, got %u\n", count);
238 else
239 ok(count == 16, "expected 16, got %u\n", count);
240
241 for (i = 0; i < 8; i++)
242 {
243 entries[i] = 0xff000000;
244 if (i & 1) entries[i] |= 0xff;
245 if (i & 2) entries[i] |= 0xff00;
246 if (i & 4) entries[i] |= 0xff0000;
247 }
248
249 for (i = 8; i < 16; i++)
250 {
251 static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
252 0x000080, 0x808000, 0x800080, 0x008080 };
253 entries[i] = 0xff000000;
254 entries[i] |= halftone[i-8];
255 }
256
257 if (add_transparent)
258 entries[i] = 0;
259 }
260
261 static void generate_halftone27_palette(DWORD *entries, UINT count, BOOL add_transparent)
262 {
263 static const BYTE halftone_values[4] = { 0x00,0x80,0xff };
264 UINT i;
265
266 if (add_transparent)
267 ok(count == 29, "expected 29, got %u\n", count);
268 else
269 ok(count == 28, "expected 28, got %u\n", count);
270
271 for (i = 0; i < 27; i++)
272 {
273 entries[i] = 0xff000000;
274 entries[i] |= halftone_values[i%3];
275 entries[i] |= halftone_values[(i/3)%3] << 8;
276 entries[i] |= halftone_values[(i/9)%3] << 16;
277 }
278
279 entries[i++] = 0xffc0c0c0;
280 if (add_transparent)
281 entries[i] = 0;
282 }
283
284 static void generate_halftone64_palette(DWORD *entries, UINT count, BOOL add_transparent)
285 {
286 static const BYTE halftone_values[4] = { 0x00,0x55,0xaa,0xff };
287 UINT i;
288
289 if (add_transparent)
290 ok(count == 73, "expected 73, got %u\n", count);
291 else
292 ok(count == 72, "expected 72, got %u\n", count);
293
294 for (i = 0; i < 64; i++)
295 {
296 entries[i] = 0xff000000;
297 entries[i] |= halftone_values[i%4];
298 entries[i] |= halftone_values[(i/4)%4] << 8;
299 entries[i] |= halftone_values[(i/16)%4] << 16;
300 }
301
302 for (i = 64; i < 72; i++)
303 {
304 static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
305 0x000080, 0x808000, 0x800080, 0x008080 };
306 entries[i] = 0xff000000;
307 entries[i] |= halftone[i-64];
308 }
309
310 if (add_transparent)
311 entries[i] = 0;
312 }
313
314 static void generate_halftone125_palette(DWORD *entries, UINT count, BOOL add_transparent)
315 {
316 static const BYTE halftone_values[5] = { 0x00, 0x40, 0x80, 0xbf, 0xff };
317 UINT i;
318
319 if (add_transparent)
320 ok(count == 127, "expected 127, got %u\n", count);
321 else
322 ok(count == 126, "expected 126, got %u\n", count);
323
324 for (i = 0; i < 125; i++)
325 {
326 entries[i] = 0xff000000;
327 entries[i] |= halftone_values[i%5];
328 entries[i] |= halftone_values[(i/5)%5] << 8;
329 entries[i] |= halftone_values[(i/25)%5] << 16;
330 }
331
332 entries[i++] = 0xffc0c0c0;
333 if (add_transparent)
334 entries[i] = 0;
335 }
336
337 static void generate_halftone216_palette(DWORD *entries, UINT count, BOOL add_transparent)
338 {
339 static const BYTE halftone_values[6] = { 0x00,0x33,0x66,0x99,0xcc,0xff };
340 UINT i;
341
342 if (add_transparent)
343 ok(count == 225, "expected 225, got %u\n", count);
344 else
345 ok(count == 224, "expected 224, got %u\n", count);
346
347 for (i = 0; i < 216; i++)
348 {
349 entries[i] = 0xff000000;
350 entries[i] |= halftone_values[i%6];
351 entries[i] |= halftone_values[(i/6)%6] << 8;
352 entries[i] |= halftone_values[(i/36)%6] << 16;
353 }
354
355 for (i = 216; i < 224; i++)
356 {
357 static const DWORD halftone[8] = { 0xc0c0c0, 0x808080, 0x800000, 0x008000,
358 0x000080, 0x808000, 0x800080, 0x008080 };
359 entries[i] = 0xff000000;
360 entries[i] |= halftone[i-216];
361 }
362
363 if (add_transparent)
364 entries[i] = 0;
365 }
366
367 static void generate_halftone252_palette(DWORD *entries, UINT count, BOOL add_transparent)
368 {
369 static const BYTE halftone_values_rb[6] = { 0x00,0x33,0x66,0x99,0xcc,0xff };
370 static const BYTE halftone_values_g[7] = { 0x00,0x2b,0x55,0x80,0xaa,0xd5,0xff };
371 UINT i;
372
373 if (add_transparent)
374 ok(count == 253, "expected 253, got %u\n", count);
375 else
376 ok(count == 252, "expected 252, got %u\n", count);
377
378 for (i = 0; i < 252; i++)
379 {
380 entries[i] = 0xff000000;
381 entries[i] |= halftone_values_rb[i%6];
382 entries[i] |= halftone_values_g[(i/6)%7] << 8;
383 entries[i] |= halftone_values_rb[(i/42)%6] << 16;
384 }
385
386 if (add_transparent)
387 entries[i] = 0;
388 }
389
390 static void generate_halftone256_palette(DWORD *entries, UINT count, BOOL add_transparent)
391 {
392 static const BYTE halftone_values_b[4] = { 0x00,0x55,0xaa,0xff };
393 static const BYTE halftone_values_gr[8] = { 0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff };
394 UINT i;
395
396 assert(count == 256);
397
398 for (i = 0; i < 256; i++)
399 {
400 entries[i] = 0xff000000;
401 entries[i] |= halftone_values_b[i%4];
402 entries[i] |= halftone_values_gr[(i/4)%8] << 8;
403 entries[i] |= halftone_values_gr[(i/32)%8] << 16;
404 }
405
406 if (add_transparent)
407 entries[255] = 0;
408 }
409
410 static void test_predefined_palette(void)
411 {
412 static struct test_data
413 {
414 WICBitmapPaletteType type;
415 BOOL is_bw, is_gray;
416 UINT count;
417 WICColor color[256];
418 BOOL add_transparent;
419 } td[] =
420 {
421 { WICBitmapPaletteTypeFixedBW, 1, 1, 2, { 0xff000000, 0xffffffff } },
422 { WICBitmapPaletteTypeFixedBW, 1, 1, 2, { 0xff000000, 0xffffffff }, 1 },
423 { WICBitmapPaletteTypeFixedGray4, 0, 1, 4,
424 { 0xff000000, 0xff555555, 0xffaaaaaa, 0xffffffff } },
425 { WICBitmapPaletteTypeFixedGray4, 0, 1, 4,
426 { 0xff000000, 0xff555555, 0xffaaaaaa, 0xffffffff }, 1 },
427 { WICBitmapPaletteTypeFixedGray16, 0, 1, 16, { 0 } },
428 { WICBitmapPaletteTypeFixedGray16, 0, 1, 16, { 0 }, 1 },
429 { WICBitmapPaletteTypeFixedGray256, 0, 1, 256, { 0 } },
430 { WICBitmapPaletteTypeFixedGray256, 0, 1, 256, { 0 }, 1 },
431 { WICBitmapPaletteTypeFixedHalftone8, 0, 0, 16, { 0 } },
432 { WICBitmapPaletteTypeFixedHalftone8, 0, 0, 17, { 0 }, 1 },
433 { WICBitmapPaletteTypeFixedHalftone27, 0, 0, 28, { 0 } },
434 { WICBitmapPaletteTypeFixedHalftone27, 0, 0, 29, { 0 }, 1 },
435 { WICBitmapPaletteTypeFixedHalftone64, 0, 0, 72, { 0 } },
436 { WICBitmapPaletteTypeFixedHalftone64, 0, 0, 73, { 0 }, 1 },
437 { WICBitmapPaletteTypeFixedHalftone125, 0, 0, 126, { 0 } },
438 { WICBitmapPaletteTypeFixedHalftone125, 0, 0, 127, { 0 }, 1 },
439 { WICBitmapPaletteTypeFixedHalftone216, 0, 0, 224, { 0 } },
440 { WICBitmapPaletteTypeFixedHalftone216, 0, 0, 225, { 0 }, 1 },
441 { WICBitmapPaletteTypeFixedHalftone252, 0, 0, 252, { 0 } },
442 { WICBitmapPaletteTypeFixedHalftone252, 0, 0, 253, { 0 }, 1 },
443 { WICBitmapPaletteTypeFixedHalftone256, 0, 0, 256, { 0 } },
444 { WICBitmapPaletteTypeFixedHalftone256, 0, 0, 256, { 0 }, 1 }
445 };
446 IWICImagingFactory *factory;
447 IWICPalette *palette;
448 HRESULT hr;
449 WICBitmapPaletteType type;
450 UINT count, i, ret;
451 BOOL bret;
452 WICColor color[256];
453
454 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
455 &IID_IWICImagingFactory, (void **)&factory);
456 ok(hr == S_OK, "CoCreateInstance error %#x\n", hr);
457
458 hr = IWICImagingFactory_CreatePalette(factory, &palette);
459 ok(hr == S_OK, "CreatePalette error %#x\n", hr);
460 hr = IWICPalette_InitializePredefined(palette, WICBitmapPaletteTypeCustom, FALSE);
461 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
462 hr = IWICPalette_InitializePredefined(palette, WICBitmapPaletteTypeMedianCut, FALSE);
463 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
464 hr = IWICPalette_InitializePredefined(palette, 0x0f, FALSE);
465 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
466 IWICPalette_Release(palette);
467
468 for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
469 {
470 hr = IWICImagingFactory_CreatePalette(factory, &palette);
471 ok(hr == S_OK, "%u: CreatePalette error %#x\n", i, hr);
472
473 hr = IWICPalette_InitializePredefined(palette, td[i].type, td[i].add_transparent);
474 ok(hr == S_OK, "%u: InitializePredefined error %#x\n", i, hr);
475
476 bret = -1;
477 hr = IWICPalette_IsBlackWhite(palette, &bret);
478 ok(hr == S_OK, "%u: IsBlackWhite error %#x\n", i, hr);
479 ok(bret == td[i].is_bw ||
480 broken(td[i].type == WICBitmapPaletteTypeFixedBW && bret != td[i].is_bw), /* XP */
481 "%u: expected %d, got %d\n",i, td[i].is_bw, bret);
482
483 bret = -1;
484 hr = IWICPalette_IsGrayscale(palette, &bret);
485 ok(hr == S_OK, "%u: IsGrayscale error %#x\n", i, hr);
486 ok(bret == td[i].is_gray, "%u: expected %d, got %d\n", i, td[i].is_gray, bret);
487
488 type = -1;
489 hr = IWICPalette_GetType(palette, &type);
490 ok(hr == S_OK, "%u: GetType error %#x\n", i, hr);
491 ok(type == td[i].type, "%u: expected %#x, got %#x\n", i, td[i].type, type);
492
493 count = 0xdeadbeef;
494 hr = IWICPalette_GetColorCount(palette, &count);
495 ok(hr == S_OK, "%u: GetColorCount error %#x\n", i, hr);
496 ok(count == td[i].count, "%u: expected %u, got %u\n", i, td[i].count, count);
497
498 hr = IWICPalette_GetColors(palette, count, color, &ret);
499 ok(hr == S_OK, "%u: GetColors error %#x\n", i, hr);
500 ok(ret == count, "%u: expected %u, got %u\n", i, count, ret);
501 if (ret == td[i].count)
502 {
503 UINT j;
504
505 if (td[i].type == WICBitmapPaletteTypeFixedGray16)
506 generate_gray16_palette(td[i].color, td[i].count);
507 else if (td[i].type == WICBitmapPaletteTypeFixedGray256)
508 generate_gray256_palette(td[i].color, td[i].count);
509 else if (td[i].type == WICBitmapPaletteTypeFixedHalftone8)
510 generate_halftone8_palette(td[i].color, td[i].count, td[i].add_transparent);
511 else if (td[i].type == WICBitmapPaletteTypeFixedHalftone27)
512 generate_halftone27_palette(td[i].color, td[i].count, td[i].add_transparent);
513 else if (td[i].type == WICBitmapPaletteTypeFixedHalftone64)
514 generate_halftone64_palette(td[i].color, td[i].count, td[i].add_transparent);
515 else if (td[i].type == WICBitmapPaletteTypeFixedHalftone125)
516 generate_halftone125_palette(td[i].color, td[i].count, td[i].add_transparent);
517 else if (td[i].type == WICBitmapPaletteTypeFixedHalftone216)
518 generate_halftone216_palette(td[i].color, td[i].count, td[i].add_transparent);
519 else if (td[i].type == WICBitmapPaletteTypeFixedHalftone252)
520 generate_halftone252_palette(td[i].color, td[i].count, td[i].add_transparent);
521 else if (td[i].type == WICBitmapPaletteTypeFixedHalftone256)
522 generate_halftone256_palette(td[i].color, td[i].count, td[i].add_transparent);
523
524 for (j = 0; j < count; j++)
525 {
526 ok(color[j] == td[i].color[j], "%u:[%u]: expected %#x, got %#x\n",
527 i, j, td[i].color[j], color[j]);
528 }
529 }
530
531 IWICPalette_Release(palette);
532 }
533
534 IWICImagingFactory_Release(factory);
535 }
536
537 START_TEST(palette)
538 {
539 CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
540
541 test_custom_palette();
542 test_predefined_palette();
543
544 CoUninitialize();
545 }