2 * Copyright 2009 Vincent Povirk
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_NO_STATUS
24 #define COM_NO_WINDOWS_H
33 #include <wine/test.h>
35 typedef struct bitmap_data
{
36 const WICPixelFormatGUID
*format
;
45 typedef struct BitmapTestSrc
{
46 IWICBitmapSource IWICBitmapSource_iface
;
48 const bitmap_data
*data
;
51 static inline BitmapTestSrc
*impl_from_IWICBitmapSource(IWICBitmapSource
*iface
)
53 return CONTAINING_RECORD(iface
, BitmapTestSrc
, IWICBitmapSource_iface
);
56 static HRESULT WINAPI
BitmapTestSrc_QueryInterface(IWICBitmapSource
*iface
, REFIID iid
,
59 if (!ppv
) return E_INVALIDARG
;
61 if (IsEqualIID(&IID_IUnknown
, iid
) ||
62 IsEqualIID(&IID_IWICBitmapSource
, iid
))
67 IUnknown_AddRef((IUnknown
*)*ppv
);
71 static ULONG WINAPI
BitmapTestSrc_AddRef(IWICBitmapSource
*iface
)
73 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
74 ULONG ref
= InterlockedIncrement(&This
->ref
);
78 static ULONG WINAPI
BitmapTestSrc_Release(IWICBitmapSource
*iface
)
80 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
81 ULONG ref
= InterlockedDecrement(&This
->ref
);
85 static HRESULT WINAPI
BitmapTestSrc_GetSize(IWICBitmapSource
*iface
,
86 UINT
*puiWidth
, UINT
*puiHeight
)
88 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
89 *puiWidth
= This
->data
->width
;
90 *puiHeight
= This
->data
->height
;
94 static HRESULT WINAPI
BitmapTestSrc_GetPixelFormat(IWICBitmapSource
*iface
,
95 WICPixelFormatGUID
*pPixelFormat
)
97 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
98 memcpy(pPixelFormat
, This
->data
->format
, sizeof(GUID
));
102 static HRESULT WINAPI
BitmapTestSrc_GetResolution(IWICBitmapSource
*iface
,
103 double *pDpiX
, double *pDpiY
)
105 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
106 *pDpiX
= This
->data
->xres
;
107 *pDpiY
= This
->data
->yres
;
111 static HRESULT WINAPI
BitmapTestSrc_CopyPalette(IWICBitmapSource
*iface
,
112 IWICPalette
*pIPalette
)
117 static HRESULT WINAPI
BitmapTestSrc_CopyPixels(IWICBitmapSource
*iface
,
118 const WICRect
*prc
, UINT cbStride
, UINT cbBufferSize
, BYTE
*pbBuffer
)
120 BitmapTestSrc
*This
= impl_from_IWICBitmapSource(iface
);
130 rc
.Width
= This
->data
->width
;
131 rc
.Height
= This
->data
->height
;
136 if (prc
->X
< 0 || prc
->Y
< 0 || prc
->X
+prc
->Width
> This
->data
->width
|| prc
->Y
+prc
->Height
> This
->data
->height
)
140 bytesperrow
= ((This
->data
->bpp
* prc
->Width
)+7)/8;
141 srcstride
= ((This
->data
->bpp
* This
->data
->width
)+7)/8;
143 if (cbStride
< bytesperrow
)
146 if ((cbStride
* prc
->Height
) > cbBufferSize
)
149 row_offset
= prc
->X
* This
->data
->bpp
;
151 if (row_offset
% 8 == 0)
157 src
= This
->data
->bits
+ (row_offset
/ 8) + prc
->Y
* srcstride
;
159 for (row
=0; row
< prc
->Height
; row
++)
161 memcpy(dst
, src
, bytesperrow
);
169 ok(0, "bitmap %p was asked to copy pixels not aligned on a byte boundary\n", iface
);
174 static const IWICBitmapSourceVtbl BitmapTestSrc_Vtbl
= {
175 BitmapTestSrc_QueryInterface
,
176 BitmapTestSrc_AddRef
,
177 BitmapTestSrc_Release
,
178 BitmapTestSrc_GetSize
,
179 BitmapTestSrc_GetPixelFormat
,
180 BitmapTestSrc_GetResolution
,
181 BitmapTestSrc_CopyPalette
,
182 BitmapTestSrc_CopyPixels
185 static void CreateTestBitmap(const bitmap_data
*data
, BitmapTestSrc
**This
)
187 *This
= HeapAlloc(GetProcessHeap(), 0, sizeof(**This
));
191 (*This
)->IWICBitmapSource_iface
.lpVtbl
= &BitmapTestSrc_Vtbl
;
193 (*This
)->data
= data
;
197 static void DeleteTestBitmap(BitmapTestSrc
*This
)
199 ok(This
->IWICBitmapSource_iface
.lpVtbl
== &BitmapTestSrc_Vtbl
, "test bitmap %p deleted with incorrect vtable\n", This
);
200 ok(This
->ref
== 1, "test bitmap %p deleted with %i references instead of 1\n", This
, This
->ref
);
201 HeapFree(GetProcessHeap(), 0, This
);
204 static void compare_bitmap_data(const struct bitmap_data
*expect
, IWICBitmapSource
*source
, const char *name
)
206 BYTE
*converted_bits
;
210 UINT stride
, buffersize
;
211 GUID dst_pixelformat
;
214 hr
= IWICBitmapSource_GetSize(source
, &width
, &height
);
215 ok(SUCCEEDED(hr
), "GetSize(%s) failed, hr=%x\n", name
, hr
);
216 ok(width
== expect
->width
, "expecting %u, got %u (%s)\n", expect
->width
, width
, name
);
217 ok(height
== expect
->height
, "expecting %u, got %u (%s)\n", expect
->height
, height
, name
);
219 hr
= IWICBitmapSource_GetResolution(source
, &xres
, &yres
);
220 ok(SUCCEEDED(hr
), "GetResolution(%s) failed, hr=%x\n", name
, hr
);
221 ok(fabs(xres
- expect
->xres
) < 0.02, "expecting %0.2f, got %0.2f (%s)\n", expect
->xres
, xres
, name
);
222 ok(fabs(yres
- expect
->yres
) < 0.02, "expecting %0.2f, got %0.2f (%s)\n", expect
->yres
, yres
, name
);
224 hr
= IWICBitmapSource_GetPixelFormat(source
, &dst_pixelformat
);
225 ok(SUCCEEDED(hr
), "GetPixelFormat(%s) failed, hr=%x\n", name
, hr
);
226 ok(IsEqualGUID(&dst_pixelformat
, expect
->format
), "got unexpected pixel format (%s)\n", name
);
230 prc
.Width
= expect
->width
;
231 prc
.Height
= expect
->height
;
233 stride
= (expect
->bpp
* expect
->width
+ 7) / 8;
234 buffersize
= stride
* expect
->height
;
236 converted_bits
= HeapAlloc(GetProcessHeap(), 0, buffersize
);
237 hr
= IWICBitmapSource_CopyPixels(source
, &prc
, stride
, buffersize
, converted_bits
);
238 ok(SUCCEEDED(hr
), "CopyPixels(%s) failed, hr=%x\n", name
, hr
);
239 if (IsEqualGUID(expect
->format
, &GUID_WICPixelFormat32bppBGR
))
241 /* ignore the padding byte when comparing data */
244 const DWORD
*a
=(const DWORD
*)expect
->bits
, *b
=(const DWORD
*)converted_bits
;
245 for (i
=0; i
<(buffersize
/4); i
++)
246 if ((a
[i
]&0xffffff) != (b
[i
]&0xffffff))
251 ok(equal
, "unexpected pixel data (%s)\n", name
);
254 ok(memcmp(expect
->bits
, converted_bits
, buffersize
) == 0, "unexpected pixel data (%s)\n", name
);
256 /* Test with NULL rectangle - should copy the whole bitmap */
257 hr
= IWICBitmapSource_CopyPixels(source
, NULL
, stride
, buffersize
, converted_bits
);
258 ok(SUCCEEDED(hr
), "CopyPixels(%s,rc=NULL) failed, hr=%x\n", name
, hr
);
259 if (IsEqualGUID(expect
->format
, &GUID_WICPixelFormat32bppBGR
))
261 /* ignore the padding byte when comparing data */
264 const DWORD
*a
=(const DWORD
*)expect
->bits
, *b
=(const DWORD
*)converted_bits
;
265 for (i
=0; i
<(buffersize
/4); i
++)
266 if ((a
[i
]&0xffffff) != (b
[i
]&0xffffff))
271 ok(equal
, "unexpected pixel data with rc=NULL (%s)\n", name
);
274 ok(memcmp(expect
->bits
, converted_bits
, buffersize
) == 0, "unexpected pixel data with rc=NULL (%s)\n", name
);
276 HeapFree(GetProcessHeap(), 0, converted_bits
);
279 static const BYTE bits_24bppBGR
[] = {
280 255,0,0, 0,255,0, 0,0,255, 0,0,0,
281 0,255,255, 255,0,255, 255,255,0, 255,255,255};
282 static const struct bitmap_data testdata_24bppBGR
= {
283 &GUID_WICPixelFormat24bppBGR
, 24, bits_24bppBGR
, 4, 2, 96.0, 96.0};
285 static const BYTE bits_24bppRGB
[] = {
286 0,0,255, 0,255,0, 255,0,0, 0,0,0,
287 255,255,0, 255,0,255, 0,255,255, 255,255,255};
288 static const struct bitmap_data testdata_24bppRGB
= {
289 &GUID_WICPixelFormat24bppRGB
, 24, bits_24bppRGB
, 4, 2, 96.0, 96.0};
291 static const BYTE bits_32bppBGR
[] = {
292 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
293 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80};
294 static const struct bitmap_data testdata_32bppBGR
= {
295 &GUID_WICPixelFormat32bppBGR
, 32, bits_32bppBGR
, 4, 2, 96.0, 96.0};
297 static const BYTE bits_32bppBGRA
[] = {
298 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
299 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255};
300 static const struct bitmap_data testdata_32bppBGRA
= {
301 &GUID_WICPixelFormat32bppBGRA
, 32, bits_32bppBGRA
, 4, 2, 96.0, 96.0};
303 static void test_conversion(const struct bitmap_data
*src
, const struct bitmap_data
*dst
, const char *name
, BOOL todo
)
305 BitmapTestSrc
*src_obj
;
306 IWICBitmapSource
*dst_bitmap
;
309 CreateTestBitmap(src
, &src_obj
);
311 hr
= WICConvertBitmapSource(dst
->format
, &src_obj
->IWICBitmapSource_iface
, &dst_bitmap
);
313 todo_wine
ok(SUCCEEDED(hr
), "WICConvertBitmapSource(%s) failed, hr=%x\n", name
, hr
);
315 ok(SUCCEEDED(hr
), "WICConvertBitmapSource(%s) failed, hr=%x\n", name
, hr
);
319 compare_bitmap_data(dst
, dst_bitmap
, name
);
321 IWICBitmapSource_Release(dst_bitmap
);
324 DeleteTestBitmap(src_obj
);
327 static void test_invalid_conversion(void)
329 BitmapTestSrc
*src_obj
;
330 IWICBitmapSource
*dst_bitmap
;
333 CreateTestBitmap(&testdata_32bppBGRA
, &src_obj
);
335 /* convert to a non-pixel-format GUID */
336 hr
= WICConvertBitmapSource(&GUID_VendorMicrosoft
, &src_obj
->IWICBitmapSource_iface
, &dst_bitmap
);
337 ok(hr
== WINCODEC_ERR_COMPONENTNOTFOUND
, "WICConvertBitmapSource returned %x\n", hr
);
339 DeleteTestBitmap(src_obj
);
342 static void test_default_converter(void)
344 BitmapTestSrc
*src_obj
;
345 IWICFormatConverter
*converter
;
349 CreateTestBitmap(&testdata_32bppBGRA
, &src_obj
);
351 hr
= CoCreateInstance(&CLSID_WICDefaultFormatConverter
, NULL
, CLSCTX_INPROC_SERVER
,
352 &IID_IWICFormatConverter
, (void**)&converter
);
353 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
356 hr
= IWICFormatConverter_CanConvert(converter
, &GUID_WICPixelFormat32bppBGRA
,
357 &GUID_WICPixelFormat32bppBGR
, &can_convert
);
358 ok(SUCCEEDED(hr
), "CanConvert returned %x\n", hr
);
359 ok(can_convert
, "expected TRUE, got %i\n", can_convert
);
361 hr
= IWICFormatConverter_Initialize(converter
, &src_obj
->IWICBitmapSource_iface
,
362 &GUID_WICPixelFormat32bppBGR
, WICBitmapDitherTypeNone
, NULL
, 0.0,
363 WICBitmapPaletteTypeCustom
);
364 ok(SUCCEEDED(hr
), "Initialize returned %x\n", hr
);
367 compare_bitmap_data(&testdata_32bppBGR
, (IWICBitmapSource
*)converter
, "default converter");
369 IWICFormatConverter_Release(converter
);
372 DeleteTestBitmap(src_obj
);
375 typedef struct property_opt_test_data
379 VARTYPE initial_var_type
;
382 } property_opt_test_data
;
384 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};
385 static const WCHAR wszCompressionQuality
[] = {'C','o','m','p','r','e','s','s','i','o','n','Q','u','a','l','i','t','y',0};
387 static const struct property_opt_test_data testdata_tiff_props
[] = {
388 { wszTiffCompressionMethod
, VT_UI1
, VT_UI1
, WICTiffCompressionDontCare
},
389 { wszCompressionQuality
, VT_R4
, VT_EMPTY
},
393 static int find_property_index(const WCHAR
* name
, PROPBAG2
* all_props
, int all_prop_cnt
)
396 for (i
=0; i
< all_prop_cnt
; i
++)
398 if (lstrcmpW(name
, all_props
[i
].pstrName
) == 0)
404 static void test_specific_encoder_properties(IPropertyBag2
*options
, const property_opt_test_data
* data
, PROPBAG2
* all_props
, int all_prop_cnt
)
409 HRESULT phrError
= S_OK
;
413 int idx
= find_property_index(data
[i
].name
, all_props
, all_prop_cnt
);
415 pb
.pstrName
= (LPOLESTR
)data
[i
].name
;
417 hr
= IPropertyBag2_Read(options
, 1, &pb
, NULL
, &pvarValue
, &phrError
);
419 ok(idx
>= 0, "Property %s not in output of GetPropertyInfo\n",
420 wine_dbgstr_w(data
[i
].name
));
423 ok(all_props
[idx
].vt
== data
[i
].var_type
, "Property %s has unexpected vt type, vt=%i\n",
424 wine_dbgstr_w(data
[i
].name
), all_props
[idx
].vt
);
425 ok(all_props
[idx
].dwType
== PROPBAG2_TYPE_DATA
, "Property %s has unexpected dw type, vt=%i\n",
426 wine_dbgstr_w(data
[i
].name
), all_props
[idx
].dwType
);
427 ok(all_props
[idx
].cfType
== 0, "Property %s has unexpected cf type, vt=%i\n",
428 wine_dbgstr_w(data
[i
].name
), all_props
[idx
].cfType
);
431 ok(SUCCEEDED(hr
), "Reading property %s from bag failed, hr=%x\n",
432 wine_dbgstr_w(data
[i
].name
), hr
);
436 /* On XP the initial type is always VT_EMPTY */
437 ok(V_VT(&pvarValue
) == data
[i
].initial_var_type
|| V_VT(&pvarValue
) == VT_EMPTY
,
438 "Property %s has unexpected initial type, V_VT=%i\n",
439 wine_dbgstr_w(data
[i
].name
), V_VT(&pvarValue
));
441 if(V_VT(&pvarValue
) == data
[i
].initial_var_type
)
443 switch (data
[i
].initial_var_type
)
447 ok(V_UNION(&pvarValue
, bVal
) == data
[i
].i_init_val
, "Property %s has an unexpected initial value, pvarValue=%i\n",
448 wine_dbgstr_w(data
[i
].name
), V_UNION(&pvarValue
, bVal
));
451 ok(V_UNION(&pvarValue
, fltVal
) == data
[i
].f_init_val
, "Property %s has an unexpected initial value, pvarValue=%f\n",
452 wine_dbgstr_w(data
[i
].name
), V_UNION(&pvarValue
, fltVal
));
459 VariantClear(&pvarValue
);
466 static void test_encoder_properties(const CLSID
* clsid_encoder
, IPropertyBag2
*options
)
469 ULONG cProperties
= 0;
470 ULONG cProperties2
= 0;
471 PROPBAG2 all_props
[64] = {{0}}; /* Should be enough for every encoder out there */
474 /* CountProperties */
476 hr
= IPropertyBag2_CountProperties(options
, &cProperties
);
477 ok(SUCCEEDED(hr
), "Reading property count, hr=%x\n", hr
);
480 /* GetPropertyInfo */
482 hr
= IPropertyBag2_GetPropertyInfo(options
, cProperties
, 1, all_props
, &cProperties2
);
483 ok(hr
== WINCODEC_ERR_VALUEOUTOFRANGE
, "IPropertyBag2::GetPropertyInfo - iProperty out of bounce handled wrong, hr=%x\n", hr
);
485 hr
= IPropertyBag2_GetPropertyInfo(options
, 0, cProperties
+1, all_props
, &cProperties2
);
486 ok(hr
== WINCODEC_ERR_VALUEOUTOFRANGE
, "IPropertyBag2::GetPropertyInfo - cProperty out of bounce handled wrong, hr=%x\n", hr
);
488 if (cProperties
== 0) /* GetPropertyInfo can be called for zero items on Windows 8 but not on Windows 7 (wine behaves like Win8) */
490 cProperties2
= cProperties
;
495 hr
= IPropertyBag2_GetPropertyInfo(options
, 0, min(64, cProperties
), all_props
, &cProperties2
);
496 ok(SUCCEEDED(hr
), "Reading infos from property bag failed, hr=%x\n", hr
);
502 ok(cProperties
== cProperties2
, "Missmatch of property count (IPropertyBag2::CountProperties=%i, IPropertyBag2::GetPropertyInfo=%i)\n",
503 (int)cProperties
, (int)cProperties2
);
506 if (clsid_encoder
== &CLSID_WICTiffEncoder
)
507 test_specific_encoder_properties(options
, testdata_tiff_props
, all_props
, cProperties2
);
509 for (i
=0; i
< cProperties2
; i
++)
511 ok(all_props
[i
].pstrName
!= NULL
, "Unset property name in output of IPropertyBag2::GetPropertyInfo\n");
512 CoTaskMemFree(all_props
[i
].pstrName
);
516 static void test_multi_encoder(const struct bitmap_data
**srcs
, const CLSID
* clsid_encoder
,
517 const struct bitmap_data
**dsts
, const CLSID
*clsid_decoder
, const char *name
)
520 IWICBitmapEncoder
*encoder
;
521 BitmapTestSrc
*src_obj
;
524 IWICBitmapFrameEncode
*frameencode
;
525 IPropertyBag2
*options
=NULL
;
526 IWICBitmapDecoder
*decoder
;
527 IWICBitmapFrameDecode
*framedecode
;
528 WICPixelFormatGUID pixelformat
;
531 hr
= CoCreateInstance(clsid_encoder
, NULL
, CLSCTX_INPROC_SERVER
,
532 &IID_IWICBitmapEncoder
, (void**)&encoder
);
533 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
536 hglobal
= GlobalAlloc(GMEM_MOVEABLE
, 0);
537 ok(hglobal
!= NULL
, "GlobalAlloc failed\n");
540 hr
= CreateStreamOnHGlobal(hglobal
, TRUE
, &stream
);
541 ok(SUCCEEDED(hr
), "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
544 if (hglobal
&& SUCCEEDED(hr
))
546 hr
= IWICBitmapEncoder_Initialize(encoder
, stream
, WICBitmapEncoderNoCache
);
547 ok(SUCCEEDED(hr
), "Initialize failed, hr=%x\n", hr
);
550 while (SUCCEEDED(hr
) && srcs
[i
])
552 CreateTestBitmap(srcs
[i
], &src_obj
);
554 hr
= IWICBitmapEncoder_CreateNewFrame(encoder
, &frameencode
, &options
);
555 ok(SUCCEEDED(hr
), "CreateFrame failed, hr=%x\n", hr
);
558 ok(options
!= NULL
, "Encoder initialization has not created an property bag\n");
560 test_encoder_properties(clsid_encoder
, options
);
562 hr
= IWICBitmapFrameEncode_Initialize(frameencode
, options
);
563 ok(SUCCEEDED(hr
), "Initialize failed, hr=%x\n", hr
);
565 memcpy(&pixelformat
, srcs
[i
]->format
, sizeof(GUID
));
566 hr
= IWICBitmapFrameEncode_SetPixelFormat(frameencode
, &pixelformat
);
567 ok(SUCCEEDED(hr
), "SetPixelFormat failed, hr=%x\n", hr
);
568 ok(IsEqualGUID(&pixelformat
, srcs
[i
]->format
), "SetPixelFormat changed the format\n");
570 hr
= IWICBitmapFrameEncode_SetSize(frameencode
, srcs
[i
]->width
, srcs
[i
]->height
);
571 ok(SUCCEEDED(hr
), "SetSize failed, hr=%x\n", hr
);
573 hr
= IWICBitmapFrameEncode_WriteSource(frameencode
, &src_obj
->IWICBitmapSource_iface
, NULL
);
574 ok(SUCCEEDED(hr
), "WriteSource failed, hr=%x\n", hr
);
576 hr
= IWICBitmapFrameEncode_Commit(frameencode
);
577 ok(SUCCEEDED(hr
), "Commit failed, hr=%x\n", hr
);
579 IWICBitmapFrameEncode_Release(frameencode
);
580 IPropertyBag2_Release(options
);
583 DeleteTestBitmap(src_obj
);
590 hr
= IWICBitmapEncoder_Commit(encoder
);
591 ok(SUCCEEDED(hr
), "Commit failed, hr=%x\n", hr
);
596 hr
= CoCreateInstance(clsid_decoder
, NULL
, CLSCTX_INPROC_SERVER
,
597 &IID_IWICBitmapDecoder
, (void**)&decoder
);
598 ok(SUCCEEDED(hr
), "CoCreateInstance failed, hr=%x\n", hr
);
603 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnDemand
);
604 ok(SUCCEEDED(hr
), "Initialize failed, hr=%x\n", hr
);
607 while (SUCCEEDED(hr
) && dsts
[i
])
609 hr
= IWICBitmapDecoder_GetFrame(decoder
, i
, &framedecode
);
610 ok(SUCCEEDED(hr
), "GetFrame failed, hr=%x\n", hr
);
614 compare_bitmap_data(dsts
[i
], (IWICBitmapSource
*)framedecode
, name
);
616 IWICBitmapFrameDecode_Release(framedecode
);
622 IWICBitmapDecoder_Release(decoder
);
625 IStream_Release(stream
);
628 IWICBitmapEncoder_Release(encoder
);
632 static void test_encoder(const struct bitmap_data
*src
, const CLSID
* clsid_encoder
,
633 const struct bitmap_data
*dst
, const CLSID
*clsid_decoder
, const char *name
)
635 const struct bitmap_data
*srcs
[2];
636 const struct bitmap_data
*dsts
[2];
643 test_multi_encoder(srcs
, clsid_encoder
, dsts
, clsid_decoder
, name
);
646 static const struct bitmap_data
*multiple_frames
[3] = {
651 START_TEST(converter
)
653 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
655 test_conversion(&testdata_32bppBGRA
, &testdata_32bppBGR
, "BGRA -> BGR", 0);
656 test_conversion(&testdata_32bppBGR
, &testdata_32bppBGRA
, "BGR -> BGRA", 0);
657 test_conversion(&testdata_32bppBGRA
, &testdata_32bppBGRA
, "BGRA -> BGRA", 0);
659 test_conversion(&testdata_24bppBGR
, &testdata_24bppBGR
, "24bppBGR -> 24bppBGR", 0);
660 test_conversion(&testdata_24bppBGR
, &testdata_24bppRGB
, "24bppBGR -> 24bppRGB", 0);
662 test_conversion(&testdata_24bppRGB
, &testdata_24bppRGB
, "24bppRGB -> 24bppRGB", 0);
663 test_conversion(&testdata_24bppRGB
, &testdata_24bppBGR
, "24bppRGB -> 24bppBGR", 0);
665 test_conversion(&testdata_32bppBGR
, &testdata_24bppRGB
, "32bppBGR -> 24bppRGB", 0);
666 test_conversion(&testdata_24bppRGB
, &testdata_32bppBGR
, "24bppRGB -> 32bppBGR", 0);
668 test_invalid_conversion();
669 test_default_converter();
671 test_encoder(&testdata_32bppBGR
, &CLSID_WICBmpEncoder
,
672 &testdata_32bppBGR
, &CLSID_WICBmpDecoder
, "BMP encoder 32bppBGR");
674 test_encoder(&testdata_24bppBGR
, &CLSID_WICPngEncoder
,
675 &testdata_24bppBGR
, &CLSID_WICPngDecoder
, "PNG encoder 24bppBGR");
677 test_encoder(&testdata_24bppBGR
, &CLSID_WICTiffEncoder
,
678 &testdata_24bppBGR
, &CLSID_WICTiffDecoder
, "TIFF encoder 24bppBGR");
680 test_multi_encoder(multiple_frames
, &CLSID_WICTiffEncoder
,
681 multiple_frames
, &CLSID_WICTiffDecoder
, "TIFF encoder multi-frame");