2 * Copyright 2009 Vincent Povirk for CodeWeavers
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
28 #include "wincodecsdk.h"
29 #include "wine/test.h"
32 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
34 static const char *debugstr_guid(GUID
*guid
)
41 sprintf(buf
, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
42 guid
->Data1
, guid
->Data2
, guid
->Data3
, guid
->Data4
[0],
43 guid
->Data4
[1], guid
->Data4
[2], guid
->Data4
[3], guid
->Data4
[4],
44 guid
->Data4
[5], guid
->Data4
[6], guid
->Data4
[7]);
49 static HRESULT
get_component_info(const GUID
*clsid
, IWICComponentInfo
**result
)
51 IWICImagingFactory
*factory
;
54 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
55 &IID_IWICImagingFactory
, (void**)&factory
);
56 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
57 if (FAILED(hr
)) return hr
;
59 hr
= IWICImagingFactory_CreateComponentInfo(factory
, clsid
, result
);
61 IWICImagingFactory_Release(factory
);
66 static int is_pixelformat(GUID
*format
)
68 IWICComponentInfo
*info
;
70 WICComponentType componenttype
;
72 hr
= get_component_info(format
, &info
);
76 hr
= IWICComponentInfo_GetComponentType(info
, &componenttype
);
78 IWICComponentInfo_Release(info
);
80 return SUCCEEDED(hr
) && componenttype
== WICPixelFormat
;
83 static void test_decoder_info(void)
85 IWICComponentInfo
*info
;
86 IWICBitmapDecoderInfo
*decoder_info
;
90 const WCHAR expected_mimetype
[] = {'i','m','a','g','e','/','b','m','p',0};
92 GUID pixelformats
[20];
93 UINT num_formats
, count
;
96 hr
= get_component_info(&CLSID_WICBmpDecoder
, &info
);
98 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICBitmapDecoderInfo
, (void**)&decoder_info
);
99 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
101 hr
= IWICBitmapDecoderInfo_GetCLSID(decoder_info
, NULL
);
102 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
104 hr
= IWICBitmapDecoderInfo_GetCLSID(decoder_info
, &clsid
);
105 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
106 ok(IsEqualGUID(&CLSID_WICBmpDecoder
, &clsid
), "GetCLSID returned wrong result\n");
108 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 0, NULL
, NULL
);
109 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
111 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 1, NULL
, &len
);
112 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
113 ok(len
== lstrlenW(expected_mimetype
)+1, "GetMimeType returned wrong len %i\n", len
);
115 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, len
, value
, NULL
);
116 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
118 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 0, NULL
, &len
);
119 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
120 ok(len
== lstrlenW(expected_mimetype
)+1, "GetMimeType returned wrong len %i\n", len
);
123 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, len
, value
, &len
);
124 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
125 ok(lstrcmpW(value
, expected_mimetype
) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value
));
126 ok(len
== lstrlenW(expected_mimetype
)+1, "GetMimeType returned wrong len %i\n", len
);
128 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 1, value
, &len
);
129 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetMimeType failed, hr=%x\n", hr
);
130 ok(len
== lstrlenW(expected_mimetype
)+1, "GetMimeType returned wrong len %i\n", len
);
132 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 256, value
, &len
);
133 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
134 ok(lstrcmpW(value
, expected_mimetype
) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value
));
135 ok(len
== lstrlenW(expected_mimetype
)+1, "GetMimeType returned wrong len %i\n", len
);
137 num_formats
= 0xdeadbeef;
138 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, NULL
, &num_formats
);
139 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
140 ok(num_formats
< 20 && num_formats
> 1, "got %d formats\n", num_formats
);
142 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, NULL
, NULL
);
143 ok(hr
== E_INVALIDARG
, "GetPixelFormats failed, hr=%x\n", hr
);
146 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, pixelformats
, &count
);
147 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
148 ok(count
== 0, "got %d formats\n", count
);
151 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 1, pixelformats
, &count
);
152 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
153 ok(count
== 1, "got %d formats\n", count
);
154 ok(is_pixelformat(&pixelformats
[0]), "got invalid pixel format\n");
157 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, num_formats
, pixelformats
, &count
);
158 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
159 ok(count
== num_formats
, "got %d formats, expected %d\n", count
, num_formats
);
160 for (i
=0; i
<num_formats
; i
++)
161 ok(is_pixelformat(&pixelformats
[i
]), "got invalid pixel format\n");
163 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, num_formats
, pixelformats
, NULL
);
164 ok(hr
== E_INVALIDARG
, "GetPixelFormats failed, hr=%x\n", hr
);
167 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 20, pixelformats
, &count
);
168 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
169 ok(count
== num_formats
, "got %d formats, expected %d\n", count
, num_formats
);
171 IWICBitmapDecoderInfo_Release(decoder_info
);
173 IWICComponentInfo_Release(info
);
176 static void test_pixelformat_info(void)
178 IWICComponentInfo
*info
;
179 IWICPixelFormatInfo
*pixelformat_info
;
180 IWICPixelFormatInfo2
*pixelformat_info2
;
182 ULONG len
, known_len
;
185 WICComponentType componenttype
;
186 WICPixelFormatNumericRepresentation numericrepresentation
;
190 BOOL supportstransparency
;
192 hr
= get_component_info(&GUID_WICPixelFormat32bppBGRA
, &info
);
193 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
198 hr
= IWICComponentInfo_GetAuthor(info
, 0, NULL
, 0);
199 ok(hr
== E_INVALIDARG
, "GetAuthor failed, hr=%x\n", hr
);
202 hr
= IWICComponentInfo_GetAuthor(info
, 0, NULL
, &len
);
203 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
204 ok(len
< 255 && len
> 0, "invalid length 0x%x\n", len
);
207 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
208 hr
= IWICComponentInfo_GetAuthor(info
, len
-1, value
, NULL
);
209 ok(hr
== E_INVALIDARG
, "GetAuthor failed, hr=%x\n", hr
);
210 ok(value
[0] = 0xaaaa, "string modified\n");
213 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
214 hr
= IWICComponentInfo_GetAuthor(info
, known_len
-1, value
, &len
);
215 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetAuthor failed, hr=%x\n", hr
);
216 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
217 ok(value
[known_len
-1] == 0xaaaa, "string modified past given length\n");
218 ok(value
[0] == 0xaaaa, "string modified\n");
221 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
222 hr
= IWICComponentInfo_GetAuthor(info
, known_len
, value
, &len
);
223 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
224 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
225 ok(value
[known_len
-1] == 0, "string not terminated at expected length\n");
226 ok(value
[known_len
-2] != 0xaaaa, "string not modified at given length\n");
229 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
230 hr
= IWICComponentInfo_GetAuthor(info
, known_len
+1, value
, &len
);
231 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
232 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
233 ok(value
[known_len
] == 0xaaaa, "string modified past end\n");
234 ok(value
[known_len
-1] == 0, "string not terminated at expected length\n");
235 ok(value
[known_len
-2] != 0xaaaa, "string not modified at given length\n");
237 hr
= IWICComponentInfo_GetCLSID(info
, NULL
);
238 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
240 memset(&guid
, 0xaa, sizeof(guid
));
241 hr
= IWICComponentInfo_GetCLSID(info
, &guid
);
242 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
243 ok(IsEqualGUID(&guid
, &GUID_WICPixelFormat32bppBGRA
), "unexpected CLSID %s\n", debugstr_guid(&guid
));
245 hr
= IWICComponentInfo_GetComponentType(info
, NULL
);
246 ok(hr
== E_INVALIDARG
, "GetComponentType failed, hr=%x\n", hr
);
248 hr
= IWICComponentInfo_GetComponentType(info
, &componenttype
);
249 ok(hr
== S_OK
, "GetComponentType failed, hr=%x\n", hr
);
250 ok(componenttype
== WICPixelFormat
, "unexpected component type 0x%x\n", componenttype
);
253 hr
= IWICComponentInfo_GetFriendlyName(info
, 0, NULL
, &len
);
254 ok(hr
== S_OK
, "GetFriendlyName failed, hr=%x\n", hr
);
255 ok(len
< 255 && len
> 0, "invalid length 0x%x\n", len
);
257 hr
= IWICComponentInfo_GetSigningStatus(info
, NULL
);
258 ok(hr
== E_INVALIDARG
, "GetSigningStatus failed, hr=%x\n", hr
);
260 hr
= IWICComponentInfo_GetSigningStatus(info
, &signing
);
261 ok(hr
== S_OK
, "GetSigningStatus failed, hr=%x\n", hr
);
262 ok(signing
== WICComponentSigned
, "unexpected signing status 0x%x\n", signing
);
265 hr
= IWICComponentInfo_GetSpecVersion(info
, 0, NULL
, &len
);
266 ok(hr
== S_OK
, "GetSpecVersion failed, hr=%x\n", hr
);
267 ok(len
== 0, "invalid length 0x%x\n", len
); /* spec version does not apply to pixel formats */
269 memset(&guid
, 0xaa, sizeof(guid
));
270 hr
= IWICComponentInfo_GetVendorGUID(info
, &guid
);
271 ok(hr
== S_OK
, "GetVendorGUID failed, hr=%x\n", hr
);
272 ok(IsEqualGUID(&guid
, &GUID_VendorMicrosoft
) ||
273 broken(IsEqualGUID(&guid
, &GUID_NULL
)) /* XP */, "unexpected GUID %s\n", debugstr_guid(&guid
));
276 hr
= IWICComponentInfo_GetVersion(info
, 0, NULL
, &len
);
277 ok(hr
== S_OK
, "GetVersion failed, hr=%x\n", hr
);
278 ok(len
== 0, "invalid length 0x%x\n", len
); /* version does not apply to pixel formats */
280 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICPixelFormatInfo
, (void**)&pixelformat_info
);
281 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
285 hr
= IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info
, NULL
);
286 ok(hr
== E_INVALIDARG
, "GetBitsPerPixel failed, hr=%x\n", hr
);
288 hr
= IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info
, &uiresult
);
289 ok(hr
== S_OK
, "GetBitsPerPixel failed, hr=%x\n", hr
);
290 ok(uiresult
== 32, "unexpected bpp %i\n", uiresult
);
292 hr
= IWICPixelFormatInfo_GetChannelCount(pixelformat_info
, &uiresult
);
293 ok(hr
== S_OK
, "GetChannelCount failed, hr=%x\n", hr
);
294 ok(uiresult
== 4, "unexpected channel count %i\n", uiresult
);
296 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 0, NULL
, NULL
);
297 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
299 uiresult
= 0xdeadbeef;
300 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 0, NULL
, &uiresult
);
301 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
302 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
304 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
305 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, known_len
, abbuffer
, NULL
);
306 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
307 ok(abbuffer
[0] == 0xaa, "buffer modified\n");
309 uiresult
= 0xdeadbeef;
310 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
311 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 3, abbuffer
, &uiresult
);
312 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
313 ok(abbuffer
[0] == 0xaa, "buffer modified\n");
314 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
316 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
317 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 4, abbuffer
, &uiresult
);
318 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
319 ok(*((ULONG
*)abbuffer
) == 0xff, "unexpected mask 0x%x\n", *((ULONG
*)abbuffer
));
320 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
322 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
323 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 5, abbuffer
, &uiresult
);
324 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
325 ok(*((ULONG
*)abbuffer
) == 0xff, "unexpected mask 0x%x\n", *((ULONG
*)abbuffer
));
326 ok(abbuffer
[4] == 0xaa, "buffer modified past actual length\n");
327 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
329 memset(&guid
, 0xaa, sizeof(guid
));
330 hr
= IWICPixelFormatInfo_GetFormatGUID(pixelformat_info
, &guid
);
331 ok(hr
== S_OK
, "GetFormatGUID failed, hr=%x\n", hr
);
332 ok(IsEqualGUID(&guid
, &GUID_WICPixelFormat32bppBGRA
), "unexpected GUID %s\n", debugstr_guid(&guid
));
334 IWICPixelFormatInfo_Release(pixelformat_info
);
337 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICPixelFormatInfo2
, (void**)&pixelformat_info2
);
340 win_skip("IWICPixelFormatInfo2 not supported\n");
343 hr
= IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2
, NULL
);
344 ok(hr
== E_INVALIDARG
, "GetNumericRepresentation failed, hr=%x\n", hr
);
346 numericrepresentation
= 0xdeadbeef;
347 hr
= IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2
, &numericrepresentation
);
348 ok(hr
== S_OK
, "GetNumericRepresentation failed, hr=%x\n", hr
);
349 ok(numericrepresentation
== WICPixelFormatNumericRepresentationUnsignedInteger
, "unexpected numeric representation %i\n", numericrepresentation
);
351 hr
= IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2
, NULL
);
352 ok(hr
== E_INVALIDARG
, "SupportsTransparency failed, hr=%x\n", hr
);
354 supportstransparency
= 0xdeadbeef;
355 hr
= IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2
, &supportstransparency
);
356 ok(hr
== S_OK
, "SupportsTransparency failed, hr=%x\n", hr
);
357 ok(supportstransparency
== 1, "unexpected value %i\n", supportstransparency
);
359 IWICPixelFormatInfo2_Release(pixelformat_info2
);
362 IWICComponentInfo_Release(info
);
365 static void test_reader_info(void)
367 IWICImagingFactory
*factory
;
368 IWICComponentInfo
*info
;
369 IWICMetadataReaderInfo
*reader_info
;
372 GUID container_formats
[10];
374 WICMetadataPattern
*patterns
;
376 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
377 &IID_IWICImagingFactory
, (void**)&factory
);
378 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
379 if (FAILED(hr
)) return;
381 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICUnknownMetadataReader
, &info
);
382 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
384 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICMetadataReaderInfo
, (void**)&reader_info
);
385 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
387 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, NULL
);
388 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
390 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, &clsid
);
391 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
392 ok(IsEqualGUID(&CLSID_WICUnknownMetadataReader
, &clsid
), "GetCLSID returned wrong result\n");
394 hr
= IWICMetadataReaderInfo_GetMetadataFormat(reader_info
, &clsid
);
395 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
396 ok(IsEqualGUID(&GUID_MetadataFormatUnknown
, &clsid
), "GetMetadataFormat returned wrong result\n");
398 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, NULL
);
399 ok(hr
== E_INVALIDARG
, "GetContainerFormats failed, hr=%x\n", hr
);
402 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, &count
);
404 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
406 ok(count
== 0, "unexpected count %d\n", count
);
408 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
409 0, NULL
, NULL
, NULL
);
410 ok(hr
== E_INVALIDARG
, "GetPatterns failed, hr=%x\n", hr
);
412 count
= size
= 0xdeadbeef;
413 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
414 0, NULL
, &count
, &size
);
416 ok(hr
== WINCODEC_ERR_COMPONENTNOTFOUND
|| broken(hr
== S_OK
) /* Windows XP */,
417 "GetPatterns failed, hr=%x\n", hr
);
418 ok(count
== 0xdeadbeef, "unexpected count %d\n", count
);
419 ok(size
== 0xdeadbeef, "unexpected size %d\n", size
);
421 IWICMetadataReaderInfo_Release(reader_info
);
423 IWICComponentInfo_Release(info
);
425 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICXMPStructMetadataReader
, &info
);
427 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
431 IWICImagingFactory_Release(factory
);
435 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICMetadataReaderInfo
, (void**)&reader_info
);
436 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
438 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, NULL
);
439 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
441 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, &clsid
);
442 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
443 ok(IsEqualGUID(&CLSID_WICXMPStructMetadataReader
, &clsid
), "GetCLSID returned wrong result\n");
445 hr
= IWICMetadataReaderInfo_GetMetadataFormat(reader_info
, &clsid
);
446 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
447 ok(IsEqualGUID(&GUID_MetadataFormatXMPStruct
, &clsid
), "GetMetadataFormat returned wrong result\n");
449 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, NULL
);
450 ok(hr
== E_INVALIDARG
, "GetContainerFormats failed, hr=%x\n", hr
);
453 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, &count
);
454 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
455 ok(count
>= 2, "unexpected count %d\n", count
);
458 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 1, container_formats
, &count
);
459 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
460 ok(count
== 1, "unexpected count %d\n", count
);
463 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 10, container_formats
, &count
);
464 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
465 ok(count
== min(count
, 10), "unexpected count %d\n", count
);
467 count
= size
= 0xdeadbeef;
468 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
469 0, NULL
, &count
, &size
);
470 ok(hr
== WINCODEC_ERR_COMPONENTNOTFOUND
|| broken(hr
== S_OK
) /* Windows XP */,
471 "GetPatterns failed, hr=%x\n", hr
);
472 ok(count
== 0xdeadbeef, "unexpected count %d\n", count
);
473 ok(size
== 0xdeadbeef, "unexpected size %d\n", size
);
475 count
= size
= 0xdeadbeef;
476 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
477 0, NULL
, &count
, &size
);
478 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
479 ok(count
== 1, "unexpected count %d\n", count
);
480 ok(size
> sizeof(WICMetadataPattern
), "unexpected size %d\n", size
);
484 patterns
= HeapAlloc(GetProcessHeap(), 0, size
);
486 count
= size
= 0xdeadbeef;
487 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
488 size
-1, patterns
, &count
, &size
);
489 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
490 ok(count
== 1, "unexpected count %d\n", count
);
491 ok(size
> sizeof(WICMetadataPattern
), "unexpected size %d\n", size
);
493 count
= size
= 0xdeadbeef;
494 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
495 size
, patterns
, &count
, &size
);
496 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
497 ok(count
== 1, "unexpected count %d\n", count
);
498 ok(size
== sizeof(WICMetadataPattern
) + patterns
->Length
* 2, "unexpected size %d\n", size
);
500 HeapFree(GetProcessHeap(), 0, patterns
);
503 IWICMetadataReaderInfo_Release(reader_info
);
505 IWICComponentInfo_Release(info
);
507 IWICImagingFactory_Release(factory
);
512 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
516 test_pixelformat_info();