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};
91 const WCHAR expected_extensions
[] = {'.','b','m','p',',','.','d','i','b',',','.','r','l','e',0};
93 GUID pixelformats
[20];
94 UINT num_formats
, count
;
97 hr
= get_component_info(&CLSID_WICBmpDecoder
, &info
);
99 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICBitmapDecoderInfo
, (void**)&decoder_info
);
100 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
102 hr
= IWICBitmapDecoderInfo_GetCLSID(decoder_info
, NULL
);
103 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
105 hr
= IWICBitmapDecoderInfo_GetCLSID(decoder_info
, &clsid
);
106 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
107 ok(IsEqualGUID(&CLSID_WICBmpDecoder
, &clsid
), "GetCLSID returned wrong result\n");
109 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 0, NULL
, NULL
);
110 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
112 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 1, NULL
, &len
);
113 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
114 ok(len
== lstrlenW(expected_mimetype
)+1, "GetMimeType returned wrong len %i\n", len
);
116 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, len
, value
, NULL
);
117 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
119 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 0, NULL
, &len
);
120 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
121 ok(len
== lstrlenW(expected_mimetype
)+1, "GetMimeType returned wrong len %i\n", len
);
124 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, len
, value
, &len
);
125 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
126 ok(lstrcmpW(value
, expected_mimetype
) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value
));
127 ok(len
== lstrlenW(expected_mimetype
)+1, "GetMimeType returned wrong len %i\n", len
);
129 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 1, value
, &len
);
130 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetMimeType failed, hr=%x\n", hr
);
131 ok(len
== lstrlenW(expected_mimetype
)+1, "GetMimeType returned wrong len %i\n", len
);
133 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 256, value
, &len
);
134 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
135 ok(lstrcmpW(value
, expected_mimetype
) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value
));
136 ok(len
== lstrlenW(expected_mimetype
)+1, "GetMimeType returned wrong len %i\n", len
);
138 num_formats
= 0xdeadbeef;
139 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, NULL
, &num_formats
);
140 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
141 ok(num_formats
< 20 && num_formats
> 1, "got %d formats\n", num_formats
);
143 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, NULL
, NULL
);
144 ok(hr
== E_INVALIDARG
, "GetPixelFormats failed, hr=%x\n", hr
);
147 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, pixelformats
, &count
);
148 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
149 ok(count
== 0, "got %d formats\n", count
);
152 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 1, pixelformats
, &count
);
153 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
154 ok(count
== 1, "got %d formats\n", count
);
155 ok(is_pixelformat(&pixelformats
[0]), "got invalid pixel format\n");
158 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, num_formats
, pixelformats
, &count
);
159 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
160 ok(count
== num_formats
, "got %d formats, expected %d\n", count
, num_formats
);
161 for (i
=0; i
<num_formats
; i
++)
162 ok(is_pixelformat(&pixelformats
[i
]), "got invalid pixel format\n");
164 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, num_formats
, pixelformats
, NULL
);
165 ok(hr
== E_INVALIDARG
, "GetPixelFormats failed, hr=%x\n", hr
);
168 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 20, pixelformats
, &count
);
169 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
170 ok(count
== num_formats
, "got %d formats, expected %d\n", count
, num_formats
);
172 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 0, NULL
, NULL
);
173 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
175 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 1, NULL
, &len
);
176 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
177 ok(len
== lstrlenW(expected_extensions
)+1, "GetFileExtensions returned wrong len %i\n", len
);
179 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, len
, value
, NULL
);
180 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
182 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 0, NULL
, &len
);
183 ok(hr
== S_OK
, "GetFileExtensions failed, hr=%x\n", hr
);
184 ok(len
== lstrlenW(expected_extensions
)+1, "GetFileExtensions returned wrong len %i\n", len
);
187 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, len
, value
, &len
);
188 ok(hr
== S_OK
, "GetFileExtensions failed, hr=%x\n", hr
);
189 ok(lstrcmpW(value
, expected_extensions
) == 0, "GetFileExtensions returned wrong value %s\n", wine_dbgstr_w(value
));
190 ok(len
== lstrlenW(expected_extensions
)+1, "GetFileExtensions returned wrong len %i\n", len
);
192 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 1, value
, &len
);
193 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetFileExtensions failed, hr=%x\n", hr
);
194 ok(len
== lstrlenW(expected_extensions
)+1, "GetFileExtensions returned wrong len %i\n", len
);
196 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 256, value
, &len
);
197 ok(hr
== S_OK
, "GetFileExtensions failed, hr=%x\n", hr
);
198 ok(lstrcmpW(value
, expected_extensions
) == 0, "GetFileExtensions returned wrong value %s\n", wine_dbgstr_w(value
));
199 ok(len
== lstrlenW(expected_extensions
)+1, "GetFileExtensions returned wrong len %i\n", len
);
201 IWICBitmapDecoderInfo_Release(decoder_info
);
203 IWICComponentInfo_Release(info
);
206 static void test_pixelformat_info(void)
208 IWICComponentInfo
*info
;
209 IWICPixelFormatInfo
*pixelformat_info
;
210 IWICPixelFormatInfo2
*pixelformat_info2
;
212 ULONG len
, known_len
;
215 WICComponentType componenttype
;
216 WICPixelFormatNumericRepresentation numericrepresentation
;
220 BOOL supportstransparency
;
222 hr
= get_component_info(&GUID_WICPixelFormat32bppBGRA
, &info
);
223 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
228 hr
= IWICComponentInfo_GetAuthor(info
, 0, NULL
, 0);
229 ok(hr
== E_INVALIDARG
, "GetAuthor failed, hr=%x\n", hr
);
232 hr
= IWICComponentInfo_GetAuthor(info
, 0, NULL
, &len
);
233 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
234 ok(len
< 255 && len
> 0, "invalid length 0x%x\n", len
);
237 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
238 hr
= IWICComponentInfo_GetAuthor(info
, len
-1, value
, NULL
);
239 ok(hr
== E_INVALIDARG
, "GetAuthor failed, hr=%x\n", hr
);
240 ok(value
[0] = 0xaaaa, "string modified\n");
243 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
244 hr
= IWICComponentInfo_GetAuthor(info
, known_len
-1, value
, &len
);
245 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetAuthor failed, hr=%x\n", hr
);
246 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
247 ok(value
[known_len
-1] == 0xaaaa, "string modified past given length\n");
248 ok(value
[0] == 0xaaaa, "string modified\n");
251 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
252 hr
= IWICComponentInfo_GetAuthor(info
, known_len
, value
, &len
);
253 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
254 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
255 ok(value
[known_len
-1] == 0, "string not terminated at expected length\n");
256 ok(value
[known_len
-2] != 0xaaaa, "string not modified at given length\n");
259 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
260 hr
= IWICComponentInfo_GetAuthor(info
, known_len
+1, value
, &len
);
261 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
262 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
263 ok(value
[known_len
] == 0xaaaa, "string modified past end\n");
264 ok(value
[known_len
-1] == 0, "string not terminated at expected length\n");
265 ok(value
[known_len
-2] != 0xaaaa, "string not modified at given length\n");
267 hr
= IWICComponentInfo_GetCLSID(info
, NULL
);
268 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
270 memset(&guid
, 0xaa, sizeof(guid
));
271 hr
= IWICComponentInfo_GetCLSID(info
, &guid
);
272 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
273 ok(IsEqualGUID(&guid
, &GUID_WICPixelFormat32bppBGRA
), "unexpected CLSID %s\n", debugstr_guid(&guid
));
275 hr
= IWICComponentInfo_GetComponentType(info
, NULL
);
276 ok(hr
== E_INVALIDARG
, "GetComponentType failed, hr=%x\n", hr
);
278 hr
= IWICComponentInfo_GetComponentType(info
, &componenttype
);
279 ok(hr
== S_OK
, "GetComponentType failed, hr=%x\n", hr
);
280 ok(componenttype
== WICPixelFormat
, "unexpected component type 0x%x\n", componenttype
);
283 hr
= IWICComponentInfo_GetFriendlyName(info
, 0, NULL
, &len
);
284 ok(hr
== S_OK
, "GetFriendlyName failed, hr=%x\n", hr
);
285 ok(len
< 255 && len
> 0, "invalid length 0x%x\n", len
);
287 hr
= IWICComponentInfo_GetSigningStatus(info
, NULL
);
288 ok(hr
== E_INVALIDARG
, "GetSigningStatus failed, hr=%x\n", hr
);
290 hr
= IWICComponentInfo_GetSigningStatus(info
, &signing
);
291 ok(hr
== S_OK
, "GetSigningStatus failed, hr=%x\n", hr
);
292 ok(signing
== WICComponentSigned
, "unexpected signing status 0x%x\n", signing
);
295 hr
= IWICComponentInfo_GetSpecVersion(info
, 0, NULL
, &len
);
296 ok(hr
== S_OK
, "GetSpecVersion failed, hr=%x\n", hr
);
297 ok(len
== 0, "invalid length 0x%x\n", len
); /* spec version does not apply to pixel formats */
299 memset(&guid
, 0xaa, sizeof(guid
));
300 hr
= IWICComponentInfo_GetVendorGUID(info
, &guid
);
301 ok(hr
== S_OK
, "GetVendorGUID failed, hr=%x\n", hr
);
302 ok(IsEqualGUID(&guid
, &GUID_VendorMicrosoft
) ||
303 broken(IsEqualGUID(&guid
, &GUID_NULL
)) /* XP */, "unexpected GUID %s\n", debugstr_guid(&guid
));
306 hr
= IWICComponentInfo_GetVersion(info
, 0, NULL
, &len
);
307 ok(hr
== S_OK
, "GetVersion failed, hr=%x\n", hr
);
308 ok(len
== 0, "invalid length 0x%x\n", len
); /* version does not apply to pixel formats */
310 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICPixelFormatInfo
, (void**)&pixelformat_info
);
311 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
315 hr
= IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info
, NULL
);
316 ok(hr
== E_INVALIDARG
, "GetBitsPerPixel failed, hr=%x\n", hr
);
318 hr
= IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info
, &uiresult
);
319 ok(hr
== S_OK
, "GetBitsPerPixel failed, hr=%x\n", hr
);
320 ok(uiresult
== 32, "unexpected bpp %i\n", uiresult
);
322 hr
= IWICPixelFormatInfo_GetChannelCount(pixelformat_info
, &uiresult
);
323 ok(hr
== S_OK
, "GetChannelCount failed, hr=%x\n", hr
);
324 ok(uiresult
== 4, "unexpected channel count %i\n", uiresult
);
326 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 0, NULL
, NULL
);
327 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
329 uiresult
= 0xdeadbeef;
330 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 0, NULL
, &uiresult
);
331 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
332 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
334 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
335 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, known_len
, abbuffer
, NULL
);
336 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
337 ok(abbuffer
[0] == 0xaa, "buffer modified\n");
339 uiresult
= 0xdeadbeef;
340 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
341 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 3, abbuffer
, &uiresult
);
342 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
343 ok(abbuffer
[0] == 0xaa, "buffer modified\n");
344 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
346 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
347 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 4, abbuffer
, &uiresult
);
348 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
349 ok(*((ULONG
*)abbuffer
) == 0xff, "unexpected mask 0x%x\n", *((ULONG
*)abbuffer
));
350 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
352 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
353 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 5, abbuffer
, &uiresult
);
354 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
355 ok(*((ULONG
*)abbuffer
) == 0xff, "unexpected mask 0x%x\n", *((ULONG
*)abbuffer
));
356 ok(abbuffer
[4] == 0xaa, "buffer modified past actual length\n");
357 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
359 memset(&guid
, 0xaa, sizeof(guid
));
360 hr
= IWICPixelFormatInfo_GetFormatGUID(pixelformat_info
, &guid
);
361 ok(hr
== S_OK
, "GetFormatGUID failed, hr=%x\n", hr
);
362 ok(IsEqualGUID(&guid
, &GUID_WICPixelFormat32bppBGRA
), "unexpected GUID %s\n", debugstr_guid(&guid
));
364 IWICPixelFormatInfo_Release(pixelformat_info
);
367 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICPixelFormatInfo2
, (void**)&pixelformat_info2
);
370 win_skip("IWICPixelFormatInfo2 not supported\n");
373 hr
= IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2
, NULL
);
374 ok(hr
== E_INVALIDARG
, "GetNumericRepresentation failed, hr=%x\n", hr
);
376 numericrepresentation
= 0xdeadbeef;
377 hr
= IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2
, &numericrepresentation
);
378 ok(hr
== S_OK
, "GetNumericRepresentation failed, hr=%x\n", hr
);
379 ok(numericrepresentation
== WICPixelFormatNumericRepresentationUnsignedInteger
, "unexpected numeric representation %i\n", numericrepresentation
);
381 hr
= IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2
, NULL
);
382 ok(hr
== E_INVALIDARG
, "SupportsTransparency failed, hr=%x\n", hr
);
384 supportstransparency
= 0xdeadbeef;
385 hr
= IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2
, &supportstransparency
);
386 ok(hr
== S_OK
, "SupportsTransparency failed, hr=%x\n", hr
);
387 ok(supportstransparency
== 1, "unexpected value %i\n", supportstransparency
);
389 IWICPixelFormatInfo2_Release(pixelformat_info2
);
392 IWICComponentInfo_Release(info
);
395 static void test_reader_info(void)
397 IWICImagingFactory
*factory
;
398 IWICComponentInfo
*info
;
399 IWICMetadataReaderInfo
*reader_info
;
402 GUID container_formats
[10];
404 WICMetadataPattern
*patterns
;
406 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
407 &IID_IWICImagingFactory
, (void**)&factory
);
408 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
409 if (FAILED(hr
)) return;
411 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICUnknownMetadataReader
, &info
);
412 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
414 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICMetadataReaderInfo
, (void**)&reader_info
);
415 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
417 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, NULL
);
418 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
420 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, &clsid
);
421 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
422 ok(IsEqualGUID(&CLSID_WICUnknownMetadataReader
, &clsid
), "GetCLSID returned wrong result\n");
424 hr
= IWICMetadataReaderInfo_GetMetadataFormat(reader_info
, &clsid
);
425 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
426 ok(IsEqualGUID(&GUID_MetadataFormatUnknown
, &clsid
), "GetMetadataFormat returned wrong result\n");
428 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, NULL
);
429 ok(hr
== E_INVALIDARG
, "GetContainerFormats failed, hr=%x\n", hr
);
432 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, &count
);
434 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
436 ok(count
== 0, "unexpected count %d\n", count
);
438 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
439 0, NULL
, NULL
, NULL
);
440 ok(hr
== E_INVALIDARG
, "GetPatterns failed, hr=%x\n", hr
);
442 count
= size
= 0xdeadbeef;
443 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
444 0, NULL
, &count
, &size
);
446 ok(hr
== WINCODEC_ERR_COMPONENTNOTFOUND
|| broken(hr
== S_OK
) /* Windows XP */,
447 "GetPatterns failed, hr=%x\n", hr
);
448 ok(count
== 0xdeadbeef, "unexpected count %d\n", count
);
449 ok(size
== 0xdeadbeef, "unexpected size %d\n", size
);
451 IWICMetadataReaderInfo_Release(reader_info
);
453 IWICComponentInfo_Release(info
);
455 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICXMPStructMetadataReader
, &info
);
457 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
461 IWICImagingFactory_Release(factory
);
465 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICMetadataReaderInfo
, (void**)&reader_info
);
466 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
468 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, NULL
);
469 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
471 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, &clsid
);
472 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
473 ok(IsEqualGUID(&CLSID_WICXMPStructMetadataReader
, &clsid
), "GetCLSID returned wrong result\n");
475 hr
= IWICMetadataReaderInfo_GetMetadataFormat(reader_info
, &clsid
);
476 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
477 ok(IsEqualGUID(&GUID_MetadataFormatXMPStruct
, &clsid
), "GetMetadataFormat returned wrong result\n");
479 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, NULL
);
480 ok(hr
== E_INVALIDARG
, "GetContainerFormats failed, hr=%x\n", hr
);
483 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, &count
);
484 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
485 ok(count
>= 2, "unexpected count %d\n", count
);
488 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 1, container_formats
, &count
);
489 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
490 ok(count
== 1, "unexpected count %d\n", count
);
493 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 10, container_formats
, &count
);
494 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
495 ok(count
== min(count
, 10), "unexpected count %d\n", count
);
497 count
= size
= 0xdeadbeef;
498 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
499 0, NULL
, &count
, &size
);
500 ok(hr
== WINCODEC_ERR_COMPONENTNOTFOUND
|| broken(hr
== S_OK
) /* Windows XP */,
501 "GetPatterns failed, hr=%x\n", hr
);
502 ok(count
== 0xdeadbeef, "unexpected count %d\n", count
);
503 ok(size
== 0xdeadbeef, "unexpected size %d\n", size
);
505 count
= size
= 0xdeadbeef;
506 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
507 0, NULL
, &count
, &size
);
508 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
509 ok(count
== 1, "unexpected count %d\n", count
);
510 ok(size
> sizeof(WICMetadataPattern
), "unexpected size %d\n", size
);
514 patterns
= HeapAlloc(GetProcessHeap(), 0, size
);
516 count
= size
= 0xdeadbeef;
517 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
518 size
-1, patterns
, &count
, &size
);
519 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
520 ok(count
== 1, "unexpected count %d\n", count
);
521 ok(size
> sizeof(WICMetadataPattern
), "unexpected size %d\n", size
);
523 count
= size
= 0xdeadbeef;
524 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
525 size
, patterns
, &count
, &size
);
526 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
527 ok(count
== 1, "unexpected count %d\n", count
);
528 ok(size
== sizeof(WICMetadataPattern
) + patterns
->Length
* 2, "unexpected size %d\n", size
);
530 HeapFree(GetProcessHeap(), 0, patterns
);
533 IWICMetadataReaderInfo_Release(reader_info
);
535 IWICComponentInfo_Release(info
);
537 IWICImagingFactory_Release(factory
);
542 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
546 test_pixelformat_info();