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