ReactOS 0.4.16-dev-752-g47bae01
info.c
Go to the documentation of this file.
1/*
2 * Copyright 2009 Vincent Povirk for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19#include <stdio.h>
20#include <stdarg.h>
21#include <math.h>
22
23#define COBJMACROS
24
25#include "windef.h"
26#include "objbase.h"
27#include "wincodec.h"
28#include "wincodecsdk.h"
29#include "wine/test.h"
30
32{
34 HRESULT hr;
35
36 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
37 &IID_IWICImagingFactory, (void**)&factory);
38 ok(hr == S_OK, "CoCreateInstance failed, hr=%lx\n", hr);
39 if (FAILED(hr)) return hr;
40
41 hr = IWICImagingFactory_CreateComponentInfo(factory, clsid, result);
42
43 IWICImagingFactory_Release(factory);
44
45 return hr;
46}
47
49{
51 HRESULT hr;
52 WICComponentType componenttype;
53
55 if (FAILED(hr))
56 return FALSE;
57
58 hr = IWICComponentInfo_GetComponentType(info, &componenttype);
59
60 IWICComponentInfo_Release(info);
61
62 return SUCCEEDED(hr) && componenttype == WICPixelFormat;
63}
64
65static void test_decoder_info(void)
66{
67 struct decoder_info_test
68 {
69 const CLSID *clsid;
70 const char *mimetype;
71 const char *extensions;
72 unsigned int todo;
73 } decoder_info_tests[] =
74 {
75 {
76 &CLSID_WICBmpDecoder,
77 "image/bmp",
78 ".bmp,.dib,.rle"
79 },
80 {
81 &CLSID_WICGifDecoder,
82 "image/gif",
83 ".gif"
84 },
85 {
86 &CLSID_WICIcoDecoder,
87 "image/ico,image/x-icon",
88 ".ico,.icon",
89 1
90 },
91 {
92 &CLSID_WICJpegDecoder,
93 "image/jpeg,image/jpe,image/jpg",
94 ".jpeg,.jpe,.jpg,.jfif,.exif",
95 1
96 },
97 {
98 &CLSID_WICPngDecoder,
99 "image/png",
100 ".png"
101 },
102 {
103 &CLSID_WICTiffDecoder,
104 "image/tiff,image/tif",
105 ".tiff,.tif",
106 1
107 },
108 {
109 &CLSID_WICDdsDecoder,
110 "image/vnd.ms-dds",
111 ".dds",
112 }
113 };
114 IWICBitmapDecoderInfo *decoder_info, *decoder_info2;
116 HRESULT hr;
117 UINT len;
118 WCHAR value[256];
119 CLSID clsid;
120 GUID pixelformats[32];
121 UINT num_formats, count;
122 int i, j;
123
124 for (i = 0; i < ARRAY_SIZE(decoder_info_tests); i++)
125 {
126 struct decoder_info_test *test = &decoder_info_tests[i];
127 IWICBitmapDecoder *decoder, *decoder2;
128 WCHAR extensionsW[64];
129 WCHAR mimetypeW[64];
130
131 hr = CoCreateInstance(test->clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IWICBitmapDecoder, (void **)&decoder);
132 if (test->clsid == &CLSID_WICDdsDecoder && hr != S_OK) {
133 win_skip("DDS decoder is not supported\n");
134 continue;
135 }
136 ok(SUCCEEDED(hr), "Failed to create decoder, hr %#lx.\n", hr);
137
139 hr = IWICBitmapDecoder_GetDecoderInfo(decoder, &decoder_info);
140 ok(hr == S_OK || broken(IsEqualCLSID(&CLSID_WICBmpDecoder, test->clsid) && FAILED(hr)) /* Fails on Windows */,
141 "%u: failed to get decoder info, hr %#lx.\n", i, hr);
142
143 if (hr == S_OK)
144 {
145 decoder_info2 = NULL;
146 hr = IWICBitmapDecoder_GetDecoderInfo(decoder, &decoder_info2);
147 ok(hr == S_OK, "Failed to get decoder info, hr %#lx.\n", hr);
148 ok(decoder_info == decoder_info2, "Unexpected decoder info instance.\n");
149
150 hr = IWICBitmapDecoderInfo_QueryInterface(decoder_info, &IID_IWICBitmapDecoder, (void **)&decoder2);
151 ok(hr == E_NOINTERFACE, "Unexpected hr %#lx.\n", hr);
152
153 IWICBitmapDecoderInfo_Release(decoder_info);
154 IWICBitmapDecoderInfo_Release(decoder_info2);
155 }
156 IWICBitmapDecoder_Release(decoder);
157
158 MultiByteToWideChar(CP_ACP, 0, test->mimetype, -1, mimetypeW, ARRAY_SIZE(mimetypeW));
159 MultiByteToWideChar(CP_ACP, 0, test->extensions, -1, extensionsW, ARRAY_SIZE(extensionsW));
160
161 hr = get_component_info(test->clsid, &info);
162 ok(hr == S_OK, "CreateComponentInfo failed, hr=%lx\n", hr);
163
164 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICBitmapDecoderInfo, (void **)&decoder_info);
165 ok(hr == S_OK, "QueryInterface failed, hr=%lx\n", hr);
166
167 hr = IWICBitmapDecoderInfo_GetCLSID(decoder_info, NULL);
168 ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%lx\n", hr);
169
170 hr = IWICBitmapDecoderInfo_GetCLSID(decoder_info, &clsid);
171 ok(hr == S_OK, "GetCLSID failed, hr=%lx\n", hr);
172 ok(IsEqualGUID(test->clsid, &clsid), "GetCLSID returned wrong result\n");
173
174 hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 0, NULL, NULL);
175 ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%lx\n", hr);
176
177 len = 0;
178 hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 1, NULL, &len);
179 ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%lx\n", hr);
180 todo_wine_if(test->todo)
181 ok(len == lstrlenW(mimetypeW) + 1, "GetMimeType returned wrong len %i\n", len);
182
183 hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, len, value, NULL);
184 ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%lx\n", hr);
185
186 len = 0;
187 hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 0, NULL, &len);
188 ok(hr == S_OK, "GetMimeType failed, hr=%lx\n", hr);
189 todo_wine_if(test->todo)
190 ok(len == lstrlenW(mimetypeW) + 1, "GetMimeType returned wrong len %i\n", len);
191
192 value[0] = 0;
193 hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, len, value, &len);
194 ok(hr == S_OK, "GetMimeType failed, hr=%lx\n", hr);
195 todo_wine_if(test->todo) {
196 ok(lstrcmpW(value, mimetypeW) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value));
197 ok(len == lstrlenW(mimetypeW) + 1, "GetMimeType returned wrong len %i\n", len);
198 }
199 hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 1, value, &len);
200 ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "GetMimeType failed, hr=%lx\n", hr);
201 todo_wine_if(test->todo)
202 ok(len == lstrlenW(mimetypeW) + 1, "GetMimeType returned wrong len %i\n", len);
203
204 hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 256, value, &len);
205 ok(hr == S_OK, "GetMimeType failed, hr=%lx\n", hr);
206 todo_wine_if(test->todo) {
207 ok(lstrcmpW(value, mimetypeW) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value));
208 ok(len == lstrlenW(mimetypeW) + 1, "GetMimeType returned wrong len %i\n", len);
209 }
210 num_formats = 0xdeadbeef;
211 hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 0, NULL, &num_formats);
212 ok(hr == S_OK, "GetPixelFormats failed, hr=%lx\n", hr);
213 ok((num_formats <= 21 && num_formats >= 1) ||
214 broken(IsEqualCLSID(test->clsid, &CLSID_WICIcoDecoder) && num_formats == 0) /* WinXP */,
215 "%u: got %d formats\n", i, num_formats);
216
217 hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 0, NULL, NULL);
218 ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%lx\n", hr);
219
220 count = 0xdeadbeef;
221 hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 0, pixelformats, &count);
222 ok(hr == S_OK, "GetPixelFormats failed, hr=%lx\n", hr);
223 ok(count == 0, "got %d formats\n", count);
224
225 count = 0xdeadbeef;
226 hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 1, pixelformats, &count);
227 ok(hr == S_OK, "GetPixelFormats failed, hr=%lx\n", hr);
228 ok((count == 1) || broken(IsEqualCLSID(test->clsid, &CLSID_WICIcoDecoder) && count == 0) /* WinXP */,
229 "%u: got %d formats\n", i, num_formats);
230 ok(is_pixelformat(&pixelformats[0]), "got invalid pixel format\n");
231
232 count = 0xdeadbeef;
233 hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, num_formats, pixelformats, &count);
234 ok(hr == S_OK, "GetPixelFormats failed, hr=%lx\n", hr);
235 ok(count == num_formats, "got %d formats, expected %d\n", count, num_formats);
236 for (j = 0; j < num_formats; j++)
237 ok(is_pixelformat(&pixelformats[j]), "got invalid pixel format\n");
238
239 hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, num_formats, pixelformats, NULL);
240 ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%lx\n", hr);
241
242 count = 0xdeadbeef;
243 hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, ARRAY_SIZE(pixelformats),
245 ok(hr == S_OK, "GetPixelFormats failed, hr=%lx\n", hr);
246 ok(count == num_formats, "got %d formats, expected %d\n", count, num_formats);
247
248 hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 0, NULL, NULL);
249 ok(hr == E_INVALIDARG, "GetFileExtensions failed, hr=%lx\n", hr);
250
251 hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 1, NULL, &len);
252 ok(hr == E_INVALIDARG, "GetFileExtensions failed, hr=%lx\n", hr);
253 todo_wine_if(test->todo && !IsEqualCLSID(test->clsid, &CLSID_WICTiffDecoder))
254 ok(len == lstrlenW(extensionsW) + 1, "%u: GetFileExtensions returned wrong len %i\n", i, len);
255
256 hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, len, value, NULL);
257 ok(hr == E_INVALIDARG, "GetFileExtensions failed, hr=%lx\n", hr);
258
259 hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 0, NULL, &len);
260 ok(hr == S_OK, "GetFileExtensions failed, hr=%lx\n", hr);
261 todo_wine_if(test->todo && !IsEqualCLSID(test->clsid, &CLSID_WICTiffDecoder))
262 ok(len == lstrlenW(extensionsW) + 1, "GetFileExtensions returned wrong len %i\n", len);
263
264 value[0] = 0;
265 hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, len, value, &len);
266 ok(hr == S_OK, "GetFileExtensions failed, hr=%lx\n", hr);
267 todo_wine_if(test->todo)
268 ok(lstrcmpW(value, extensionsW) == 0, "GetFileExtensions returned wrong value %s\n", wine_dbgstr_w(value));
269 todo_wine_if(test->todo && !IsEqualCLSID(test->clsid, &CLSID_WICTiffDecoder))
270 ok(len == lstrlenW(extensionsW) + 1, "GetFileExtensions returned wrong len %i\n", len);
271
272 hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 1, value, &len);
273 ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "GetFileExtensions failed, hr=%lx\n", hr);
274 todo_wine_if(test->todo && !IsEqualCLSID(test->clsid, &CLSID_WICTiffDecoder))
275 ok(len == lstrlenW(extensionsW) + 1, "GetFileExtensions returned wrong len %i\n", len);
276
277 hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 256, value, &len);
278 ok(hr == S_OK, "GetFileExtensions failed, hr=%lx\n", hr);
279 todo_wine_if(test->todo)
280 ok(lstrcmpW(value, extensionsW) == 0, "GetFileExtensions returned wrong value %s\n", wine_dbgstr_w(value));
281 todo_wine_if(test->todo && !IsEqualCLSID(test->clsid, &CLSID_WICTiffDecoder))
282 ok(len == lstrlenW(extensionsW) + 1, "GetFileExtensions returned wrong len %i\n", len);
283
284 IWICBitmapDecoderInfo_Release(decoder_info);
285 IWICComponentInfo_Release(info);
286 }
287}
288
289static void test_pixelformat_info(void)
290{
292 IWICPixelFormatInfo *pixelformat_info;
293 IWICPixelFormatInfo2 *pixelformat_info2;
294 HRESULT hr;
295 UINT len, known_len;
296 WCHAR value[256];
297 GUID guid;
298 WICComponentType componenttype;
299 WICPixelFormatNumericRepresentation numericrepresentation;
300 DWORD signing;
301 UINT uiresult;
302 BYTE abbuffer[256];
303 BOOL supportstransparency;
304
305 hr = get_component_info(&GUID_WICPixelFormat32bppBGRA, &info);
306 ok(hr == S_OK, "CreateComponentInfo failed, hr=%lx\n", hr);
307
308 if (FAILED(hr))
309 return;
310
311 hr = IWICComponentInfo_GetAuthor(info, 0, NULL, 0);
312 ok(hr == E_INVALIDARG, "GetAuthor failed, hr=%lx\n", hr);
313
314 len = 0xdeadbeef;
315 hr = IWICComponentInfo_GetAuthor(info, 0, NULL, &len);
316 ok(hr == S_OK, "GetAuthor failed, hr=%lx\n", hr);
317 ok(len < 255 && len > 0, "invalid length 0x%x\n", len);
318 known_len = len;
319
320 memset(value, 0xaa, 256 * sizeof(WCHAR));
321 hr = IWICComponentInfo_GetAuthor(info, len-1, value, NULL);
322 ok(hr == E_INVALIDARG, "GetAuthor failed, hr=%lx\n", hr);
323 ok(value[0] == 0xaaaa, "string modified\n");
324
325 len = 0xdeadbeef;
326 memset(value, 0xaa, 256 * sizeof(WCHAR));
327 hr = IWICComponentInfo_GetAuthor(info, known_len-1, value, &len);
328 ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "GetAuthor failed, hr=%lx\n", hr);
329 ok(len == known_len, "got length of 0x%x, expected 0x%x\n", len, known_len);
330 ok(value[known_len-1] == 0xaaaa, "string modified past given length\n");
331 ok(value[0] == 0xaaaa, "string modified\n");
332
333 len = 0xdeadbeef;
334 memset(value, 0xaa, 256 * sizeof(WCHAR));
335 hr = IWICComponentInfo_GetAuthor(info, known_len, value, &len);
336 ok(hr == S_OK, "GetAuthor failed, hr=%lx\n", hr);
337 ok(len == known_len, "got length of 0x%x, expected 0x%x\n", len, known_len);
338 ok(value[known_len-1] == 0, "string not terminated at expected length\n");
339 ok(value[known_len-2] != 0xaaaa, "string not modified at given length\n");
340
341 len = 0xdeadbeef;
342 memset(value, 0xaa, 256 * sizeof(WCHAR));
343 hr = IWICComponentInfo_GetAuthor(info, known_len+1, value, &len);
344 ok(hr == S_OK, "GetAuthor failed, hr=%lx\n", hr);
345 ok(len == known_len, "got length of 0x%x, expected 0x%x\n", len, known_len);
346 ok(value[known_len] == 0xaaaa, "string modified past end\n");
347 ok(value[known_len-1] == 0, "string not terminated at expected length\n");
348 ok(value[known_len-2] != 0xaaaa, "string not modified at given length\n");
349
350 hr = IWICComponentInfo_GetCLSID(info, NULL);
351 ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%lx\n", hr);
352
353 memset(&guid, 0xaa, sizeof(guid));
354 hr = IWICComponentInfo_GetCLSID(info, &guid);
355 ok(hr == S_OK, "GetCLSID failed, hr=%lx\n", hr);
356 ok(IsEqualGUID(&guid, &GUID_WICPixelFormat32bppBGRA), "unexpected CLSID %s\n", wine_dbgstr_guid(&guid));
357
358 hr = IWICComponentInfo_GetComponentType(info, NULL);
359 ok(hr == E_INVALIDARG, "GetComponentType failed, hr=%lx\n", hr);
360
361 hr = IWICComponentInfo_GetComponentType(info, &componenttype);
362 ok(hr == S_OK, "GetComponentType failed, hr=%lx\n", hr);
363 ok(componenttype == WICPixelFormat, "unexpected component type 0x%x\n", componenttype);
364
365 len = 0xdeadbeef;
366 hr = IWICComponentInfo_GetFriendlyName(info, 0, NULL, &len);
367 ok(hr == S_OK, "GetFriendlyName failed, hr=%lx\n", hr);
368 ok(len < 255 && len > 0, "invalid length 0x%x\n", len);
369
370 hr = IWICComponentInfo_GetSigningStatus(info, NULL);
371 ok(hr == E_INVALIDARG, "GetSigningStatus failed, hr=%lx\n", hr);
372
373 hr = IWICComponentInfo_GetSigningStatus(info, &signing);
374 ok(hr == S_OK, "GetSigningStatus failed, hr=%lx\n", hr);
375 ok(signing == WICComponentSigned, "unexpected signing status 0x%lx\n", signing);
376
377 len = 0xdeadbeef;
378 hr = IWICComponentInfo_GetSpecVersion(info, 0, NULL, &len);
379 ok(hr == S_OK, "GetSpecVersion failed, hr=%lx\n", hr);
380 ok(len == 0, "invalid length 0x%x\n", len); /* spec version does not apply to pixel formats */
381
382 memset(&guid, 0xaa, sizeof(guid));
383 hr = IWICComponentInfo_GetVendorGUID(info, &guid);
384 ok(hr == S_OK, "GetVendorGUID failed, hr=%lx\n", hr);
385 ok(IsEqualGUID(&guid, &GUID_VendorMicrosoft) ||
386 broken(IsEqualGUID(&guid, &GUID_NULL)) /* XP */, "unexpected GUID %s\n", wine_dbgstr_guid(&guid));
387
388 len = 0xdeadbeef;
389 hr = IWICComponentInfo_GetVersion(info, 0, NULL, &len);
390 ok(hr == S_OK, "GetVersion failed, hr=%lx\n", hr);
391 ok(len == 0, "invalid length 0x%x\n", len); /* version does not apply to pixel formats */
392
393 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo, (void**)&pixelformat_info);
394 ok(hr == S_OK, "QueryInterface failed, hr=%lx\n", hr);
395
396 if (SUCCEEDED(hr))
397 {
398 hr = IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info, NULL);
399 ok(hr == E_INVALIDARG, "GetBitsPerPixel failed, hr=%lx\n", hr);
400
401 hr = IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info, &uiresult);
402 ok(hr == S_OK, "GetBitsPerPixel failed, hr=%lx\n", hr);
403 ok(uiresult == 32, "unexpected bpp %i\n", uiresult);
404
405 hr = IWICPixelFormatInfo_GetChannelCount(pixelformat_info, &uiresult);
406 ok(hr == S_OK, "GetChannelCount failed, hr=%lx\n", hr);
407 ok(uiresult == 4, "unexpected channel count %i\n", uiresult);
408
409 hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 0, NULL, NULL);
410 ok(hr == E_INVALIDARG, "GetChannelMask failed, hr=%lx\n", hr);
411
412 uiresult = 0xdeadbeef;
413 hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 0, NULL, &uiresult);
414 ok(hr == S_OK, "GetChannelMask failed, hr=%lx\n", hr);
415 ok(uiresult == 4, "unexpected length %i\n", uiresult);
416
417 memset(abbuffer, 0xaa, sizeof(abbuffer));
418 hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, known_len, abbuffer, NULL);
419 ok(hr == E_INVALIDARG, "GetChannelMask failed, hr=%lx\n", hr);
420 ok(abbuffer[0] == 0xaa, "buffer modified\n");
421
422 uiresult = 0xdeadbeef;
423 memset(abbuffer, 0xaa, sizeof(abbuffer));
424 hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 3, abbuffer, &uiresult);
425 ok(hr == E_INVALIDARG, "GetChannelMask failed, hr=%lx\n", hr);
426 ok(abbuffer[0] == 0xaa, "buffer modified\n");
427 ok(uiresult == 4, "unexpected length %i\n", uiresult);
428
429 memset(abbuffer, 0xaa, sizeof(abbuffer));
430 hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 4, abbuffer, &uiresult);
431 ok(hr == S_OK, "GetChannelMask failed, hr=%lx\n", hr);
432 ok(*((ULONG*)abbuffer) == 0xff, "unexpected mask 0x%lx\n", *((ULONG*)abbuffer));
433 ok(uiresult == 4, "unexpected length %i\n", uiresult);
434
435 memset(abbuffer, 0xaa, sizeof(abbuffer));
436 hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 5, abbuffer, &uiresult);
437 ok(hr == S_OK, "GetChannelMask failed, hr=%lx\n", hr);
438 ok(*((ULONG*)abbuffer) == 0xff, "unexpected mask 0x%lx\n", *((ULONG*)abbuffer));
439 ok(abbuffer[4] == 0xaa, "buffer modified past actual length\n");
440 ok(uiresult == 4, "unexpected length %i\n", uiresult);
441
442 memset(&guid, 0xaa, sizeof(guid));
443 hr = IWICPixelFormatInfo_GetFormatGUID(pixelformat_info, &guid);
444 ok(hr == S_OK, "GetFormatGUID failed, hr=%lx\n", hr);
445 ok(IsEqualGUID(&guid, &GUID_WICPixelFormat32bppBGRA), "unexpected GUID %s\n", wine_dbgstr_guid(&guid));
446
447 IWICPixelFormatInfo_Release(pixelformat_info);
448 }
449
450 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo2, (void**)&pixelformat_info2);
451
452 if (FAILED(hr))
453 win_skip("IWICPixelFormatInfo2 not supported\n");
454 else
455 {
456 hr = IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2, NULL);
457 ok(hr == E_INVALIDARG, "GetNumericRepresentation failed, hr=%lx\n", hr);
458
459 numericrepresentation = 0xdeadbeef;
460 hr = IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2, &numericrepresentation);
461 ok(hr == S_OK, "GetNumericRepresentation failed, hr=%lx\n", hr);
462 ok(numericrepresentation == WICPixelFormatNumericRepresentationUnsignedInteger, "unexpected numeric representation %i\n", numericrepresentation);
463
464 hr = IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2, NULL);
465 ok(hr == E_INVALIDARG, "SupportsTransparency failed, hr=%lx\n", hr);
466
467 supportstransparency = 0xdeadbeef;
468 hr = IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2, &supportstransparency);
469 ok(hr == S_OK, "SupportsTransparency failed, hr=%lx\n", hr);
470 ok(supportstransparency == 1, "unexpected value %i\n", supportstransparency);
471
472 IWICPixelFormatInfo2_Release(pixelformat_info2);
473 }
474
475 IWICComponentInfo_Release(info);
476}
477
479{
481 HRESULT hr;
482
484
485 hr = get_component_info(&CLSID_WICUnknownMetadataReader, &info);
486 ok(hr == S_OK, "CreateComponentInfo failed, hr=%lx\n", hr);
487 ok(info == arg, "unexpected info pointer %p\n", info);
488 IWICComponentInfo_Release(info);
489
491 return 0;
492}
493
494static void test_reader_info(void)
495{
497 IWICComponentInfo *info, *info2;
498 IWICMetadataReaderInfo *reader_info;
499 HRESULT hr;
500 CLSID clsid;
501 GUID container_formats[10];
502 UINT count, size;
503 DWORD tid;
505 WICMetadataPattern *patterns;
506
507 hr = get_component_info(&CLSID_WICUnknownMetadataReader, &info2);
508 ok(hr == S_OK, "CreateComponentInfo failed, hr=%lx\n", hr);
509 IWICComponentInfo_Release(info2);
510
511 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
512 &IID_IWICImagingFactory, (void**)&factory);
513 ok(hr == S_OK, "CoCreateInstance failed, hr=%lx\n", hr);
514 if (FAILED(hr)) return;
515
516 hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICUnknownMetadataReader, &info);
517 ok(hr == S_OK, "CreateComponentInfo failed, hr=%lx\n", hr);
518 ok(info == info2, "info != info2\n");
519
523
524 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
525 ok(hr == S_OK, "QueryInterface failed, hr=%lx\n", hr);
526
527 hr = IWICMetadataReaderInfo_GetCLSID(reader_info, NULL);
528 ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%lx\n", hr);
529
530 hr = IWICMetadataReaderInfo_GetCLSID(reader_info, &clsid);
531 ok(hr == S_OK, "GetCLSID failed, hr=%lx\n", hr);
532 ok(IsEqualGUID(&CLSID_WICUnknownMetadataReader, &clsid), "GetCLSID returned wrong result\n");
533
534 hr = IWICMetadataReaderInfo_GetMetadataFormat(reader_info, &clsid);
535 ok(hr == S_OK, "GetMetadataFormat failed, hr=%lx\n", hr);
536 ok(IsEqualGUID(&GUID_MetadataFormatUnknown, &clsid), "GetMetadataFormat returned wrong result\n");
537
538 hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, NULL);
539 ok(hr == E_INVALIDARG, "GetContainerFormats failed, hr=%lx\n", hr);
540
541 count = 0xdeadbeef;
542 hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, &count);
543 ok(hr == S_OK, "GetContainerFormats failed, hr=%lx\n", hr);
544 ok(count == 0, "unexpected count %d\n", count);
545
546 hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
547 0, NULL, NULL, NULL);
548 ok(hr == E_INVALIDARG, "GetPatterns failed, hr=%lx\n", hr);
549
550 count = size = 0xdeadbeef;
551 hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
552 0, NULL, &count, &size);
553 ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND || broken(hr == S_OK) /* Windows XP */,
554 "GetPatterns failed, hr=%lx\n", hr);
555 ok(count == 0xdeadbeef, "unexpected count %d\n", count);
556 ok(size == 0xdeadbeef, "unexpected size %d\n", size);
557
558 IWICMetadataReaderInfo_Release(reader_info);
559
560 IWICComponentInfo_Release(info);
561
562 hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICXMPStructMetadataReader, &info);
564 ok(hr == S_OK, "CreateComponentInfo failed, hr=%lx\n", hr);
565
566 if (FAILED(hr))
567 {
568 IWICImagingFactory_Release(factory);
569 return;
570 }
571
572 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
573 ok(hr == S_OK, "QueryInterface failed, hr=%lx\n", hr);
574
575 hr = IWICMetadataReaderInfo_GetCLSID(reader_info, NULL);
576 ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%lx\n", hr);
577
578 hr = IWICMetadataReaderInfo_GetCLSID(reader_info, &clsid);
579 ok(hr == S_OK, "GetCLSID failed, hr=%lx\n", hr);
580 ok(IsEqualGUID(&CLSID_WICXMPStructMetadataReader, &clsid), "GetCLSID returned wrong result\n");
581
582 hr = IWICMetadataReaderInfo_GetMetadataFormat(reader_info, &clsid);
583 ok(hr == S_OK, "GetMetadataFormat failed, hr=%lx\n", hr);
584 ok(IsEqualGUID(&GUID_MetadataFormatXMPStruct, &clsid), "GetMetadataFormat returned wrong result\n");
585
586 hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, NULL);
587 ok(hr == E_INVALIDARG, "GetContainerFormats failed, hr=%lx\n", hr);
588
589 count = 0xdeadbeef;
590 hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, &count);
591 ok(hr == S_OK, "GetContainerFormats failed, hr=%lx\n", hr);
592 ok(count >= 2, "unexpected count %d\n", count);
593
594 count = 0xdeadbeef;
595 hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 1, container_formats, &count);
596 ok(hr == S_OK, "GetContainerFormats failed, hr=%lx\n", hr);
597 ok(count == 1, "unexpected count %d\n", count);
598
599 count = 0xdeadbeef;
600 hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 10, container_formats, &count);
601 ok(hr == S_OK, "GetContainerFormats failed, hr=%lx\n", hr);
602 ok(count == min(count, 10), "unexpected count %d\n", count);
603
604 count = size = 0xdeadbeef;
605 hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
606 0, NULL, &count, &size);
607 ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND || broken(hr == S_OK) /* Windows XP */,
608 "GetPatterns failed, hr=%lx\n", hr);
609 ok(count == 0xdeadbeef, "unexpected count %d\n", count);
610 ok(size == 0xdeadbeef, "unexpected size %d\n", size);
611
612 count = size = 0xdeadbeef;
613 hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
614 0, NULL, &count, &size);
615 ok(hr == S_OK, "GetPatterns failed, hr=%lx\n", hr);
616 ok(count == 1, "unexpected count %d\n", count);
617 ok(size > sizeof(WICMetadataPattern), "unexpected size %d\n", size);
618
619 if (hr == S_OK)
620 {
621 patterns = HeapAlloc(GetProcessHeap(), 0, size);
622
623 count = size = 0xdeadbeef;
624 hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
625 size-1, patterns, &count, &size);
626 ok(hr == S_OK, "GetPatterns failed, hr=%lx\n", hr);
627 ok(count == 1, "unexpected count %d\n", count);
628 ok(size > sizeof(WICMetadataPattern), "unexpected size %d\n", size);
629
630 count = size = 0xdeadbeef;
631 hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
632 size, patterns, &count, &size);
633 ok(hr == S_OK, "GetPatterns failed, hr=%lx\n", hr);
634 ok(count == 1, "unexpected count %d\n", count);
635 ok(size == sizeof(WICMetadataPattern) + patterns->Length * 2, "unexpected size %d\n", size);
636
637 HeapFree(GetProcessHeap(), 0, patterns);
638 }
639
640 IWICMetadataReaderInfo_Release(reader_info);
641
642 IWICComponentInfo_Release(info);
643
644 IWICImagingFactory_Release(factory);
645}
646
648{
649 IWICComponentFactory *component_factory;
650 IWICImagingFactory2 *factory2;
652 HRESULT hr;
653
654 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
655 &IID_IWICImagingFactory2, (void **)&factory2);
656 if (FAILED(hr))
657 {
658 win_skip("IWICImagingFactory2 is not supported.\n");
659 return;
660 }
661
662 hr = IWICImagingFactory2_QueryInterface(factory2, &IID_IWICComponentFactory, (void **)&component_factory);
663 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
664
665 hr = IWICComponentFactory_QueryInterface(component_factory, &IID_IWICImagingFactory, (void **)&factory);
666 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
667 ok(factory == (IWICImagingFactory *)component_factory, "Unexpected factory pointer.\n");
668 IWICImagingFactory_Release(factory);
669
670 hr = IWICImagingFactory2_QueryInterface(factory2, &IID_IWICImagingFactory, (void **)&factory);
671 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
672 ok(factory == (IWICImagingFactory *)component_factory, "Unexpected factory pointer.\n");
673
674 IWICComponentFactory_Release(component_factory);
675 IWICImagingFactory2_Release(factory2);
676 IWICImagingFactory_Release(factory);
677}
678
680{
681 static const unsigned int types[] =
682 {
688 };
690 IEnumUnknown *enumerator;
691 unsigned int i;
692 IUnknown *item;
693 HRESULT hr;
694
695 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
696 &IID_IWICImagingFactory, (void **)&factory);
697 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
698
699 for (i = 0; i < ARRAY_SIZE(types); ++i)
700 {
701 hr = IWICImagingFactory_CreateComponentEnumerator(factory, types[i], 0, &enumerator);
702 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
703
704 hr = IEnumUnknown_Next(enumerator, 1, &item, NULL);
705 ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
706 IUnknown_Release(item);
707
708 IEnumUnknown_Release(enumerator);
709 }
710
711 IWICImagingFactory_Release(factory);
712}
713
715{
717
723
725}
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
static HANDLE thread
Definition: service.c:33
DDPIXELFORMAT pixelformats[]
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrlenW
Definition: compat.h:750
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4243
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint64EXT * result
Definition: glext.h:11304
GLenum GLsizei len
Definition: glext.h:6722
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define wine_dbgstr_w
Definition: kernel32.h:34
#define GUID_NULL
Definition: ks.h:106
const GUID * guid
BOOL todo
Definition: filedlg.c:313
static TfClientId tid
#define todo_wine_if(is_todo)
Definition: custom.c:86
#define todo_wine
Definition: custom.c:89
static ATOM item
Definition: dde.c:856
static void test_component_enumerator(void)
Definition: info.c:679
static void test_imagingfactory_interfaces(void)
Definition: info.c:647
static DWORD WINAPI cache_across_threads_test(void *arg)
Definition: info.c:478
static void test_decoder_info(void)
Definition: info.c:65
static void test_pixelformat_info(void)
Definition: info.c:289
static HRESULT get_component_info(const GUID *clsid, IWICComponentInfo **result)
Definition: info.c:31
static BOOL is_pixelformat(GUID *format)
Definition: info.c:48
static void test_reader_info(void)
Definition: info.c:494
#define min(a, b)
Definition: monoChain.cc:55
REFCLSID clsid
Definition: msctf.c:82
unsigned int UINT
Definition: ndis.h:50
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
#define test
Definition: rosglue.h:37
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
#define win_skip
Definition: test.h:164
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
Definition: main.c:439
Definition: format.c:58
Definition: cmds.c:130
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:94
@ WICComponentSigned
Definition: wincodec.idl:136
WICPixelFormatNumericRepresentation
Definition: wincodec.idl:158
@ WICPixelFormatNumericRepresentationUnsignedInteger
Definition: wincodec.idl:161
WICComponentType
Definition: wincodec.idl:125
@ WICDecoder
Definition: wincodec.idl:126
@ WICPixelFormatConverter
Definition: wincodec.idl:128
@ WICMetadataReader
Definition: wincodec.idl:129
@ WICEncoder
Definition: wincodec.idl:127
@ WICPixelFormat
Definition: wincodec.idl:131
#define WINAPI
Definition: msvc.h:6
#define WINCODEC_ERR_COMPONENTNOTFOUND
Definition: winerror.h:3296
#define E_NOINTERFACE
Definition: winerror.h:2364
#define WINCODEC_ERR_INSUFFICIENTBUFFER
Definition: winerror.h:3311
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193