2 * Copyright 2009 Vincent Povirk
3 * Copyright 2016 Dmitry Timoshkov
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.
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.
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
30 #include "wincodecsdk.h"
31 #include "wine/test.h"
33 static IWICImagingFactory
*factory
;
35 typedef struct bitmap_data
{
36 const WICPixelFormatGUID
*format
;
43 const struct bitmap_data
*alt_data
;
46 typedef struct BitmapTestSrc
{
47 IWICBitmapSource IWICBitmapSource_iface
;
49 const bitmap_data
*data
;
52 extern HRESULT STDMETHODCALLTYPE
IWICBitmapFrameEncode_WriteSource_Proxy(IWICBitmapFrameEncode
* This
,
53 IWICBitmapSource
*pIBitmapSource
, WICRect
*prc
);
55 static BOOL
near_equal(float a
, float b
)
57 return fabsf(a
- b
) < 0.001;
60 static inline BitmapTestSrc
*impl_from_IWICBitmapSource(IWICBitmapSource
*iface
)
62 return CONTAINING_RECORD(iface
, BitmapTestSrc
, IWICBitmapSource_iface
);
65 static HRESULT WINAPI
BitmapTestSrc_QueryInterface(IWICBitmapSource
*iface
, REFIID iid
,
68 if (!ppv
) return E_INVALIDARG
;
70 if (IsEqualIID(&IID_IUnknown
, iid
) ||
71 IsEqualIID(&IID_IWICBitmapSource
, iid
))
76 IUnknown_AddRef((IUnknown
*)*ppv
);
80 static ULONG WINAPI
BitmapTestSrc_AddRef(IWICBitmapSource
*iface
)
82 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
83 ULONG ref
= InterlockedIncrement(&This
->ref
);
87 static ULONG WINAPI
BitmapTestSrc_Release(IWICBitmapSource
*iface
)
89 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
90 ULONG ref
= InterlockedDecrement(&This
->ref
);
94 static HRESULT WINAPI
BitmapTestSrc_GetSize(IWICBitmapSource
*iface
,
95 UINT
*puiWidth
, UINT
*puiHeight
)
97 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
98 *puiWidth
= This
->data
->width
;
99 *puiHeight
= This
->data
->height
;
103 static HRESULT WINAPI
BitmapTestSrc_GetPixelFormat(IWICBitmapSource
*iface
,
104 WICPixelFormatGUID
*pPixelFormat
)
106 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
107 memcpy(pPixelFormat
, This
->data
->format
, sizeof(GUID
));
111 static HRESULT WINAPI
BitmapTestSrc_GetResolution(IWICBitmapSource
*iface
,
112 double *pDpiX
, double *pDpiY
)
114 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
115 *pDpiX
= This
->data
->xres
;
116 *pDpiY
= This
->data
->yres
;
120 static HRESULT WINAPI
BitmapTestSrc_CopyPalette(IWICBitmapSource
*iface
,
121 IWICPalette
*palette
)
123 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
125 if (IsEqualGUID(This
->data
->format
, &GUID_WICPixelFormat1bppIndexed
) ||
126 IsEqualGUID(This
->data
->format
, &GUID_WICPixelFormat2bppIndexed
) ||
127 IsEqualGUID(This
->data
->format
, &GUID_WICPixelFormat4bppIndexed
) ||
128 IsEqualGUID(This
->data
->format
, &GUID_WICPixelFormat8bppIndexed
))
132 colors
[0] = 0xff0000ff;
133 colors
[1] = 0xff00ff00;
134 colors
[2] = 0xffff0000;
135 colors
[3] = 0xff000000;
136 colors
[4] = 0xffffff00;
137 colors
[5] = 0xffff00ff;
138 colors
[6] = 0xff00ffff;
139 colors
[7] = 0xffffffff;
140 return IWICPalette_InitializeCustom(palette
, colors
, 8);
143 /* unique error marker */
147 static HRESULT WINAPI
BitmapTestSrc_CopyPixels(IWICBitmapSource
*iface
,
148 const WICRect
*prc
, UINT cbStride
, UINT cbBufferSize
, BYTE
*pbBuffer
)
150 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
160 rc
.Width
= This
->data
->width
;
161 rc
.Height
= This
->data
->height
;
166 if (prc
->X
< 0 || prc
->Y
< 0 || prc
->X
+prc
->Width
> This
->data
->width
|| prc
->Y
+prc
->Height
> This
->data
->height
)
170 bytesperrow
= ((This
->data
->bpp
* prc
->Width
)+7)/8;
171 srcstride
= ((This
->data
->bpp
* This
->data
->width
)+7)/8;
173 if (cbStride
< bytesperrow
)
176 if ((cbStride
* prc
->Height
) > cbBufferSize
)
179 row_offset
= prc
->X
* This
->data
->bpp
;
181 if (row_offset
% 8 == 0)
187 src
= This
->data
->bits
+ (row_offset
/ 8) + prc
->Y
* srcstride
;
189 for (row
=0; row
< prc
->Height
; row
++)
191 memcpy(dst
, src
, bytesperrow
);
199 ok(0, "bitmap %p was asked to copy pixels not aligned on a byte boundary\n", iface
);
204 static const IWICBitmapSourceVtbl BitmapTestSrc_Vtbl
= {
205 BitmapTestSrc_QueryInterface
,
206 BitmapTestSrc_AddRef
,
207 BitmapTestSrc_Release
,
208 BitmapTestSrc_GetSize
,
209 BitmapTestSrc_GetPixelFormat
,
210 BitmapTestSrc_GetResolution
,
211 BitmapTestSrc_CopyPalette
,
212 BitmapTestSrc_CopyPixels
215 static void CreateTestBitmap(const bitmap_data
*data
, BitmapTestSrc
**This
)
217 *This
= HeapAlloc(GetProcessHeap(), 0, sizeof(**This
));
221 (*This
)->IWICBitmapSource_iface
.lpVtbl
= &BitmapTestSrc_Vtbl
;
223 (*This
)->data
= data
;
227 static void DeleteTestBitmap(BitmapTestSrc
*This
)
229 ok(This
->IWICBitmapSource_iface
.lpVtbl
== &BitmapTestSrc_Vtbl
, "test bitmap %p deleted with incorrect vtable\n", This
);
230 ok(This
->ref
== 1, "test bitmap %p deleted with %li references instead of 1\n", This
, This
->ref
);
231 HeapFree(GetProcessHeap(), 0, This
);
234 static BOOL
compare_bits(const struct bitmap_data
*expect
, UINT buffersize
, const BYTE
*converted_bits
)
238 if (IsEqualGUID(expect
->format
, &GUID_WICPixelFormat32bppBGR
))
240 /* ignore the padding byte when comparing data */
242 const DWORD
*a
=(const DWORD
*)expect
->bits
, *b
=(const DWORD
*)converted_bits
;
244 for (i
=0; i
<(buffersize
/4); i
++)
245 if ((a
[i
]&0xffffff) != (b
[i
]&0xffffff))
251 else if (IsEqualGUID(expect
->format
, &GUID_WICPixelFormat32bppGrayFloat
))
254 const float *a
=(const float*)expect
->bits
, *b
=(const float*)converted_bits
;
256 for (i
=0; i
<(buffersize
/4); i
++)
257 if (!near_equal(a
[i
], b
[i
]))
263 else if (IsEqualGUID(expect
->format
, &GUID_WICPixelFormatBlackWhite
) ||
264 IsEqualGUID(expect
->format
, &GUID_WICPixelFormat1bppIndexed
))
267 const BYTE
*a
=(const BYTE
*)expect
->bits
, *b
=(const BYTE
*)converted_bits
;
269 for (i
=0; i
<buffersize
; i
++)
270 if (a
[i
] != b
[i
] && b
[i
] != 0xff /* BMP encoder B&W */)
276 else if (IsEqualGUID(expect
->format
, &GUID_WICPixelFormat2bppIndexed
) ||
277 IsEqualGUID(expect
->format
, &GUID_WICPixelFormat4bppIndexed
) ||
278 IsEqualGUID(expect
->format
, &GUID_WICPixelFormat8bppIndexed
))
281 const BYTE
*a
=(const BYTE
*)expect
->bits
, *b
=(const BYTE
*)converted_bits
;
284 for (i
=0; i
<buffersize
; i
++)
292 equal
= (memcmp(expect
->bits
, converted_bits
, buffersize
) == 0);
294 if (!equal
&& expect
->alt_data
)
295 equal
= compare_bits(expect
->alt_data
, buffersize
, converted_bits
);
297 if (!equal
&& winetest_debug
> 1)
300 bps
= expect
->bpp
/ 8;
301 if (!bps
) bps
= buffersize
;
302 printf("converted_bits (%u bytes):\n ", buffersize
);
303 for (i
= 0; i
< buffersize
; i
++)
305 printf("%u,", converted_bits
[i
]);
306 if (!((i
+ 1) % 32)) printf("\n ");
307 else if (!((i
+1) % bps
)) printf(" ");
315 static BOOL
is_indexed_format(const GUID
*format
)
317 if (IsEqualGUID(format
, &GUID_WICPixelFormat1bppIndexed
) ||
318 IsEqualGUID(format
, &GUID_WICPixelFormat2bppIndexed
) ||
319 IsEqualGUID(format
, &GUID_WICPixelFormat4bppIndexed
) ||
320 IsEqualGUID(format
, &GUID_WICPixelFormat8bppIndexed
))
326 static void compare_bitmap_data(const struct bitmap_data
*src
, const struct bitmap_data
*expect
,
327 IWICBitmapSource
*source
, const char *name
)
329 BYTE
*converted_bits
;
333 UINT stride
, buffersize
;
334 GUID dst_pixelformat
;
337 hr
= IWICBitmapSource_GetSize(source
, &width
, &height
);
338 ok(SUCCEEDED(hr
), "GetSize(%s) failed, hr=%lx\n", name
, hr
);
339 ok(width
== expect
->width
, "expecting %u, got %u (%s)\n", expect
->width
, width
, name
);
340 ok(height
== expect
->height
, "expecting %u, got %u (%s)\n", expect
->height
, height
, name
);
342 hr
= IWICBitmapSource_GetResolution(source
, &xres
, &yres
);
343 ok(SUCCEEDED(hr
), "GetResolution(%s) failed, hr=%lx\n", name
, hr
);
344 ok(fabs(xres
- expect
->xres
) < 0.02, "expecting %0.2f, got %0.2f (%s)\n", expect
->xres
, xres
, name
);
345 ok(fabs(yres
- expect
->yres
) < 0.02, "expecting %0.2f, got %0.2f (%s)\n", expect
->yres
, yres
, name
);
347 hr
= IWICBitmapSource_GetPixelFormat(source
, &dst_pixelformat
);
348 ok(SUCCEEDED(hr
), "GetPixelFormat(%s) failed, hr=%lx\n", name
, hr
);
349 ok(IsEqualGUID(&dst_pixelformat
, expect
->format
), "got unexpected pixel format %s (%s)\n", wine_dbgstr_guid(&dst_pixelformat
), name
);
353 prc
.Width
= expect
->width
;
354 prc
.Height
= expect
->height
;
356 stride
= (expect
->bpp
* expect
->width
+ 7) / 8;
357 buffersize
= stride
* expect
->height
;
359 converted_bits
= HeapAlloc(GetProcessHeap(), 0, buffersize
);
360 memset(converted_bits
, 0xaa, buffersize
);
361 hr
= IWICBitmapSource_CopyPixels(source
, &prc
, stride
, buffersize
, converted_bits
);
362 ok(SUCCEEDED(hr
), "CopyPixels(%s) failed, hr=%lx\n", name
, hr
);
364 /* The result of conversion of color to indexed formats depends on
365 * optimized palette generation implementation. We either need to
366 * assign our own palette, or just skip the comparison.
368 if (!(!is_indexed_format(src
->format
) && is_indexed_format(expect
->format
)))
369 ok(compare_bits(expect
, buffersize
, converted_bits
), "unexpected pixel data (%s)\n", name
);
371 /* Test with NULL rectangle - should copy the whole bitmap */
372 memset(converted_bits
, 0xaa, buffersize
);
373 hr
= IWICBitmapSource_CopyPixels(source
, NULL
, stride
, buffersize
, converted_bits
);
374 ok(SUCCEEDED(hr
), "CopyPixels(%s,rc=NULL) failed, hr=%lx\n", name
, hr
);
375 /* see comment above */
376 if (!(!is_indexed_format(src
->format
) && is_indexed_format(expect
->format
)))
377 ok(compare_bits(expect
, buffersize
, converted_bits
), "unexpected pixel data (%s)\n", name
);
379 HeapFree(GetProcessHeap(), 0, converted_bits
);
382 /* some encoders (like BMP) require data to be 4-bytes aligned */
383 static const BYTE bits_1bpp
[] = {
384 0x55,0x55,0x55,0x55, /*01010101*/
385 0xaa,0xaa,0xaa,0xaa}; /*10101010*/
386 static const struct bitmap_data testdata_BlackWhite
= {
387 &GUID_WICPixelFormatBlackWhite
, 1, bits_1bpp
, 32, 2, 96.0, 96.0};
388 static const struct bitmap_data testdata_1bppIndexed
= {
389 &GUID_WICPixelFormat1bppIndexed
, 1, bits_1bpp
, 32, 2, 96.0, 96.0};
391 /* some encoders (like BMP) require data to be 4-bytes aligned */
392 static const BYTE bits_2bpp
[] = {
393 0xdb,0xdb,0xdb,0xdb,0xdb,0xdb,0xdb,0xdb,
394 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24};
395 static const struct bitmap_data testdata_2bppIndexed
= {
396 &GUID_WICPixelFormat2bppIndexed
, 2, bits_2bpp
, 32, 2, 96.0, 96.0};
398 /* some encoders (like BMP) require data to be 4-bytes aligned */
399 static const BYTE bits_4bpp
[] = {
400 0x34,0x43,0x34,0x43,0x34,0x43,0x34,0x43,0x34,0x43,0x34,0x43,0x34,0x43,0x34,0x43,
401 0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44};
403 static const struct bitmap_data testdata_4bppIndexed
= {
404 &GUID_WICPixelFormat4bppIndexed
, 4, bits_4bpp
, 32, 2, 96.0, 96.0};
406 static const BYTE bits_8bpp_BW
[] = {
407 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
408 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0};
409 static const struct bitmap_data testdata_8bppIndexed_BW
= {
410 &GUID_WICPixelFormat8bppIndexed
, 8, bits_8bpp_BW
, 32, 2, 96.0, 96.0};
412 static const BYTE bits_8bpp_4colors
[] = {
413 0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,
414 3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3};
415 static const struct bitmap_data testdata_8bppIndexed_4colors
= {
416 &GUID_WICPixelFormat8bppIndexed
, 8, bits_8bpp_4colors
, 32, 2, 96.0, 96.0};
418 static const BYTE bits_8bpp
[] = {
419 0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,
420 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
421 static const struct bitmap_data testdata_8bppIndexed
= {
422 &GUID_WICPixelFormat8bppIndexed
, 8, bits_8bpp
, 32, 2, 96.0, 96.0};
424 static const BYTE bits_24bppBGR
[] = {
425 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
426 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
427 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
428 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
429 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255,
430 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255,
431 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255,
432 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255};
433 static const struct bitmap_data testdata_24bppBGR
= {
434 &GUID_WICPixelFormat24bppBGR
, 24, bits_24bppBGR
, 32, 2, 96.0, 96.0};
436 static const BYTE bits_24bppRGB
[] = {
437 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
438 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
439 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
440 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
441 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255,
442 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255,
443 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255,
444 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255 };
445 static const struct bitmap_data testdata_24bppRGB
= {
446 &GUID_WICPixelFormat24bppRGB
, 24, bits_24bppRGB
, 32, 2, 96.0, 96.0};
448 static const BYTE bits_32bppBGR
[] = {
449 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
450 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
451 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
452 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
453 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80,
454 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80,
455 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80,
456 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80,
457 3,3,3,80, 6,6,6,80, 12,12,12,80, 15,15,15,80, 19,19,19,80, 22,22,22,80, 28,28,28,80, 31,31,31,80,
458 35,35,35,80, 38,38,38,80, 41,41,41,80, 47,47,47,80, 47,47,47,80, 54,54,54,80, 57,57,57,80, 63,63,63,80,
459 66,66,66,80, 70,70,70,80, 73,73,73,80, 79,79,79,80, 82,82,82,80, 86,86,86,80, 89,89,89,80, 95,95,95,80,
460 98,98,98,80, 98,98,98,80, 105,105,105,80, 108,108,108,80, 114,114,114,80, 117,117,117,80, 121,121,121,80, 124,124,124,80,
461 130,130,130,80, 133,133,133,80, 137,137,137,80, 140,140,140,80, 146,146,146,80, 149,149,149,80, 156,156,156,80, 156,156,156,80,
462 159,159,159,80, 165,165,165,80, 168,168,168,80, 172,172,172,80, 175,175,175,80, 181,181,181,80, 184,184,184,80, 188,188,188,80,
463 191,191,191,80, 197,197,197,80, 200,200,200,80, 207,207,207,80, 207,207,207,80, 213,213,213,80, 216,216,216,80, 219,219,219,80,
464 223,223,223,80, 226,226,226,80, 232,232,232,80, 235,235,235,80, 239,239,239,80, 242,242,242,80, 248,248,248,80, 251,251,251,80};
465 static const struct bitmap_data testdata_32bppBGR
= {
466 &GUID_WICPixelFormat32bppBGR
, 32, bits_32bppBGR
, 32, 2, 96.0, 96.0};
467 static const struct bitmap_data testdata_32bppBGRA80
= {
468 &GUID_WICPixelFormat32bppBGRA
, 32, bits_32bppBGR
, 32, 4, 96.0, 96.0};
469 static const struct bitmap_data testdata_32bppRGBA80
= {
470 &GUID_WICPixelFormat32bppRGBA
, 32, bits_32bppBGR
, 32, 4, 96.0, 96.0};
472 static const BYTE bits_32bppBGRA
[] = {
473 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
474 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
475 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
476 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
477 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255,
478 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255,
479 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255,
480 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255,
481 3,3,3,255, 6,6,6,255, 12,12,12,255, 15,15,15,255, 19,19,19,255, 22,22,22,255, 28,28,28,255, 31,31,31,80,
482 35,35,35,255, 38,38,38,255, 41,41,41,255, 47,47,47,255, 47,47,47,255, 54,54,54,255, 57,57,57,255, 63,63,63,80,
483 66,66,66,255, 70,70,70,255, 73,73,73,255, 79,79,79,255, 82,82,82,255, 86,86,86,255, 89,89,89,255, 95,95,95,80,
484 98,98,98,255, 98,98,98,255, 105,105,105,255, 108,108,108,255, 114,114,114,255, 117,117,117,255, 121,121,121,255, 124,124,124,80,
485 130,130,130,255, 133,133,133,255, 137,137,137,255, 140,140,140,255, 146,146,146,255, 149,149,149,255, 156,156,156,255, 156,156,156,80,
486 159,159,159,255, 165,165,165,255, 168,168,168,255, 172,172,172,255, 175,175,175,255, 181,181,181,255, 184,184,184,255, 188,188,188,80,
487 191,191,191,255, 197,197,197,255, 200,200,200,255, 207,207,207,255, 207,207,207,255, 213,213,213,255, 216,216,216,255, 219,219,219,80,
488 223,223,223,255, 226,226,226,255, 232,232,232,255, 235,235,235,255, 239,239,239,255, 242,242,242,255, 248,248,248,255, 251,251,251,80};
489 static const BYTE bits_32bppRGBA
[] = {
490 0,0,255,255, 0,255,0,255, 255,0,0,255, 0,0,0,255, 0,0,255,255, 0,255,0,255, 255,0,0,255, 0,0,0,255,
491 0,0,255,255, 0,255,0,255, 255,0,0,255, 0,0,0,255, 0,0,255,255, 0,255,0,255, 255,0,0,255, 0,0,0,255,
492 0,0,255,255, 0,255,0,255, 255,0,0,255, 0,0,0,255, 0,0,255,255, 0,255,0,255, 255,0,0,255, 0,0,0,255,
493 0,0,255,255, 0,255,0,255, 255,0,0,255, 0,0,0,255, 0,0,255,255, 0,255,0,255, 255,0,0,255, 0,0,0,255,
494 255,255,0,255, 255,0,255,255, 0,255,255,255, 255,255,255,255, 255,255,0,255, 255,0,255,255, 0,255,255,255, 255,255,255,255,
495 255,255,0,255, 255,0,255,255, 0,255,255,255, 255,255,255,255, 255,255,0,255, 255,0,255,255, 0,255,255,255, 255,255,255,255,
496 255,255,0,255, 255,0,255,255, 0,255,255,255, 255,255,255,255, 255,255,0,255, 255,0,255,255, 0,255,255,255, 255,255,255,255,
497 255,255,0,255, 255,0,255,255, 0,255,255,255, 255,255,255,255, 255,255,0,255, 255,0,255,255, 0,255,255,255, 255,255,255,255};
499 static const struct bitmap_data testdata_32bppBGRA
= {
500 &GUID_WICPixelFormat32bppBGRA
, 32, bits_32bppBGRA
, 32, 2, 96.0, 96.0};
501 static const struct bitmap_data testdata_32bppRGBA
= {
502 &GUID_WICPixelFormat32bppRGBA
, 32, bits_32bppRGBA
, 32, 2, 96.0, 96.0};
503 static const struct bitmap_data testdata_32bppRGB
= {
504 &GUID_WICPixelFormat32bppRGB
, 32, bits_32bppRGBA
, 32, 2, 96.0, 96.0};
506 static const BYTE bits_32bppPBGRA
[] = {
507 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80,
508 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80,
509 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80,
510 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80, 80,0,0,80, 0,80,0,80, 0,0,80,80, 0,0,0,80,
511 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80,
512 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80,
513 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80,
514 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80, 0,80,80,80, 80,0,80,80, 80,80,0,80, 80,80,80,80,
515 1,1,1,80, 2,2,2,80, 4,4,4,80, 5,5,5,80, 6,6,6,80, 7,7,7,80, 9,9,9,80, 10,10,10,80,
516 11,11,11,80, 12,12,12,80, 13,13,13,80, 15,15,15,80, 15,15,15,80, 17,17,17,80, 18,18,18,80, 20,20,20,80,
517 21,21,21,80, 22,22,22,80, 23,23,23,80, 25,25,25,80, 26,26,26,80, 27,27,27,80, 28,28,28,80, 30,30,30,80,
518 31,31,31,80, 31,31,31,80, 33,33,33,80, 34,34,34,80, 36,36,36,80, 37,37,37,80, 38,38,38,80, 39,39,39,80,
519 41,41,41,80, 42,42,42,80, 43,43,43,80, 44,44,44,80, 46,46,46,80, 47,47,47,80, 49,49,49,80, 49,49,49,80,
520 50,50,50,80, 52,52,52,80, 53,53,53,80, 54,54,54,80, 55,55,55,80, 57,57,57,80, 58,58,58,80, 59,59,59,80,
521 60,60,60,80, 62,62,62,80, 63,63,63,80, 65,65,65,80, 65,65,65,80, 67,67,67,80, 68,68,68,80, 69,69,69,80,
522 70,70,70,80, 71,71,71,80, 73,73,73,80, 74,74,74,80, 75,75,75,80, 76,76,76,80, 78,78,78,80, 79,79,79,80};
523 static const struct bitmap_data testdata_32bppPBGRA
= {
524 &GUID_WICPixelFormat32bppPBGRA
, 32, bits_32bppPBGRA
, 32, 4, 96.0, 96.0};
525 static const struct bitmap_data testdata_32bppPRGBA
= {
526 &GUID_WICPixelFormat32bppPRGBA
, 32, bits_32bppPBGRA
, 32, 4, 96.0, 96.0};
528 static const BYTE bits_64bppRGBA
[] = {
529 128,0,128,0,128,255,128,255, 128,0,128,255,128,0,128,255, 128,255,128,0,128,0,128,255, 128,0,128,0,128,0,128,255, 128,0,128,0,128,255,128,255, 128,0,128,255,128,0,128,255, 128,255,128,0,128,0,128,255, 128,0,128,0,128,0,128,255,
530 128,0,128,0,128,255,128,255, 128,0,128,255,128,0,128,255, 128,255,128,0,128,0,128,255, 128,0,128,0,128,0,128,255, 128,0,128,0,128,255,128,255, 128,0,128,255,128,0,128,255, 128,255,128,0,128,0,128,255, 128,0,128,0,128,0,128,255,
531 128,0,128,0,128,255,128,255, 128,0,128,255,128,0,128,255, 128,255,128,0,128,0,128,255, 128,0,128,0,128,0,128,255, 128,0,128,0,128,255,128,255, 128,0,128,255,128,0,128,255, 128,255,128,0,128,0,128,255, 128,0,128,0,128,0,128,255,
532 128,0,128,0,128,255,128,255, 128,0,128,255,128,0,128,255, 128,255,128,0,128,0,128,255, 128,0,128,0,128,0,128,255, 128,0,128,0,128,255,128,255, 128,0,128,255,128,0,128,255, 128,255,128,0,128,0,128,255, 128,0,128,0,128,0,128,255,
533 128,255,128,255,128,0,128,255, 128,255,128,0,128,255,128,255, 128,0,128,255,128,255,128,255, 128,255,128,255,128,255,128,255, 128,255,128,255,128,0,128,255, 128,255,128,0,128,255,128,255, 128,0,128,255,128,255,128,255, 128,255,128,255,128,255,128,255,
534 128,255,128,255,128,0,128,255, 128,255,128,0,128,255,128,255, 128,0,128,255,128,255,128,255, 128,255,128,255,128,255,128,255, 128,255,128,255,128,0,128,255, 128,255,128,0,128,255,128,255, 128,0,128,255,128,255,128,255, 128,255,128,255,128,255,128,255,
535 128,255,128,255,128,0,128,255, 128,255,128,0,128,255,128,255, 128,0,128,255,128,255,128,255, 128,255,128,255,128,255,128,255, 128,255,128,255,128,0,128,255, 128,255,128,0,128,255,128,255, 128,0,128,255,128,255,128,255, 128,255,128,255,128,255,128,255,
536 128,255,128,255,128,0,128,255, 128,255,128,0,128,255,128,255, 128,0,128,255,128,255,128,255, 128,255,128,255,128,255,128,255, 128,255,128,255,128,0,128,255, 128,255,128,0,128,255,128,255, 128,0,128,255,128,255,128,255, 128,255,128,255,128,255,128,255};
537 static const struct bitmap_data testdata_64bppRGBA
= {
538 &GUID_WICPixelFormat64bppRGBA
, 64, bits_64bppRGBA
, 32, 2, 96.0, 96.0};
540 /* XP and 2003 use linear color conversion, later versions use sRGB gamma */
541 static const float bits_32bppGrayFloat_xp
[] = {
542 0.114000f
,0.587000f
,0.299000f
,0.000000f
,0.114000f
,0.587000f
,0.299000f
,0.000000f
,
543 0.114000f
,0.587000f
,0.299000f
,0.000000f
,0.114000f
,0.587000f
,0.299000f
,0.000000f
,
544 0.114000f
,0.587000f
,0.299000f
,0.000000f
,0.114000f
,0.587000f
,0.299000f
,0.000000f
,
545 0.114000f
,0.587000f
,0.299000f
,0.000000f
,0.114000f
,0.587000f
,0.299000f
,0.000000f
,
546 0.886000f
,0.413000f
,0.701000f
,1.000000f
,0.886000f
,0.413000f
,0.701000f
,1.000000f
,
547 0.886000f
,0.413000f
,0.701000f
,1.000000f
,0.886000f
,0.413000f
,0.701000f
,1.000000f
,
548 0.886000f
,0.413000f
,0.701000f
,1.000000f
,0.886000f
,0.413000f
,0.701000f
,1.000000f
,
549 0.886000f
,0.413000f
,0.701000f
,1.000000f
,0.886000f
,0.413000f
,0.701000f
,1.000000f
};
550 static const struct bitmap_data testdata_32bppGrayFloat_xp
= {
551 &GUID_WICPixelFormat32bppGrayFloat
, 32, (const BYTE
*)bits_32bppGrayFloat_xp
, 32, 2, 96.0, 96.0};
553 static const float bits_32bppGrayFloat
[] = {
554 0.072200f
,0.715200f
,0.212600f
,0.000000f
,0.072200f
,0.715200f
,0.212600f
,0.000000f
,
555 0.072200f
,0.715200f
,0.212600f
,0.000000f
,0.072200f
,0.715200f
,0.212600f
,0.000000f
,
556 0.072200f
,0.715200f
,0.212600f
,0.000000f
,0.072200f
,0.715200f
,0.212600f
,0.000000f
,
557 0.072200f
,0.715200f
,0.212600f
,0.000000f
,0.072200f
,0.715200f
,0.212600f
,0.000000f
,
558 0.927800f
,0.284800f
,0.787400f
,1.000000f
,0.927800f
,0.284800f
,0.787400f
,1.000000f
,
559 0.927800f
,0.284800f
,0.787400f
,1.000000f
,0.927800f
,0.284800f
,0.787400f
,1.000000f
,
560 0.927800f
,0.284800f
,0.787400f
,1.000000f
,0.927800f
,0.284800f
,0.787400f
,1.000000f
,
561 0.927800f
,0.284800f
,0.787400f
,1.000000f
,0.927800f
,0.284800f
,0.787400f
,1.000000f
};
562 static const struct bitmap_data testdata_32bppGrayFloat
= {
563 &GUID_WICPixelFormat32bppGrayFloat
, 32, (const BYTE
*)bits_32bppGrayFloat
, 32, 2, 96.0, 96.0, &testdata_32bppGrayFloat_xp
};
565 static const BYTE bits_4bppGray_xp
[] = {
566 77,112,77,112,77,112,77,112,77,112,77,112,77,112,77,112,249,
567 239,249,239,249,239,249,239,249,239,249,239,249,239,249,239};
568 static const struct bitmap_data testdata_4bppGray_xp
= {
569 &GUID_WICPixelFormat4bppGray
, 4, bits_4bppGray_xp
, 32, 2, 96.0, 96.0};
571 static const BYTE bits_4bppGray
[] = {
572 77,112,77,112,77,112,77,112,77,112,77,112,77,112,77,112,249,
573 239,249,239,249,239,249,239,249,239,249,239,249,239,249,239};
574 static const struct bitmap_data testdata_4bppGray
= {
575 &GUID_WICPixelFormat4bppGray
, 4, bits_4bppGray
, 32, 2, 96.0, 96.0, &testdata_4bppGray_xp
};
577 static const BYTE bits_8bppGray_xp
[] = {
578 29,150,76,0,29,150,76,0,29,150,76,0,29,150,76,0,
579 29,150,76,0,29,150,76,0,29,150,76,0,29,150,76,0,
580 226,105,179,255,226,105,179,255,226,105,179,255,226,105,179,255,
581 226,105,179,255,226,105,179,255,226,105,179,255,226,105,179,255};
582 static const struct bitmap_data testdata_8bppGray_xp
= {
583 &GUID_WICPixelFormat8bppGray
, 8, bits_8bppGray_xp
, 32, 2, 96.0, 96.0};
585 static const BYTE bits_8bppGray
[] = {
586 76,220,127,0,76,220,127,0,76,220,127,0,76,220,127,0,
587 76,220,127,0,76,220,127,0,76,220,127,0,76,220,127,0,
588 247,145,230,255,247,145,230,255,247,145,230,255,247,145,230,255,
589 247,145,230,255,247,145,230,255,247,145,230,255,247,145,230,255};
590 static const struct bitmap_data testdata_8bppGray
= {
591 &GUID_WICPixelFormat8bppGray
, 8, bits_8bppGray
, 32, 2, 96.0, 96.0, &testdata_8bppGray_xp
};
593 static const BYTE bits_24bppBGR_gray
[] = {
594 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
595 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
596 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
597 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
598 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255,
599 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255,
600 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255,
601 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255};
602 static const struct bitmap_data testdata_24bppBGR_gray
= {
603 &GUID_WICPixelFormat24bppBGR
, 24, bits_24bppBGR_gray
, 32, 2, 96.0, 96.0};
605 static void test_conversion(const struct bitmap_data
*src
, const struct bitmap_data
*dst
, const char *name
, BOOL todo
)
607 BitmapTestSrc
*src_obj
;
608 IWICBitmapSource
*dst_bitmap
;
611 CreateTestBitmap(src
, &src_obj
);
613 hr
= WICConvertBitmapSource(dst
->format
, &src_obj
->IWICBitmapSource_iface
, &dst_bitmap
);
616 broken(hr
== E_INVALIDARG
|| hr
== WINCODEC_ERR_COMPONENTNOTFOUND
) /* XP */, "WICConvertBitmapSource(%s) failed, hr=%lx\n", name
, hr
);
620 compare_bitmap_data(src
, dst
, dst_bitmap
, name
);
622 IWICBitmapSource_Release(dst_bitmap
);
625 DeleteTestBitmap(src_obj
);
628 static void test_invalid_conversion(void)
630 BitmapTestSrc
*src_obj
;
631 IWICBitmapSource
*dst_bitmap
;
634 CreateTestBitmap(&testdata_32bppBGRA
, &src_obj
);
636 /* convert to a non-pixel-format GUID */
637 hr
= WICConvertBitmapSource(&GUID_VendorMicrosoft
, &src_obj
->IWICBitmapSource_iface
, &dst_bitmap
);
638 ok(hr
== WINCODEC_ERR_COMPONENTNOTFOUND
, "WICConvertBitmapSource returned %lx\n", hr
);
640 DeleteTestBitmap(src_obj
);
643 static void test_default_converter(void)
645 BitmapTestSrc
*src_obj
;
646 IWICFormatConverter
*converter
;
647 BOOL can_convert
= TRUE
;
650 CreateTestBitmap(&testdata_32bppBGRA
, &src_obj
);
652 hr
= CoCreateInstance(&CLSID_WICDefaultFormatConverter
, NULL
, CLSCTX_INPROC_SERVER
,
653 &IID_IWICFormatConverter
, (void**)&converter
);
654 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%lx\n", hr
);
657 hr
= IWICFormatConverter_CanConvert(converter
, &GUID_WICPixelFormat32bppBGRA
,
658 &GUID_WICPixelFormat32bppBGR
, &can_convert
);
659 ok(SUCCEEDED(hr
), "CanConvert returned %lx\n", hr
);
660 ok(can_convert
, "expected TRUE, got %i\n", can_convert
);
662 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
663 &GUID_WICPixelFormat32bppBGR
, WICBitmapDitherTypeNone
, NULL
, 0.0,
664 WICBitmapPaletteTypeCustom
);
665 ok(SUCCEEDED(hr
), "Initialize returned %lx\n", hr
);
668 compare_bitmap_data(&testdata_32bppBGRA
, &testdata_32bppBGR
, (IWICBitmapSource
*)converter
, "default converter");
670 IWICFormatConverter_Release(converter
);
673 DeleteTestBitmap(src_obj
);
676 static void test_converter_4bppGray(void)
678 BitmapTestSrc
*src_obj
;
679 IWICFormatConverter
*converter
;
680 BOOL can_convert
= TRUE
;
683 CreateTestBitmap(&testdata_32bppBGRA
, &src_obj
);
685 hr
= CoCreateInstance(&CLSID_WICDefaultFormatConverter
, NULL
, CLSCTX_INPROC_SERVER
,
686 &IID_IWICFormatConverter
, (void**)&converter
);
687 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%lx\n", hr
);
690 hr
= IWICFormatConverter_CanConvert(converter
, &GUID_WICPixelFormat32bppBGRA
,
691 &GUID_WICPixelFormat4bppGray
, &can_convert
);
692 ok(SUCCEEDED(hr
), "CanConvert returned %lx\n", hr
);
693 todo_wine
ok(can_convert
, "expected TRUE, got %i\n", can_convert
);
695 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
696 &GUID_WICPixelFormat4bppGray
, WICBitmapDitherTypeNone
, NULL
, 0.0,
697 WICBitmapPaletteTypeCustom
);
698 todo_wine
ok(SUCCEEDED(hr
), "Initialize returned %lx\n", hr
);
701 compare_bitmap_data(&testdata_32bppBGRA
, &testdata_4bppGray
, (IWICBitmapSource
*)converter
, "4bppGray converter");
703 IWICFormatConverter_Release(converter
);
706 DeleteTestBitmap(src_obj
);
709 static void test_converter_8bppGray(void)
711 BitmapTestSrc
*src_obj
;
712 IWICFormatConverter
*converter
;
713 BOOL can_convert
= TRUE
;
716 CreateTestBitmap(&testdata_32bppBGRA
, &src_obj
);
718 hr
= CoCreateInstance(&CLSID_WICDefaultFormatConverter
, NULL
, CLSCTX_INPROC_SERVER
,
719 &IID_IWICFormatConverter
, (void**)&converter
);
720 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%lx\n", hr
);
723 hr
= IWICFormatConverter_CanConvert(converter
, &GUID_WICPixelFormat32bppBGRA
,
724 &GUID_WICPixelFormat8bppGray
, &can_convert
);
725 ok(SUCCEEDED(hr
), "CanConvert returned %lx\n", hr
);
726 ok(can_convert
, "expected TRUE, got %i\n", can_convert
);
728 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
729 &GUID_WICPixelFormat8bppGray
, WICBitmapDitherTypeNone
, NULL
, 0.0,
730 WICBitmapPaletteTypeCustom
);
731 ok(SUCCEEDED(hr
), "Initialize returned %lx\n", hr
);
734 compare_bitmap_data(&testdata_32bppBGRA
, &testdata_8bppGray
, (IWICBitmapSource
*)converter
, "8bppGray converter");
736 IWICFormatConverter_Release(converter
);
739 DeleteTestBitmap(src_obj
);
742 typedef struct property_opt_test_data
746 VARTYPE initial_var_type
;
750 } property_opt_test_data
;
752 static const WCHAR wszTiffCompressionMethod
[] = {'T','i','f','f','C','o','m','p','r','e','s','s','i','o','n','M','e','t','h','o','d',0};
753 static const WCHAR wszCompressionQuality
[] = {'C','o','m','p','r','e','s','s','i','o','n','Q','u','a','l','i','t','y',0};
754 static const WCHAR wszInterlaceOption
[] = {'I','n','t','e','r','l','a','c','e','O','p','t','i','o','n',0};
755 static const WCHAR wszFilterOption
[] = {'F','i','l','t','e','r','O','p','t','i','o','n',0};
756 static const WCHAR wszImageQuality
[] = {'I','m','a','g','e','Q','u','a','l','i','t','y',0};
757 static const WCHAR wszBitmapTransform
[] = {'B','i','t','m','a','p','T','r','a','n','s','f','o','r','m',0};
758 static const WCHAR wszLuminance
[] = {'L','u','m','i','n','a','n','c','e',0};
759 static const WCHAR wszChrominance
[] = {'C','h','r','o','m','i','n','a','n','c','e',0};
760 static const WCHAR wszJpegYCrCbSubsampling
[] = {'J','p','e','g','Y','C','r','C','b','S','u','b','s','a','m','p','l','i','n','g',0};
761 static const WCHAR wszSuppressApp0
[] = {'S','u','p','p','r','e','s','s','A','p','p','0',0};
762 static const WCHAR wszEnableV5Header32bppBGRA
[] = {'E','n','a','b','l','e','V','5','H','e','a','d','e','r','3','2','b','p','p','B','G','R','A',0};
764 static const struct property_opt_test_data testdata_tiff_props
[] = {
765 { wszTiffCompressionMethod
, VT_UI1
, VT_UI1
, WICTiffCompressionDontCare
},
766 { wszCompressionQuality
, VT_R4
, VT_EMPTY
},
770 static const struct property_opt_test_data testdata_png_props
[] = {
771 { wszInterlaceOption
, VT_BOOL
, VT_BOOL
, 0 },
772 { wszFilterOption
, VT_UI1
, VT_UI1
, WICPngFilterUnspecified
, 0.0f
, TRUE
/* not supported on XP/2k3 */},
776 static const struct property_opt_test_data testdata_jpeg_props
[] = {
777 { wszImageQuality
, VT_R4
, VT_EMPTY
},
778 { wszBitmapTransform
, VT_UI1
, VT_UI1
, WICBitmapTransformRotate0
},
779 { wszLuminance
, VT_I4
|VT_ARRAY
, VT_EMPTY
},
780 { wszChrominance
, VT_I4
|VT_ARRAY
, VT_EMPTY
},
781 { wszJpegYCrCbSubsampling
, VT_UI1
, VT_UI1
, WICJpegYCrCbSubsamplingDefault
, 0.0f
, TRUE
}, /* not supported on XP/2k3 */
782 { wszSuppressApp0
, VT_BOOL
, VT_BOOL
, FALSE
},
786 static const struct property_opt_test_data testdata_bmp_props
[] = {
787 { wszEnableV5Header32bppBGRA
, VT_BOOL
, VT_BOOL
, VARIANT_FALSE
, 0.0f
, TRUE
}, /* Supported since Win7 */
791 static int find_property_index(const WCHAR
* name
, PROPBAG2
* all_props
, int all_prop_cnt
)
794 for (i
=0; i
< all_prop_cnt
; i
++)
796 if (lstrcmpW(name
, all_props
[i
].pstrName
) == 0)
802 static void test_specific_encoder_properties(IPropertyBag2
*options
, const property_opt_test_data
* data
, PROPBAG2
* all_props
, int all_prop_cnt
)
807 HRESULT phrError
= S_OK
;
811 int idx
= find_property_index(data
[i
].name
, all_props
, all_prop_cnt
);
813 pb
.pstrName
= (LPOLESTR
)data
[i
].name
;
815 hr
= IPropertyBag2_Read(options
, 1, &pb
, NULL
, &pvarValue
, &phrError
);
817 if (data
[i
].skippable
&& idx
== -1)
819 win_skip("Property %s is not supported on this machine.\n", wine_dbgstr_w(data
[i
].name
));
824 ok(idx
>= 0, "Property %s not in output of GetPropertyInfo\n",
825 wine_dbgstr_w(data
[i
].name
));
828 ok(all_props
[idx
].vt
== data
[i
].var_type
, "Property %s has unexpected vt type, vt=%i\n",
829 wine_dbgstr_w(data
[i
].name
), all_props
[idx
].vt
);
830 ok(all_props
[idx
].dwType
== PROPBAG2_TYPE_DATA
, "Property %s has unexpected dw type, vt=%li\n",
831 wine_dbgstr_w(data
[i
].name
), all_props
[idx
].dwType
);
832 ok(all_props
[idx
].cfType
== 0, "Property %s has unexpected cf type, vt=%i\n",
833 wine_dbgstr_w(data
[i
].name
), all_props
[idx
].cfType
);
836 ok(SUCCEEDED(hr
), "Reading property %s from bag failed, hr=%lx\n",
837 wine_dbgstr_w(data
[i
].name
), hr
);
841 /* On XP the initial type is always VT_EMPTY */
842 ok(V_VT(&pvarValue
) == data
[i
].initial_var_type
|| V_VT(&pvarValue
) == VT_EMPTY
,
843 "Property %s has unexpected initial type, V_VT=%i\n",
844 wine_dbgstr_w(data
[i
].name
), V_VT(&pvarValue
));
846 if(V_VT(&pvarValue
) == data
[i
].initial_var_type
)
848 switch (data
[i
].initial_var_type
)
852 ok(V_UNION(&pvarValue
, bVal
) == data
[i
].i_init_val
, "Property %s has an unexpected initial value, pvarValue=%i\n",
853 wine_dbgstr_w(data
[i
].name
), V_UNION(&pvarValue
, bVal
));
856 ok(V_UNION(&pvarValue
, fltVal
) == data
[i
].f_init_val
, "Property %s has an unexpected initial value, pvarValue=%f\n",
857 wine_dbgstr_w(data
[i
].name
), V_UNION(&pvarValue
, fltVal
));
864 VariantClear(&pvarValue
);
871 static void test_encoder_properties(const CLSID
* clsid_encoder
, IPropertyBag2
*options
)
874 ULONG cProperties
= 0;
875 ULONG cProperties2
= 0;
876 PROPBAG2 all_props
[64] = {{0}}; /* Should be enough for every encoder out there */
879 /* CountProperties */
881 hr
= IPropertyBag2_CountProperties(options
, &cProperties
);
882 ok(SUCCEEDED(hr
), "Reading property count, hr=%lx\n", hr
);
885 /* GetPropertyInfo */
887 hr
= IPropertyBag2_GetPropertyInfo(options
, cProperties
, 1, all_props
, &cProperties2
);
888 ok(hr
== WINCODEC_ERR_VALUEOUTOFRANGE
, "IPropertyBag2::GetPropertyInfo - iProperty out of bounce handled wrong, hr=%lx\n", hr
);
890 hr
= IPropertyBag2_GetPropertyInfo(options
, 0, cProperties
+1, all_props
, &cProperties2
);
891 ok(hr
== WINCODEC_ERR_VALUEOUTOFRANGE
, "IPropertyBag2::GetPropertyInfo - cProperty out of bounce handled wrong, hr=%lx\n", hr
);
893 if (cProperties
== 0) /* GetPropertyInfo can be called for zero items on Windows 8 but not on Windows 7 (wine behaves like Win8) */
895 cProperties2
= cProperties
;
900 hr
= IPropertyBag2_GetPropertyInfo(options
, 0, min(64, cProperties
), all_props
, &cProperties2
);
901 ok(SUCCEEDED(hr
), "Reading infos from property bag failed, hr=%lx\n", hr
);
907 ok(cProperties
== cProperties2
, "Mismatch of property count (IPropertyBag2::CountProperties=%i, IPropertyBag2::GetPropertyInfo=%i)\n",
908 (int)cProperties
, (int)cProperties2
);
911 if (IsEqualCLSID(clsid_encoder
, &CLSID_WICTiffEncoder
))
912 test_specific_encoder_properties(options
, testdata_tiff_props
, all_props
, cProperties2
);
913 else if (IsEqualCLSID(clsid_encoder
, &CLSID_WICPngEncoder
))
914 test_specific_encoder_properties(options
, testdata_png_props
, all_props
, cProperties2
);
915 else if (IsEqualCLSID(clsid_encoder
, &CLSID_WICJpegEncoder
))
916 test_specific_encoder_properties(options
, testdata_jpeg_props
, all_props
, cProperties2
);
917 else if (IsEqualCLSID(clsid_encoder
, &CLSID_WICBmpEncoder
))
918 test_specific_encoder_properties(options
, testdata_bmp_props
, all_props
, cProperties2
);
920 for (i
=0; i
< cProperties2
; i
++)
922 ok(all_props
[i
].pstrName
!= NULL
, "Unset property name in output of IPropertyBag2::GetPropertyInfo\n");
923 CoTaskMemFree(all_props
[i
].pstrName
);
927 static void load_stream(IUnknown
*reader
, IStream
*stream
)
930 IWICPersistStream
*persist
;
931 #ifdef WORDS_BIGENDIAN
932 DWORD persist_options
= WICPersistOptionBigEndian
;
934 DWORD persist_options
= WICPersistOptionLittleEndian
;
937 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
938 ok(hr
== S_OK
, "QueryInterface failed, hr=%lx\n", hr
);
940 hr
= IWICPersistStream_LoadEx(persist
, stream
, NULL
, persist_options
);
941 ok(hr
== S_OK
, "LoadEx failed, hr=%lx\n", hr
);
943 IWICPersistStream_Release(persist
);
946 static void check_tiff_format(IStream
*stream
, const WICPixelFormatGUID
*format
)
949 IWICMetadataReader
*reader
;
950 PROPVARIANT id
, value
;
959 int width
, height
, bps
, photo
, samples
, colormap
;
965 { 0x100, &width
}, { 0x101, &height
}, { 0x102, &bps
},
966 { 0x106, &photo
}, { 0x115, &samples
}, { 0x140, &colormap
}
969 memset(&tiff
, 0, sizeof(tiff
));
970 hr
= IStream_Read(stream
, &tiff
, sizeof(tiff
), NULL
);
971 ok(hr
== S_OK
, "IStream_Read error %#lx\n", hr
);
972 ok(tiff
.byte_order
== MAKEWORD('I','I') || tiff
.byte_order
== MAKEWORD('M','M'),
973 "wrong TIFF byte order mark %02x\n", tiff
.byte_order
);
974 ok(tiff
.version
== 42, "wrong TIFF version %u\n", tiff
.version
);
976 pos
.QuadPart
= tiff
.dir_offset
;
977 hr
= IStream_Seek(stream
, pos
, SEEK_SET
, NULL
);
978 ok(hr
== S_OK
, "IStream_Seek error %#lx\n", hr
);
980 hr
= CoCreateInstance(&CLSID_WICIfdMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
981 &IID_IWICMetadataReader
, (void **)&reader
);
982 ok(hr
== S_OK
, "CoCreateInstance error %#lx\n", hr
);
984 load_stream((IUnknown
*)reader
, stream
);
986 hr
= IWICMetadataReader_GetCount(reader
, &count
);
987 ok(hr
== S_OK
, "GetCount error %#lx\n", hr
);
988 ok(count
!= 0, "wrong count %u\n", count
);
990 for (i
= 0; i
< ARRAY_SIZE(tag
); i
++)
992 PropVariantInit(&id
);
993 PropVariantInit(&value
);
996 U(id
).uiVal
= tag
[i
].id
;
997 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, &value
);
998 ok(hr
== S_OK
|| (tag
[i
].id
== 0x140 && hr
== WINCODEC_ERR_PROPERTYNOTFOUND
),
999 "GetValue(%04x) error %#lx\n", tag
[i
].id
, hr
);
1002 ok(value
.vt
== VT_UI2
|| value
.vt
== VT_UI4
|| value
.vt
== (VT_UI2
| VT_VECTOR
), "wrong vt: %d\n", value
.vt
);
1003 tag
[i
].value
[0] = U(value
).uiVal
;
1006 tag
[i
].value
[0] = -1;
1008 PropVariantClear(&value
);
1011 IWICMetadataReader_Release(reader
);
1013 if (IsEqualGUID(format
, &GUID_WICPixelFormatBlackWhite
))
1015 ok(width
== 32, "wrong width %u\n", width
);
1016 ok(height
== 2, "wrong height %u\n", height
);
1018 ok(bps
== 1, "wrong bps %d\n", bps
);
1019 ok(photo
== 1, "wrong photometric %d\n", photo
);
1020 ok(samples
== 1, "wrong samples %d\n", samples
);
1021 ok(colormap
== -1, "wrong colormap %d\n", colormap
);
1023 else if (IsEqualGUID(format
, &GUID_WICPixelFormat1bppIndexed
))
1025 ok(width
== 32, "wrong width %u\n", width
);
1026 ok(height
== 2, "wrong height %u\n", height
);
1028 ok(bps
== 1, "wrong bps %d\n", bps
);
1029 ok(photo
== 3, "wrong photometric %d\n", photo
);
1030 ok(samples
== 1, "wrong samples %d\n", samples
);
1031 ok(colormap
== 6, "wrong colormap %d\n", colormap
);
1033 else if (IsEqualGUID(format
, &GUID_WICPixelFormat4bppIndexed
))
1035 ok(width
== 32, "wrong width %u\n", width
);
1036 ok(height
== 2, "wrong height %u\n", height
);
1038 ok(bps
== 4, "wrong bps %d\n", bps
);
1039 ok(photo
== 3, "wrong photometric %d\n", photo
);
1040 ok(samples
== 1, "wrong samples %d\n", samples
);
1041 ok(colormap
== 48, "wrong colormap %d\n", colormap
);
1043 else if (IsEqualGUID(format
, &GUID_WICPixelFormat8bppIndexed
))
1045 ok(width
== 32, "wrong width %u\n", width
);
1046 ok(height
== 2, "wrong height %u\n", height
);
1048 ok(bps
== 8, "wrong bps %d\n", bps
);
1049 ok(photo
== 3, "wrong photometric %d\n", photo
);
1050 ok(samples
== 1, "wrong samples %d\n", samples
);
1051 ok(colormap
== 768, "wrong colormap %d\n", colormap
);
1053 else if (IsEqualGUID(format
, &GUID_WICPixelFormat24bppBGR
))
1055 ok(width
== 32, "wrong width %u\n", width
);
1056 ok(height
== 2, "wrong height %u\n", height
);
1058 ok(bps
== 3, "wrong bps %d\n", bps
);
1059 ok(photo
== 2, "wrong photometric %d\n", photo
);
1060 ok(samples
== 3, "wrong samples %d\n", samples
);
1061 ok(colormap
== -1, "wrong colormap %d\n", colormap
);
1064 ok(0, "unknown TIFF pixel format %s\n", wine_dbgstr_guid(format
));
1067 static void check_bmp_format(IStream
*stream
, const WICPixelFormatGUID
*format
)
1070 BITMAPFILEHEADER bfh
;
1073 hr
= IStream_Read(stream
, &bfh
, sizeof(bfh
), NULL
);
1074 ok(hr
== S_OK
, "IStream_Read error %#lx\n", hr
);
1076 ok(bfh
.bfType
== 0x4d42, "wrong BMP signature %02x\n", bfh
.bfType
);
1077 ok(bfh
.bfReserved1
== 0, "wrong bfReserved1 %02x\n", bfh
.bfReserved1
);
1078 ok(bfh
.bfReserved2
== 0, "wrong bfReserved2 %02x\n", bfh
.bfReserved2
);
1080 hr
= IStream_Read(stream
, &bih
, sizeof(bih
), NULL
);
1081 ok(hr
== S_OK
, "IStream_Read error %#lx\n", hr
);
1083 if (IsEqualGUID(format
, &GUID_WICPixelFormat1bppIndexed
))
1085 ok(bfh
.bfOffBits
== 0x0436, "wrong bfOffBits %08lx\n", bfh
.bfOffBits
);
1087 ok(bih
.bV5Width
== 32, "wrong width %lu\n", bih
.bV5Width
);
1088 ok(bih
.bV5Height
== 2, "wrong height %lu\n", bih
.bV5Height
);
1090 ok(bih
.bV5Planes
== 1, "wrong Planes %d\n", bih
.bV5Planes
);
1091 ok(bih
.bV5BitCount
== 1, "wrong BitCount %d\n", bih
.bV5BitCount
);
1092 ok(bih
.bV5ClrUsed
== 256, "wrong ClrUsed %ld\n", bih
.bV5ClrUsed
);
1093 ok(bih
.bV5ClrImportant
== 256, "wrong ClrImportant %ld\n", bih
.bV5ClrImportant
);
1095 else if (IsEqualGUID(format
, &GUID_WICPixelFormat4bppIndexed
))
1097 ok(bfh
.bfOffBits
== 0x0436, "wrong bfOffBits %08lx\n", bfh
.bfOffBits
);
1099 ok(bih
.bV5Width
== 32, "wrong width %lu\n", bih
.bV5Width
);
1100 ok(bih
.bV5Height
== 2, "wrong height %lu\n", bih
.bV5Height
);
1102 ok(bih
.bV5Planes
== 1, "wrong Planes %d\n", bih
.bV5Planes
);
1103 ok(bih
.bV5BitCount
== 4, "wrong BitCount %d\n", bih
.bV5BitCount
);
1104 ok(bih
.bV5ClrUsed
== 256, "wrong ClrUsed %ld\n", bih
.bV5ClrUsed
);
1105 ok(bih
.bV5ClrImportant
== 256, "wrong ClrImportant %ld\n", bih
.bV5ClrImportant
);
1107 else if (IsEqualGUID(format
, &GUID_WICPixelFormat8bppIndexed
))
1109 ok(bfh
.bfOffBits
== 0x0436, "wrong bfOffBits %08lx\n", bfh
.bfOffBits
);
1111 ok(bih
.bV5Width
== 32, "wrong width %lu\n", bih
.bV5Width
);
1112 ok(bih
.bV5Height
== 2, "wrong height %lu\n", bih
.bV5Height
);
1114 ok(bih
.bV5Planes
== 1, "wrong Planes %d\n", bih
.bV5Planes
);
1115 ok(bih
.bV5BitCount
== 8, "wrong BitCount %d\n", bih
.bV5BitCount
);
1116 ok(bih
.bV5ClrUsed
== 256, "wrong ClrUsed %ld\n", bih
.bV5ClrUsed
);
1117 ok(bih
.bV5ClrImportant
== 256, "wrong ClrImportant %ld\n", bih
.bV5ClrImportant
);
1119 else if (IsEqualGUID(format
, &GUID_WICPixelFormat32bppBGR
))
1121 ok(bfh
.bfOffBits
== 0x0036, "wrong bfOffBits %08lx\n", bfh
.bfOffBits
);
1123 ok(bih
.bV5Width
== 32, "wrong width %lu\n", bih
.bV5Width
);
1124 ok(bih
.bV5Height
== 2, "wrong height %lu\n", bih
.bV5Height
);
1126 ok(bih
.bV5Planes
== 1, "wrong Planes %d\n", bih
.bV5Planes
);
1127 ok(bih
.bV5BitCount
== 32, "wrong BitCount %d\n", bih
.bV5BitCount
);
1128 ok(bih
.bV5ClrUsed
== 0, "wrong ClrUsed %ld\n", bih
.bV5ClrUsed
);
1129 ok(bih
.bV5ClrImportant
== 0, "wrong ClrImportant %ld\n", bih
.bV5ClrImportant
);
1132 ok(0, "unknown BMP pixel format %s\n", wine_dbgstr_guid(format
));
1135 static unsigned be_uint(unsigned val
)
1144 return (u
.c
[0] << 24) | (u
.c
[1] << 16) | (u
.c
[2] << 8) | u
.c
[3];
1147 static void check_png_format(IStream
*stream
, const WICPixelFormatGUID
*format
)
1149 static const char png_sig
[8] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a};
1150 static const char png_IHDR
[8] = {0,0,0,0x0d,'I','H','D','R'};
1156 unsigned width
, height
;
1157 char bit_depth
, color_type
, compression
, filter
, interlace
;
1160 memset(&png
, 0, sizeof(png
));
1161 hr
= IStream_Read(stream
, &png
, sizeof(png
), NULL
);
1162 ok(hr
== S_OK
, "IStream_Read error %#lx\n", hr
);
1164 ok(!memcmp(png
.png_sig
, png_sig
, sizeof(png_sig
)), "expected PNG signature\n");
1165 ok(!memcmp(png
.ihdr_sig
, png_IHDR
, sizeof(png_IHDR
)), "expected PNG IHDR\n");
1167 if (IsEqualGUID(format
, &GUID_WICPixelFormatBlackWhite
))
1169 ok(be_uint(png
.width
) == 32, "wrong width %u\n", be_uint(png
.width
));
1170 ok(be_uint(png
.height
) == 2, "wrong height %u\n", be_uint(png
.height
));
1172 ok(png
.bit_depth
== 1, "wrong bit_depth %d\n", png
.bit_depth
);
1173 ok(png
.color_type
== 0, "wrong color_type %d\n", png
.color_type
);
1174 ok(png
.compression
== 0, "wrong compression %d\n", png
.compression
);
1175 ok(png
.filter
== 0, "wrong filter %d\n", png
.filter
);
1176 ok(png
.interlace
== 0, "wrong interlace %d\n", png
.interlace
);
1178 else if (IsEqualGUID(format
, &GUID_WICPixelFormat1bppIndexed
))
1180 ok(be_uint(png
.width
) == 32, "wrong width %u\n", be_uint(png
.width
));
1181 ok(be_uint(png
.height
) == 2, "wrong height %u\n", be_uint(png
.height
));
1183 ok(png
.bit_depth
== 1, "wrong bit_depth %d\n", png
.bit_depth
);
1184 ok(png
.color_type
== 3, "wrong color_type %d\n", png
.color_type
);
1185 ok(png
.compression
== 0, "wrong compression %d\n", png
.compression
);
1186 ok(png
.filter
== 0, "wrong filter %d\n", png
.filter
);
1187 ok(png
.interlace
== 0, "wrong interlace %d\n", png
.interlace
);
1189 else if (IsEqualGUID(format
, &GUID_WICPixelFormat2bppIndexed
))
1191 ok(be_uint(png
.width
) == 32, "wrong width %u\n", be_uint(png
.width
));
1192 ok(be_uint(png
.height
) == 2, "wrong height %u\n", be_uint(png
.height
));
1194 ok(png
.bit_depth
== 2, "wrong bit_depth %d\n", png
.bit_depth
);
1195 ok(png
.color_type
== 3, "wrong color_type %d\n", png
.color_type
);
1196 ok(png
.compression
== 0, "wrong compression %d\n", png
.compression
);
1197 ok(png
.filter
== 0, "wrong filter %d\n", png
.filter
);
1198 ok(png
.interlace
== 0, "wrong interlace %d\n", png
.interlace
);
1200 else if (IsEqualGUID(format
, &GUID_WICPixelFormat4bppIndexed
))
1202 ok(be_uint(png
.width
) == 32, "wrong width %u\n", be_uint(png
.width
));
1203 ok(be_uint(png
.height
) == 2, "wrong height %u\n", be_uint(png
.height
));
1205 ok(png
.bit_depth
== 4, "wrong bit_depth %d\n", png
.bit_depth
);
1206 ok(png
.color_type
== 3, "wrong color_type %d\n", png
.color_type
);
1207 ok(png
.compression
== 0, "wrong compression %d\n", png
.compression
);
1208 ok(png
.filter
== 0, "wrong filter %d\n", png
.filter
);
1209 ok(png
.interlace
== 0, "wrong interlace %d\n", png
.interlace
);
1211 else if (IsEqualGUID(format
, &GUID_WICPixelFormat8bppIndexed
))
1213 ok(be_uint(png
.width
) == 32, "wrong width %u\n", be_uint(png
.width
));
1214 ok(be_uint(png
.height
) == 2, "wrong height %u\n", be_uint(png
.height
));
1216 ok(png
.bit_depth
== 8, "wrong bit_depth %d\n", png
.bit_depth
);
1217 ok(png
.color_type
== 3, "wrong color_type %d\n", png
.color_type
);
1218 ok(png
.compression
== 0, "wrong compression %d\n", png
.compression
);
1219 ok(png
.filter
== 0, "wrong filter %d\n", png
.filter
);
1220 ok(png
.interlace
== 0, "wrong interlace %d\n", png
.interlace
);
1222 else if (IsEqualGUID(format
, &GUID_WICPixelFormat24bppBGR
))
1224 ok(be_uint(png
.width
) == 32, "wrong width %u\n", be_uint(png
.width
));
1225 ok(be_uint(png
.height
) == 2, "wrong height %u\n", be_uint(png
.height
));
1227 ok(png
.bit_depth
== 8, "wrong bit_depth %d\n", png
.bit_depth
);
1228 ok(png
.color_type
== 2, "wrong color_type %d\n", png
.color_type
);
1229 ok(png
.compression
== 0, "wrong compression %d\n", png
.compression
);
1230 ok(png
.filter
== 0, "wrong filter %d\n", png
.filter
);
1231 ok(png
.interlace
== 0 || png
.interlace
== 1, "wrong interlace %d\n", png
.interlace
);
1234 ok(0, "unknown PNG pixel format %s\n", wine_dbgstr_guid(format
));
1237 static void check_gif_format(IStream
*stream
, const WICPixelFormatGUID
*format
)
1239 #include "pshpack1.h"
1240 struct logical_screen_descriptor
1246 /* global_color_table_flag : 1;
1247 * color_resolution : 3;
1249 * global_color_table_size : 3;
1251 BYTE background_color_index
;
1252 BYTE pixel_aspect_ratio
;
1254 #include "poppack.h"
1255 UINT color_resolution
;
1258 memset(&lsd
, 0, sizeof(lsd
));
1259 hr
= IStream_Read(stream
, &lsd
, sizeof(lsd
), NULL
);
1260 ok(hr
== S_OK
, "IStream_Read error %#lx\n", hr
);
1262 ok(!memcmp(lsd
.signature
, "GIF89a", 6), "wrong GIF signature %.6s\n", lsd
.signature
);
1264 ok(lsd
.width
== 32, "wrong width %u\n", lsd
.width
);
1265 ok(lsd
.height
== 2, "wrong height %u\n", lsd
.height
);
1266 color_resolution
= 1 << (((lsd
.packed
>> 4) & 0x07) + 1);
1267 ok(color_resolution
== 256, "wrong color resolution %u\n", color_resolution
);
1268 ok(lsd
.pixel_aspect_ratio
== 0, "wrong pixel_aspect_ratio %u\n", lsd
.pixel_aspect_ratio
);
1271 static void check_bitmap_format(IStream
*stream
, const CLSID
*encoder
, const WICPixelFormatGUID
*format
)
1277 hr
= IStream_Seek(stream
, pos
, SEEK_SET
, (ULARGE_INTEGER
*)&pos
);
1278 ok(hr
== S_OK
, "IStream_Seek error %#lx\n", hr
);
1280 if (IsEqualGUID(encoder
, &CLSID_WICPngEncoder
))
1281 check_png_format(stream
, format
);
1282 else if (IsEqualGUID(encoder
, &CLSID_WICBmpEncoder
))
1283 check_bmp_format(stream
, format
);
1284 else if (IsEqualGUID(encoder
, &CLSID_WICTiffEncoder
))
1285 check_tiff_format(stream
, format
);
1286 else if (IsEqualGUID(encoder
, &CLSID_WICGifEncoder
))
1287 check_gif_format(stream
, format
);
1289 ok(0, "unknown encoder %s\n", wine_dbgstr_guid(encoder
));
1291 hr
= IStream_Seek(stream
, pos
, SEEK_SET
, NULL
);
1292 ok(hr
== S_OK
, "IStream_Seek error %#lx\n", hr
);
1302 #define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__)
1303 static void _expect_ref(IUnknown
* obj
, ULONG ref
, int line
)
1306 IUnknown_AddRef(obj
);
1307 rc
= IUnknown_Release(obj
);
1308 ok_(__FILE__
,line
)(rc
== ref
, "expected refcount %ld, got %ld\n", ref
, rc
);
1311 static void test_set_frame_palette(IWICBitmapFrameEncode
*frameencode
)
1313 IWICComponentFactory
*factory
;
1314 IWICPalette
*palette
;
1317 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
1318 &IID_IWICComponentFactory
, (void **)&factory
);
1319 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%lx\n", hr
);
1321 hr
= IWICBitmapFrameEncode_SetPalette(frameencode
, NULL
);
1322 ok(hr
== E_INVALIDARG
, "SetPalette failed, hr=%lx\n", hr
);
1324 hr
= IWICComponentFactory_CreatePalette(factory
, &palette
);
1325 ok(hr
== S_OK
, "CreatePalette failed, hr=%lx\n", hr
);
1327 hr
= IWICBitmapFrameEncode_SetPalette(frameencode
, palette
);
1329 ok(hr
== WINCODEC_ERR_NOTINITIALIZED
, "Unexpected hr=%lx\n", hr
);
1331 hr
= IWICPalette_InitializePredefined(palette
, WICBitmapPaletteTypeFixedHalftone256
, FALSE
);
1332 ok(hr
== S_OK
, "InitializePredefined failed, hr=%lx\n", hr
);
1334 EXPECT_REF(palette
, 1);
1335 hr
= IWICBitmapFrameEncode_SetPalette(frameencode
, palette
);
1336 ok(hr
== S_OK
, "SetPalette failed, hr=%lx\n", hr
);
1337 EXPECT_REF(palette
, 1);
1339 hr
= IWICBitmapFrameEncode_SetPalette(frameencode
, NULL
);
1340 ok(hr
== E_INVALIDARG
, "SetPalette failed, hr=%lx\n", hr
);
1342 IWICPalette_Release(palette
);
1343 IWICComponentFactory_Release(factory
);
1346 static void test_multi_encoder_impl(const struct bitmap_data
**srcs
, const CLSID
* clsid_encoder
,
1347 const struct bitmap_data
**dsts
, const CLSID
*clsid_decoder
, WICRect
*rc
,
1348 const struct setting
*settings
, const char *name
, IWICPalette
*palette
, BOOL set_size
)
1350 const GUID
*container_format
= NULL
;
1352 IWICBitmapEncoder
*encoder
;
1353 BitmapTestSrc
*src_obj
;
1356 IWICBitmapFrameEncode
*frameencode
;
1357 IPropertyBag2
*options
=NULL
;
1358 IWICBitmapDecoder
*decoder
;
1359 IWICBitmapFrameDecode
*framedecode
;
1360 WICPixelFormatGUID pixelformat
;
1364 hr
= CoCreateInstance(clsid_encoder
, NULL
, CLSCTX_INPROC_SERVER
,
1365 &IID_IWICBitmapEncoder
, (void **)&encoder
);
1366 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%lx\n", hr
);
1368 hr
= CreateStreamOnHGlobal(NULL
, TRUE
, &stream
);
1369 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%lx\n", hr
);
1371 hr
= IWICBitmapEncoder_GetContainerFormat(encoder
, NULL
);
1372 ok(hr
== E_INVALIDARG
, "Unexpected hr %#lx.\n", hr
);
1374 if (IsEqualGUID(clsid_encoder
, &CLSID_WICPngEncoder
))
1375 container_format
= &GUID_ContainerFormatPng
;
1376 else if (IsEqualGUID(clsid_encoder
, &CLSID_WICBmpEncoder
))
1377 container_format
= &GUID_ContainerFormatBmp
;
1378 else if (IsEqualGUID(clsid_encoder
, &CLSID_WICTiffEncoder
))
1379 container_format
= &GUID_ContainerFormatTiff
;
1380 else if (IsEqualGUID(clsid_encoder
, &CLSID_WICJpegEncoder
))
1381 container_format
= &GUID_ContainerFormatJpeg
;
1382 else if (IsEqualGUID(clsid_encoder
, &CLSID_WICGifEncoder
))
1383 container_format
= &GUID_ContainerFormatGif
;
1385 ok(0, "Unknown encoder %s.\n", wine_dbgstr_guid(clsid_encoder
));
1387 if (container_format
)
1389 memset(&guid
, 0, sizeof(guid
));
1390 hr
= IWICBitmapEncoder_GetContainerFormat(encoder
, &guid
);
1391 ok(SUCCEEDED(hr
), "Failed to get container format, hr %#lx.\n", hr
);
1392 ok(IsEqualGUID(container_format
, &guid
), "Unexpected container format %s.\n", wine_dbgstr_guid(&guid
));
1395 hr
= IWICBitmapEncoder_Initialize(encoder
, stream
, WICBitmapEncoderNoCache
);
1396 ok(SUCCEEDED(hr
), "Initialize failed, hr=%lx\n", hr
);
1398 /* Encoder options are optional. */
1399 hr
= IWICBitmapEncoder_CreateNewFrame(encoder
, &frameencode
, NULL
);
1400 ok(SUCCEEDED(hr
), "Failed to create encode frame, hr %#lx.\n", hr
);
1402 IStream_Release(stream
);
1403 IWICBitmapEncoder_Release(encoder
);
1404 IWICBitmapFrameEncode_Release(frameencode
);
1406 hr
= CoCreateInstance(clsid_encoder
, NULL
, CLSCTX_INPROC_SERVER
,
1407 &IID_IWICBitmapEncoder
, (void**)&encoder
);
1408 ok(SUCCEEDED(hr
), "CoCreateInstance(%s) failed, hr=%lx\n", wine_dbgstr_guid(clsid_encoder
), hr
);
1411 hglobal
= GlobalAlloc(GMEM_MOVEABLE
, 0);
1412 ok(hglobal
!= NULL
, "GlobalAlloc failed\n");
1415 hr
= CreateStreamOnHGlobal(hglobal
, TRUE
, &stream
);
1416 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%lx\n", hr
);
1419 if (hglobal
&& SUCCEEDED(hr
))
1423 hr
= IWICBitmapEncoder_SetPalette(encoder
, palette
);
1424 ok(hr
== WINCODEC_ERR_NOTINITIALIZED
, "wrong error %#lx (%s)\n", hr
, name
);
1427 hr
= IWICBitmapEncoder_Initialize(encoder
, stream
, WICBitmapEncoderNoCache
);
1428 ok(SUCCEEDED(hr
), "Initialize failed, hr=%lx\n", hr
);
1432 hr
= IWICBitmapEncoder_SetPalette(encoder
, palette
);
1433 if (IsEqualGUID(clsid_encoder
, &CLSID_WICGifEncoder
))
1434 ok(hr
== S_OK
, "SetPalette failed, hr=%#lx\n", hr
);
1436 ok(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
, "wrong error %#lx\n", hr
);
1441 while (SUCCEEDED(hr
) && srcs
[i
])
1443 CreateTestBitmap(srcs
[i
], &src_obj
);
1445 hr
= IWICBitmapEncoder_CreateNewFrame(encoder
, &frameencode
, &options
);
1446 ok(SUCCEEDED(hr
), "CreateFrame failed, hr=%lx\n", hr
);
1449 ok(options
!= NULL
, "Encoder initialization has not created an property bag\n");
1451 test_encoder_properties(clsid_encoder
, options
);
1456 for (j
=0; settings
[j
].name
; j
++)
1461 memset(&propbag
, 0, sizeof(propbag
));
1462 memset(&var
, 0, sizeof(var
));
1463 propbag
.pstrName
= (LPOLESTR
)settings
[j
].name
;
1464 propbag
.dwType
= settings
[j
].type
;
1465 V_VT(&var
) = settings
[j
].vt
;
1466 V_UNKNOWN(&var
) = settings
[j
].value
;
1468 hr
= IPropertyBag2_Write(options
, 1, &propbag
, &var
);
1469 ok(SUCCEEDED(hr
), "Writing property %s failed, hr=%lx\n", wine_dbgstr_w(settings
[j
].name
), hr
);
1475 hr
= IWICBitmapFrameEncode_SetPalette(frameencode
, palette
);
1476 ok(hr
== WINCODEC_ERR_NOTINITIALIZED
, "wrong error %#lx\n", hr
);
1479 hr
= IWICBitmapFrameEncode_Initialize(frameencode
, options
);
1480 ok(SUCCEEDED(hr
), "Initialize failed, hr=%lx\n", hr
);
1482 memcpy(&pixelformat
, srcs
[i
]->format
, sizeof(GUID
));
1483 hr
= IWICBitmapFrameEncode_SetPixelFormat(frameencode
, &pixelformat
);
1484 ok(SUCCEEDED(hr
), "SetPixelFormat failed, hr=%lx\n", hr
);
1485 ok(IsEqualGUID(&pixelformat
, dsts
[i
]->format
) ||
1486 (IsEqualGUID(clsid_encoder
, &CLSID_WICTiffEncoder
) && srcs
[i
]->bpp
== 2 && IsEqualGUID(&pixelformat
, &GUID_WICPixelFormat4bppIndexed
)) ||
1487 (IsEqualGUID(clsid_encoder
, &CLSID_WICBmpEncoder
) && srcs
[i
]->bpp
== 2 && IsEqualGUID(&pixelformat
, &GUID_WICPixelFormat4bppIndexed
)),
1488 "SetPixelFormat changed the format to %s (%s)\n", wine_dbgstr_guid(&pixelformat
), name
);
1492 hr
= IWICBitmapFrameEncode_SetSize(frameencode
, srcs
[i
]->width
, srcs
[i
]->height
);
1493 ok(hr
== S_OK
, "SetSize failed, hr=%lx\n", hr
);
1496 if (IsEqualGUID(clsid_encoder
, &CLSID_WICPngEncoder
))
1497 test_set_frame_palette(frameencode
);
1501 hr
= IWICBitmapFrameEncode_SetPalette(frameencode
, palette
);
1502 ok(SUCCEEDED(hr
), "SetPalette failed, hr=%lx (%s)\n", hr
, name
);
1505 hr
= IWICBitmapFrameEncode_WriteSource(frameencode
, &src_obj
->IWICBitmapSource_iface
, rc
);
1506 if (rc
&& (rc
->Width
<= 0 || rc
->Height
<= 0))
1508 /* WriteSource fails but WriteSource_Proxy succeeds. */
1509 ok(hr
== E_INVALIDARG
, "WriteSource should fail, hr=%lx (%s)\n", hr
, name
);
1510 hr
= IWICBitmapFrameEncode_WriteSource_Proxy(frameencode
, &src_obj
->IWICBitmapSource_iface
, rc
);
1511 if (!set_size
&& rc
->Width
< 0)
1513 ok(hr
== WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS
||
1514 hr
== HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW
) /* win11 */,
1515 "WriteSource_Proxy(%dx%d) got unexpected hr %lx (%s)\n", rc
->Width
, rc
->Height
, hr
, name
);
1517 ok(hr
== S_OK
, "WriteSource_Proxy failed, %dx%d, hr=%lx (%s)\n", rc
->Width
, rc
->Height
, hr
, name
);
1522 ok(SUCCEEDED(hr
), "WriteSource(%dx%d) failed, hr=%lx (%s)\n", rc
->Width
, rc
->Height
, hr
, name
);
1524 todo_wine_if((IsEqualGUID(clsid_encoder
, &CLSID_WICTiffEncoder
) && srcs
[i
]->bpp
== 2) ||
1525 (IsEqualGUID(clsid_encoder
, &CLSID_WICBmpEncoder
) && srcs
[i
]->bpp
== 2))
1526 ok(hr
== S_OK
, "WriteSource(NULL) failed, hr=%lx (%s)\n", hr
, name
);
1532 hr
= IWICBitmapFrameEncode_Commit(frameencode
);
1533 if (!set_size
&& rc
&& rc
->Height
< 0)
1535 ok(hr
== WINCODEC_ERR_UNEXPECTEDSIZE
, "Commit got unexpected hr %lx (%s)\n", hr
, name
);
1537 ok(hr
== S_OK
, "Commit failed, hr=%lx (%s)\n", hr
, name
);
1540 IWICBitmapFrameEncode_Release(frameencode
);
1541 IPropertyBag2_Release(options
);
1544 DeleteTestBitmap(src_obj
);
1549 if (clsid_decoder
== NULL
)
1551 IStream_Release(stream
);
1552 IWICBitmapEncoder_Release(encoder
);
1558 hr
= IWICBitmapEncoder_Commit(encoder
);
1559 ok(SUCCEEDED(hr
), "Commit failed, hr=%lx\n", hr
);
1561 if (IsEqualGUID(&pixelformat
, dsts
[0]->format
))
1562 check_bitmap_format(stream
, clsid_encoder
, dsts
[0]->format
);
1567 hr
= CoCreateInstance(clsid_decoder
, NULL
, CLSCTX_INPROC_SERVER
,
1568 &IID_IWICBitmapDecoder
, (void**)&decoder
);
1569 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%lx\n", hr
);
1574 IWICPalette
*frame_palette
;
1576 hr
= IWICImagingFactory_CreatePalette(factory
, &frame_palette
);
1577 ok(hr
== S_OK
, "CreatePalette error %#lx\n", hr
);
1579 hr
= IWICBitmapDecoder_CopyPalette(decoder
, frame_palette
);
1580 if (IsEqualGUID(clsid_decoder
, &CLSID_WICGifDecoder
))
1581 ok(hr
== WINCODEC_ERR_WRONGSTATE
, "wrong error %#lx\n", hr
);
1583 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "wrong error %#lx\n", hr
);
1585 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnDemand
);
1586 ok(SUCCEEDED(hr
), "Initialize failed, hr=%lx\n", hr
);
1588 hr
= IWICBitmapDecoder_CopyPalette(decoder
, frame_palette
);
1589 if (IsEqualGUID(clsid_decoder
, &CLSID_WICGifDecoder
))
1590 ok(hr
== S_OK
|| broken(hr
== WINCODEC_ERR_FRAMEMISSING
) /* XP */, "CopyPalette failed, hr=%#lx\n", hr
);
1592 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "wrong error %#lx\n", hr
);
1596 while (SUCCEEDED(hr
) && dsts
[i
])
1598 hr
= IWICBitmapDecoder_GetFrame(decoder
, i
, &framedecode
);
1599 ok(SUCCEEDED(hr
), "GetFrame failed, hr=%lx (%s)\n", hr
, name
);
1603 hr
= IWICBitmapFrameDecode_GetPixelFormat(framedecode
, &pixelformat
);
1604 ok(hr
== S_OK
, "GetPixelFormat) failed, hr=%lx (%s)\n", hr
, name
);
1605 if (IsEqualGUID(&pixelformat
, dsts
[i
]->format
))
1606 compare_bitmap_data(srcs
[i
], dsts
[i
], (IWICBitmapSource
*)framedecode
, name
);
1608 hr
= IWICBitmapFrameDecode_CopyPalette(framedecode
, frame_palette
);
1609 if (winetest_debug
> 1)
1610 trace("%s, bpp %d, %s, hr %#lx\n", name
, dsts
[i
]->bpp
, wine_dbgstr_guid(dsts
[i
]->format
), hr
);
1611 if (dsts
[i
]->bpp
> 8 || IsEqualGUID(dsts
[i
]->format
, &GUID_WICPixelFormatBlackWhite
))
1612 ok(hr
== WINCODEC_ERR_PALETTEUNAVAILABLE
, "wrong error %#lx\n", hr
);
1616 WICColor colors
[256];
1618 ok(hr
== S_OK
, "CopyPalette error %#lx (%s)\n", hr
, name
);
1621 hr
= IWICPalette_GetColorCount(frame_palette
, &count
);
1622 ok(hr
== S_OK
, "GetColorCount error %#lx\n", hr
);
1624 memset(colors
, 0, sizeof(colors
));
1626 hr
= IWICPalette_GetColors(frame_palette
, count
, colors
, &ret
);
1627 ok(hr
== S_OK
, "GetColors error %#lx\n", hr
);
1628 ok(ret
== count
, "expected %u, got %u\n", count
, ret
);
1629 if (IsEqualGUID(clsid_decoder
, &CLSID_WICPngDecoder
))
1631 /* Newer libpng versions don't accept larger palettes than the declared
1632 * bit depth, so we need to generate the palette of the correct length.
1634 ok(count
== 256 || (dsts
[i
]->bpp
== 1 && count
== 2) ||
1635 (dsts
[i
]->bpp
== 2 && count
== 4) || (dsts
[i
]->bpp
== 4 && count
== 16),
1636 "expected 256, got %u (%s)\n", count
, name
);
1638 ok(colors
[0] == 0x11111111, "got %08x (%s)\n", colors
[0], name
);
1639 ok(colors
[1] == 0x22222222, "got %08x (%s)\n", colors
[1], name
);
1642 ok(colors
[2] == 0x33333333, "got %08x (%s)\n", colors
[2], name
);
1643 ok(colors
[3] == 0x44444444, "got %08x (%s)\n", colors
[3], name
);
1646 ok(colors
[4] == 0x55555555, "got %08x (%s)\n", colors
[4], name
);
1647 ok(colors
[5] == 0, "got %08x (%s)\n", colors
[5], name
);
1651 else if (IsEqualGUID(clsid_decoder
, &CLSID_WICBmpDecoder
) ||
1652 IsEqualGUID(clsid_decoder
, &CLSID_WICTiffDecoder
) ||
1653 IsEqualGUID(clsid_decoder
, &CLSID_WICGifDecoder
))
1655 if (IsEqualGUID(&pixelformat
, &GUID_WICPixelFormatBlackWhite
) ||
1656 IsEqualGUID(&pixelformat
, &GUID_WICPixelFormat8bppIndexed
))
1658 ok(count
== 256, "expected 256, got %u (%s)\n", count
, name
);
1660 ok(colors
[0] == 0xff111111, "got %08x (%s)\n", colors
[0], name
);
1661 ok(colors
[1] == 0xff222222, "got %08x (%s)\n", colors
[1], name
);
1662 ok(colors
[2] == 0xff333333, "got %08x (%s)\n", colors
[2], name
);
1663 ok(colors
[3] == 0xff444444, "got %08x (%s)\n", colors
[3], name
);
1664 ok(colors
[4] == 0xff555555, "got %08x (%s)\n", colors
[4], name
);
1665 ok(colors
[5] == 0xff000000, "got %08x (%s)\n", colors
[5], name
);
1667 else if (IsEqualGUID(&pixelformat
, &GUID_WICPixelFormat4bppIndexed
))
1669 ok(count
== 16, "expected 16, got %u (%s)\n", count
, name
);
1671 ok(colors
[0] == 0xff111111, "got %08x (%s)\n", colors
[0], name
);
1672 ok(colors
[1] == 0xff222222, "got %08x (%s)\n", colors
[1], name
);
1673 ok(colors
[2] == 0xff333333, "got %08x (%s)\n", colors
[2], name
);
1674 ok(colors
[3] == 0xff444444, "got %08x (%s)\n", colors
[3], name
);
1675 ok(colors
[4] == 0xff555555, "got %08x (%s)\n", colors
[4], name
);
1676 ok(colors
[5] == 0xff000000, "got %08x (%s)\n", colors
[5], name
);
1680 ok(count
== 2, "expected 2, got %u (%s)\n", count
, name
);
1682 ok(colors
[0] == 0xff111111, "got %08x (%s)\n", colors
[0], name
);
1683 ok(colors
[1] == 0xff222222, "got %08x (%s)\n", colors
[1], name
);
1688 ok(count
== 2, "expected 2, got %u (%s)\n", count
, name
);
1690 ok(colors
[0] == 0xff111111, "got %08x\n", colors
[0]);
1691 ok(colors
[1] == 0xff222222, "got %08x\n", colors
[1]);
1695 IWICBitmapFrameDecode_Release(framedecode
);
1701 IWICPalette_Release(frame_palette
);
1702 IWICBitmapDecoder_Release(decoder
);
1705 IStream_Release(stream
);
1708 IWICBitmapEncoder_Release(encoder
);
1712 static void test_multi_encoder(const struct bitmap_data
**srcs
, const CLSID
* clsid_encoder
,
1713 const struct bitmap_data
**dsts
, const CLSID
*clsid_decoder
, WICRect
*rc
,
1714 const struct setting
*settings
, const char *name
, IWICPalette
*palette
)
1716 test_multi_encoder_impl(srcs
, clsid_encoder
, dsts
, clsid_decoder
, rc
, settings
, name
, palette
, TRUE
);
1717 test_multi_encoder_impl(srcs
, clsid_encoder
, dsts
, clsid_decoder
, rc
, settings
, name
, palette
, FALSE
);
1720 static void test_encoder(const struct bitmap_data
*src
, const CLSID
* clsid_encoder
,
1721 const struct bitmap_data
*dst
, const CLSID
*clsid_decoder
, const char *name
)
1723 const struct bitmap_data
*srcs
[2];
1724 const struct bitmap_data
*dsts
[2];
1725 WICColor colors
[256];
1726 IWICPalette
*palette
;
1729 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
1730 ok(hr
== S_OK
, "CreatePalette error %#lx\n", hr
);
1732 memset(colors
, 0, sizeof(colors
));
1733 colors
[0] = 0x11111111;
1734 colors
[1] = 0x22222222;
1735 colors
[2] = 0x33333333;
1736 colors
[3] = 0x44444444;
1737 colors
[4] = 0x55555555;
1738 /* TIFF decoder fails to decode a 8bpp frame if palette has less than 256 colors */
1739 hr
= IWICPalette_InitializeCustom(palette
, colors
, 256);
1740 ok(hr
== S_OK
, "InitializeCustom error %#lx\n", hr
);
1747 test_multi_encoder(srcs
, clsid_encoder
, dsts
, clsid_decoder
, NULL
, NULL
, name
, palette
);
1749 IWICPalette_Release(palette
);
1752 static void test_encoder_rects(void)
1754 const struct bitmap_data
*srcs
[2];
1755 const struct bitmap_data
*dsts
[2];
1758 srcs
[0] = &testdata_24bppBGR
;
1760 dsts
[0] = &testdata_24bppBGR
;
1768 test_multi_encoder(srcs
, &CLSID_WICTiffEncoder
, dsts
, &CLSID_WICTiffDecoder
, &rc
, NULL
, "test_encoder_rects full", NULL
);
1771 test_multi_encoder(srcs
, &CLSID_WICTiffEncoder
, dsts
, &CLSID_WICTiffDecoder
, &rc
, NULL
, "test_encoder_rects width=0", NULL
);
1774 test_multi_encoder(srcs
, &CLSID_WICTiffEncoder
, dsts
, &CLSID_WICTiffDecoder
, &rc
, NULL
, "test_encoder_rects width=-1", NULL
);
1778 test_multi_encoder(srcs
, &CLSID_WICTiffEncoder
, dsts
, &CLSID_WICTiffDecoder
, &rc
, NULL
, "test_encoder_rects height=0", NULL
);
1781 test_multi_encoder(srcs
, &CLSID_WICTiffEncoder
, dsts
, &CLSID_WICTiffDecoder
, &rc
, NULL
, "test_encoder_rects height=-1", NULL
);
1784 static const struct bitmap_data
*multiple_frames
[3] = {
1789 static const struct bitmap_data
*single_frame
[2] = {
1793 static const struct setting png_interlace_settings
[] = {
1794 {wszInterlaceOption
, PROPBAG2_TYPE_DATA
, VT_BOOL
, (void*)VARIANT_TRUE
},
1798 static void test_converter_8bppIndexed(void)
1801 BitmapTestSrc
*src_obj
;
1802 IWICFormatConverter
*converter
;
1803 IWICPalette
*palette
;
1805 BYTE buf
[32 * 2 * 3]; /* enough to hold 32x2 24bppBGR data */
1807 CreateTestBitmap(&testdata_24bppBGR
, &src_obj
);
1809 hr
= IWICImagingFactory_CreatePalette(factory
, &palette
);
1810 ok(hr
== S_OK
, "CreatePalette error %#lx\n", hr
);
1812 hr
= IWICPalette_GetColorCount(palette
, &count
);
1813 ok(hr
== S_OK
, "GetColorCount error %#lx\n", hr
);
1814 ok(count
== 0, "expected 0, got %u\n", count
);
1816 /* NULL palette + Custom type */
1817 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1818 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1819 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1820 &GUID_WICPixelFormat24bppBGR
, WICBitmapDitherTypeNone
,
1821 NULL
, 0.0, WICBitmapPaletteTypeCustom
);
1822 ok(hr
== S_OK
, "Initialize error %#lx\n", hr
);
1823 hr
= IWICFormatConverter_CopyPalette(converter
, palette
);
1824 ok(hr
== 0xdeadbeef, "unexpected error %#lx\n", hr
);
1825 hr
= IWICFormatConverter_CopyPixels(converter
, NULL
, 32 * 3, sizeof(buf
), buf
);
1826 ok(hr
== S_OK
, "CopyPixels error %#lx\n", hr
);
1827 IWICFormatConverter_Release(converter
);
1829 /* NULL palette + Custom type */
1830 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1831 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1832 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1833 &GUID_WICPixelFormat8bppIndexed
, WICBitmapDitherTypeNone
,
1834 NULL
, 0.0, WICBitmapPaletteTypeCustom
);
1835 ok(hr
== E_INVALIDARG
, "unexpected error %#lx\n", hr
);
1836 hr
= IWICFormatConverter_CopyPalette(converter
, palette
);
1837 ok(hr
== WINCODEC_ERR_WRONGSTATE
, "unexpected error %#lx\n", hr
);
1838 hr
= IWICFormatConverter_CopyPixels(converter
, NULL
, 32, sizeof(buf
), buf
);
1839 ok(hr
== WINCODEC_ERR_WRONGSTATE
, "unexpected error %#lx\n", hr
);
1840 IWICFormatConverter_Release(converter
);
1842 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1843 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1844 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1845 &GUID_WICPixelFormat4bppIndexed
, WICBitmapDitherTypeNone
,
1846 NULL
, 0.0, WICBitmapPaletteTypeCustom
);
1847 ok(hr
== E_INVALIDARG
, "unexpected error %#lx\n", hr
);
1848 IWICFormatConverter_Release(converter
);
1850 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1851 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1852 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1853 &GUID_WICPixelFormat2bppIndexed
, WICBitmapDitherTypeNone
,
1854 NULL
, 0.0, WICBitmapPaletteTypeCustom
);
1855 ok(hr
== E_INVALIDARG
, "unexpected error %#lx\n", hr
);
1856 IWICFormatConverter_Release(converter
);
1858 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1859 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1860 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1861 &GUID_WICPixelFormat1bppIndexed
, WICBitmapDitherTypeNone
,
1862 NULL
, 0.0, WICBitmapPaletteTypeCustom
);
1863 ok(hr
== E_INVALIDARG
, "unexpected error %#lx\n", hr
);
1864 IWICFormatConverter_Release(converter
);
1866 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1867 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1868 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1869 &GUID_WICPixelFormat1bppIndexed
, WICBitmapDitherTypeNone
,
1870 NULL
, 0.0, WICBitmapPaletteTypeMedianCut
);
1871 todo_wine
ok(hr
== S_OK
, "unexpected error %#lx\n", hr
);
1872 IWICFormatConverter_Release(converter
);
1874 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1875 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1876 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1877 &GUID_WICPixelFormat1bppIndexed
, WICBitmapDitherTypeNone
,
1878 NULL
, 0.0, WICBitmapPaletteTypeFixedBW
);
1879 todo_wine
ok(hr
== S_OK
, "unexpected error %#lx\n", hr
);
1880 IWICFormatConverter_Release(converter
);
1882 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1883 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1884 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1885 &GUID_WICPixelFormat1bppIndexed
, WICBitmapDitherTypeNone
,
1886 NULL
, 0.0, WICBitmapPaletteTypeFixedHalftone8
);
1887 todo_wine
ok(hr
== E_INVALIDARG
, "unexpected error %#lx\n", hr
);
1888 IWICFormatConverter_Release(converter
);
1890 /* empty palette + Custom type */
1891 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1892 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1893 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1894 &GUID_WICPixelFormat8bppIndexed
, WICBitmapDitherTypeNone
,
1895 palette
, 0.0, WICBitmapPaletteTypeCustom
);
1896 ok(hr
== S_OK
, "Initialize error %#lx\n", hr
);
1897 hr
= IWICFormatConverter_CopyPalette(converter
, palette
);
1898 ok(hr
== S_OK
, "CopyPalette error %#lx\n", hr
);
1900 hr
= IWICPalette_GetColorCount(palette
, &count
);
1901 ok(hr
== S_OK
, "GetColorCount error %#lx\n", hr
);
1902 ok(count
== 0, "expected 0, got %u\n", count
);
1903 memset(buf
, 0xaa, sizeof(buf
));
1904 hr
= IWICFormatConverter_CopyPixels(converter
, NULL
, 32, sizeof(buf
), buf
);
1905 ok(hr
== S_OK
, "CopyPixels error %#lx\n", hr
);
1907 for (i
= 0; i
< 32 * 2; i
++)
1908 if (buf
[i
] != 0) count
++;
1909 ok(count
== 0, "expected 0\n");
1910 IWICFormatConverter_Release(converter
);
1912 /* NULL palette + Predefined type */
1913 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1914 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1915 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1916 &GUID_WICPixelFormat8bppIndexed
, WICBitmapDitherTypeNone
,
1917 NULL
, 0.0, WICBitmapPaletteTypeFixedGray16
);
1918 ok(hr
== S_OK
, "Initialize error %#lx\n", hr
);
1919 hr
= IWICFormatConverter_CopyPalette(converter
, palette
);
1920 ok(hr
== S_OK
, "CopyPalette error %#lx\n", hr
);
1922 hr
= IWICPalette_GetColorCount(palette
, &count
);
1923 ok(hr
== S_OK
, "GetColorCount error %#lx\n", hr
);
1924 ok(count
== 16, "expected 16, got %u\n", count
);
1925 hr
= IWICFormatConverter_CopyPixels(converter
, NULL
, 32, sizeof(buf
), buf
);
1926 ok(hr
== S_OK
, "CopyPixels error %#lx\n", hr
);
1928 for (i
= 0; i
< 32 * 2; i
++)
1929 if (buf
[i
] != 0) count
++;
1930 ok(count
!= 0, "expected != 0\n");
1931 IWICFormatConverter_Release(converter
);
1933 /* not empty palette + Predefined type */
1934 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1935 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1936 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1937 &GUID_WICPixelFormat8bppIndexed
, WICBitmapDitherTypeNone
,
1938 palette
, 0.0, WICBitmapPaletteTypeFixedHalftone64
);
1939 ok(hr
== S_OK
, "Initialize error %#lx\n", hr
);
1940 hr
= IWICFormatConverter_CopyPalette(converter
, palette
);
1941 ok(hr
== S_OK
, "CopyPalette error %#lx\n", hr
);
1943 hr
= IWICPalette_GetColorCount(palette
, &count
);
1944 ok(hr
== S_OK
, "GetColorCount error %#lx\n", hr
);
1945 ok(count
== 16, "expected 16, got %u\n", count
);
1946 hr
= IWICFormatConverter_CopyPixels(converter
, NULL
, 32, sizeof(buf
), buf
);
1947 ok(hr
== S_OK
, "CopyPixels error %#lx\n", hr
);
1949 for (i
= 0; i
< 32 * 2; i
++)
1950 if (buf
[i
] != 0) count
++;
1951 ok(count
!= 0, "expected != 0\n");
1952 IWICFormatConverter_Release(converter
);
1954 /* not empty palette + MedianCut type */
1955 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1956 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1957 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1958 &GUID_WICPixelFormat8bppIndexed
, WICBitmapDitherTypeNone
,
1959 palette
, 0.0, WICBitmapPaletteTypeMedianCut
);
1960 ok(hr
== S_OK
, "Initialize error %#lx\n", hr
);
1961 hr
= IWICFormatConverter_CopyPalette(converter
, palette
);
1962 ok(hr
== S_OK
, "CopyPalette error %#lx\n", hr
);
1964 hr
= IWICPalette_GetColorCount(palette
, &count
);
1965 ok(hr
== S_OK
, "GetColorCount error %#lx\n", hr
);
1966 ok(count
== 16, "expected 16, got %u\n", count
);
1967 hr
= IWICFormatConverter_CopyPixels(converter
, NULL
, 32, sizeof(buf
), buf
);
1968 ok(hr
== S_OK
, "CopyPixels error %#lx\n", hr
);
1970 for (i
= 0; i
< 32 * 2; i
++)
1971 if (buf
[i
] != 0) count
++;
1972 ok(count
!= 0, "expected != 0\n");
1973 IWICFormatConverter_Release(converter
);
1975 /* NULL palette + MedianCut type */
1976 hr
= IWICImagingFactory_CreateFormatConverter(factory
, &converter
);
1977 ok(hr
== S_OK
, "CreateFormatConverter error %#lx\n", hr
);
1978 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
1979 &GUID_WICPixelFormat8bppIndexed
, WICBitmapDitherTypeNone
,
1980 NULL
, 0.0, WICBitmapPaletteTypeMedianCut
);
1981 ok(hr
== S_OK
|| broken(hr
== E_INVALIDARG
) /* XP */, "Initialize error %#lx\n", hr
);
1984 hr
= IWICFormatConverter_CopyPalette(converter
, palette
);
1985 ok(hr
== S_OK
, "CopyPalette error %#lx\n", hr
);
1987 hr
= IWICPalette_GetColorCount(palette
, &count
);
1988 ok(hr
== S_OK
, "GetColorCount error %#lx\n", hr
);
1989 ok(count
== 8, "expected 8, got %u\n", count
);
1990 hr
= IWICFormatConverter_CopyPixels(converter
, NULL
, 32, sizeof(buf
), buf
);
1991 ok(hr
== S_OK
, "CopyPixels error %#lx\n", hr
);
1993 for (i
= 0; i
< 32 * 2; i
++)
1994 if (buf
[i
] != 0) count
++;
1995 ok(count
!= 0, "expected != 0\n");
1997 IWICFormatConverter_Release(converter
);
1999 IWICPalette_Release(palette
);
2000 DeleteTestBitmap(src_obj
);
2003 START_TEST(converter
)
2007 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
2009 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
2010 &IID_IWICImagingFactory
, (void **)&factory
);
2011 ok(hr
== S_OK
, "failed to create factory: %#lx\n", hr
);
2013 test_conversion(&testdata_24bppRGB
, &testdata_1bppIndexed
, "24bppRGB -> 1bppIndexed", TRUE
);
2014 test_conversion(&testdata_24bppRGB
, &testdata_2bppIndexed
, "24bppRGB -> 2bppIndexed", TRUE
);
2015 test_conversion(&testdata_24bppRGB
, &testdata_4bppIndexed
, "24bppRGB -> 4bppIndexed", TRUE
);
2016 test_conversion(&testdata_24bppRGB
, &testdata_8bppIndexed
, "24bppRGB -> 8bppIndexed", FALSE
);
2018 test_conversion(&testdata_BlackWhite
, &testdata_8bppIndexed_BW
, "BlackWhite -> 8bppIndexed", TRUE
);
2019 test_conversion(&testdata_1bppIndexed
, &testdata_8bppIndexed_BW
, "1bppIndexed -> 8bppIndexed", TRUE
);
2020 test_conversion(&testdata_2bppIndexed
, &testdata_8bppIndexed_4colors
, "2bppIndexed -> 8bppIndexed", TRUE
);
2021 test_conversion(&testdata_4bppIndexed
, &testdata_8bppIndexed
, "4bppIndexed -> 8bppIndexed", TRUE
);
2023 test_conversion(&testdata_32bppBGRA
, &testdata_32bppBGR
, "BGRA -> BGR", FALSE
);
2024 test_conversion(&testdata_32bppBGR
, &testdata_32bppBGRA
, "BGR -> BGRA", FALSE
);
2025 test_conversion(&testdata_32bppBGRA
, &testdata_32bppBGRA
, "BGRA -> BGRA", FALSE
);
2026 test_conversion(&testdata_32bppBGRA80
, &testdata_32bppPBGRA
, "BGRA -> PBGRA", FALSE
);
2028 test_conversion(&testdata_32bppRGBA
, &testdata_32bppRGB
, "RGBA -> RGB", FALSE
);
2029 test_conversion(&testdata_32bppRGB
, &testdata_32bppRGBA
, "RGB -> RGBA", FALSE
);
2030 test_conversion(&testdata_32bppRGBA
, &testdata_32bppRGBA
, "RGBA -> RGBA", FALSE
);
2031 test_conversion(&testdata_32bppRGBA80
, &testdata_32bppPRGBA
, "RGBA -> PRGBA", FALSE
);
2033 test_conversion(&testdata_24bppBGR
, &testdata_24bppBGR
, "24bppBGR -> 24bppBGR", FALSE
);
2034 test_conversion(&testdata_24bppBGR
, &testdata_24bppRGB
, "24bppBGR -> 24bppRGB", FALSE
);
2036 test_conversion(&testdata_24bppRGB
, &testdata_24bppRGB
, "24bppRGB -> 24bppRGB", FALSE
);
2037 test_conversion(&testdata_24bppRGB
, &testdata_24bppBGR
, "24bppRGB -> 24bppBGR", FALSE
);
2039 test_conversion(&testdata_32bppBGR
, &testdata_24bppRGB
, "32bppBGR -> 24bppRGB", FALSE
);
2040 test_conversion(&testdata_24bppRGB
, &testdata_32bppBGR
, "24bppRGB -> 32bppBGR", FALSE
);
2041 test_conversion(&testdata_32bppBGRA
, &testdata_24bppRGB
, "32bppBGRA -> 24bppRGB", FALSE
);
2042 test_conversion(&testdata_32bppRGBA
, &testdata_24bppBGR
, "32bppRGBA -> 24bppBGR", FALSE
);
2044 test_conversion(&testdata_32bppRGBA
, &testdata_32bppBGRA
, "32bppRGBA -> 32bppBGRA", FALSE
);
2045 test_conversion(&testdata_32bppBGRA
, &testdata_32bppRGBA
, "32bppBGRA -> 32bppRGBA", FALSE
);
2047 test_conversion(&testdata_64bppRGBA
, &testdata_32bppRGBA
, "64bppRGBA -> 32bppRGBA", FALSE
);
2048 test_conversion(&testdata_64bppRGBA
, &testdata_32bppRGB
, "64bppRGBA -> 32bppRGB", FALSE
);
2050 test_conversion(&testdata_24bppRGB
, &testdata_32bppGrayFloat
, "24bppRGB -> 32bppGrayFloat", FALSE
);
2051 test_conversion(&testdata_32bppBGR
, &testdata_32bppGrayFloat
, "32bppBGR -> 32bppGrayFloat", FALSE
);
2053 test_conversion(&testdata_24bppBGR
, &testdata_8bppGray
, "24bppBGR -> 8bppGray", FALSE
);
2054 test_conversion(&testdata_32bppBGR
, &testdata_8bppGray
, "32bppBGR -> 8bppGray", FALSE
);
2055 test_conversion(&testdata_32bppGrayFloat
, &testdata_24bppBGR_gray
, "32bppGrayFloat -> 24bppBGR gray", FALSE
);
2056 test_conversion(&testdata_32bppGrayFloat
, &testdata_8bppGray
, "32bppGrayFloat -> 8bppGray", FALSE
);
2058 test_invalid_conversion();
2059 test_default_converter();
2060 test_converter_4bppGray();
2061 test_converter_8bppGray();
2062 test_converter_8bppIndexed();
2064 test_encoder(&testdata_8bppIndexed
, &CLSID_WICGifEncoder
,
2065 &testdata_8bppIndexed
, &CLSID_WICGifDecoder
, "GIF encoder 8bppIndexed");
2067 test_encoder(&testdata_BlackWhite
, &CLSID_WICPngEncoder
,
2068 &testdata_BlackWhite
, &CLSID_WICPngDecoder
, "PNG encoder BlackWhite");
2069 test_encoder(&testdata_1bppIndexed
, &CLSID_WICPngEncoder
,
2070 &testdata_1bppIndexed
, &CLSID_WICPngDecoder
, "PNG encoder 1bppIndexed");
2071 test_encoder(&testdata_2bppIndexed
, &CLSID_WICPngEncoder
,
2072 &testdata_2bppIndexed
, &CLSID_WICPngDecoder
, "PNG encoder 2bppIndexed");
2073 test_encoder(&testdata_4bppIndexed
, &CLSID_WICPngEncoder
,
2074 &testdata_4bppIndexed
, &CLSID_WICPngDecoder
, "PNG encoder 4bppIndexed");
2075 test_encoder(&testdata_8bppIndexed
, &CLSID_WICPngEncoder
,
2076 &testdata_8bppIndexed
, &CLSID_WICPngDecoder
, "PNG encoder 8bppIndexed");
2077 test_encoder(&testdata_24bppBGR
, &CLSID_WICPngEncoder
,
2078 &testdata_24bppBGR
, &CLSID_WICPngDecoder
, "PNG encoder 24bppBGR");
2079 if (!strcmp(winetest_platform
, "windows")) /* FIXME: enable once implemented in Wine */
2081 test_encoder(&testdata_32bppBGR
, &CLSID_WICPngEncoder
,
2082 &testdata_24bppBGR
, &CLSID_WICPngDecoder
, "PNG encoder 32bppBGR");
2085 test_encoder(&testdata_BlackWhite
, &CLSID_WICBmpEncoder
,
2086 &testdata_1bppIndexed
, &CLSID_WICBmpDecoder
, "BMP encoder BlackWhite");
2087 test_encoder(&testdata_1bppIndexed
, &CLSID_WICBmpEncoder
,
2088 &testdata_1bppIndexed
, &CLSID_WICBmpDecoder
, "BMP encoder 1bppIndexed");
2089 test_encoder(&testdata_2bppIndexed
, &CLSID_WICBmpEncoder
,
2090 &testdata_4bppIndexed
, &CLSID_WICBmpDecoder
, "BMP encoder 2bppIndexed");
2091 test_encoder(&testdata_4bppIndexed
, &CLSID_WICBmpEncoder
,
2092 &testdata_4bppIndexed
, &CLSID_WICBmpDecoder
, "BMP encoder 4bppIndexed");
2093 test_encoder(&testdata_8bppIndexed
, &CLSID_WICBmpEncoder
,
2094 &testdata_8bppIndexed
, &CLSID_WICBmpDecoder
, "BMP encoder 8bppIndexed");
2095 test_encoder(&testdata_32bppBGR
, &CLSID_WICBmpEncoder
,
2096 &testdata_32bppBGR
, &CLSID_WICBmpDecoder
, "BMP encoder 32bppBGR");
2098 test_encoder(&testdata_BlackWhite
, &CLSID_WICTiffEncoder
,
2099 &testdata_BlackWhite
, &CLSID_WICTiffDecoder
, "TIFF encoder BlackWhite");
2100 test_encoder(&testdata_1bppIndexed
, &CLSID_WICTiffEncoder
,
2101 &testdata_1bppIndexed
, &CLSID_WICTiffDecoder
, "TIFF encoder 1bppIndexed");
2102 test_encoder(&testdata_2bppIndexed
, &CLSID_WICTiffEncoder
,
2103 &testdata_4bppIndexed
, &CLSID_WICTiffDecoder
, "TIFF encoder 2bppIndexed");
2104 test_encoder(&testdata_4bppIndexed
, &CLSID_WICTiffEncoder
,
2105 &testdata_4bppIndexed
, &CLSID_WICTiffDecoder
, "TIFF encoder 4bppIndexed");
2106 test_encoder(&testdata_8bppIndexed
, &CLSID_WICTiffEncoder
,
2107 &testdata_8bppIndexed
, &CLSID_WICTiffDecoder
, "TIFF encoder 8bppIndexed");
2108 test_encoder(&testdata_24bppBGR
, &CLSID_WICTiffEncoder
,
2109 &testdata_24bppBGR
, &CLSID_WICTiffDecoder
, "TIFF encoder 24bppBGR");
2111 test_encoder(&testdata_24bppBGR
, &CLSID_WICJpegEncoder
,
2112 &testdata_24bppBGR
, NULL
, "JPEG encoder 24bppBGR");
2114 test_multi_encoder(multiple_frames
, &CLSID_WICTiffEncoder
,
2115 multiple_frames
, &CLSID_WICTiffDecoder
, NULL
, NULL
, "TIFF encoder multi-frame", NULL
);
2117 test_encoder_rects();
2119 test_multi_encoder(single_frame
, &CLSID_WICPngEncoder
,
2120 single_frame
, &CLSID_WICPngDecoder
, NULL
, png_interlace_settings
, "PNG encoder interlaced", NULL
);
2122 IWICImagingFactory_Release(factory
);