2 * Copyright 2011 Vincent Povirk for CodeWeavers
3 * Copyright 2012 Dmitry Timoshkov
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wincodecsdk.h"
31 #include "wine/test.h"
33 #define expect_blob(propvar, data, length) do { \
34 ok((propvar).vt == VT_BLOB, "unexpected vt: %i\n", (propvar).vt); \
35 if ((propvar).vt == VT_BLOB) { \
36 ok(U(propvar).blob.cbSize == (length), "expected size %u, got %u\n", (ULONG)(length), U(propvar).blob.cbSize); \
37 if (U(propvar).blob.cbSize == (length)) { \
38 ok(!memcmp(U(propvar).blob.pBlobData, (data), (length)), "unexpected data\n"); \
47 #define IFD_RATIONAL 5
49 #define IFD_UNDEFINED 7
52 #define IFD_SRATIONAL 10
72 static const struct ifd_data
74 USHORT number_of_entries
;
75 struct IFD_entry entry
[40];
77 struct IFD_rational xres
;
79 struct IFD_rational srational_val
;
84 struct IFD_rational rational
[3];
89 { 0xfe, IFD_SHORT
, 1, 1 }, /* NEWSUBFILETYPE */
90 { 0x100, IFD_LONG
, 1, 222 }, /* IMAGEWIDTH */
91 { 0x101, IFD_LONG
, 1, 333 }, /* IMAGELENGTH */
92 { 0x102, IFD_SHORT
, 1, 24 }, /* BITSPERSAMPLE */
93 { 0x103, IFD_LONG
, 1, 32773 }, /* COMPRESSION: packbits */
94 { 0x11a, IFD_RATIONAL
, 1, FIELD_OFFSET(struct ifd_data
, xres
) },
95 { 0xf001, IFD_BYTE
, 1, 0x11223344 },
96 { 0xf002, IFD_BYTE
, 4, 0x11223344 },
97 { 0xf003, IFD_SBYTE
, 1, 0x11223344 },
98 { 0xf004, IFD_SSHORT
, 1, 0x11223344 },
99 { 0xf005, IFD_SSHORT
, 2, 0x11223344 },
100 { 0xf006, IFD_SLONG
, 1, 0x11223344 },
101 { 0xf007, IFD_FLOAT
, 1, 0x11223344 },
102 { 0xf008, IFD_DOUBLE
, 1, FIELD_OFFSET(struct ifd_data
, double_val
) },
103 { 0xf009, IFD_SRATIONAL
, 1, FIELD_OFFSET(struct ifd_data
, srational_val
) },
104 { 0xf00a, IFD_BYTE
, 13, FIELD_OFFSET(struct ifd_data
, string
) },
105 { 0xf00b, IFD_SSHORT
, 4, FIELD_OFFSET(struct ifd_data
, short_val
) },
106 { 0xf00c, IFD_SLONG
, 2, FIELD_OFFSET(struct ifd_data
, long_val
) },
107 { 0xf00d, IFD_FLOAT
, 2, FIELD_OFFSET(struct ifd_data
, float_val
) },
108 { 0xf00e, IFD_ASCII
, 13, FIELD_OFFSET(struct ifd_data
, string
) },
109 { 0xf00f, IFD_ASCII
, 4, 'a' | 'b' << 8 | 'c' << 16 | 'd' << 24 },
110 { 0xf010, IFD_UNDEFINED
, 13, FIELD_OFFSET(struct ifd_data
, string
) },
111 { 0xf011, IFD_UNDEFINED
, 4, 'a' | 'b' << 8 | 'c' << 16 | 'd' << 24 },
112 { 0xf012, IFD_BYTE
, 0, 0x11223344 },
113 { 0xf013, IFD_SHORT
, 0, 0x11223344 },
114 { 0xf014, IFD_LONG
, 0, 0x11223344 },
115 { 0xf015, IFD_FLOAT
, 0, 0x11223344 },
116 { 0xf016, IFD_SRATIONAL
, 3, FIELD_OFFSET(struct ifd_data
, rational
) },
120 1234567890.0987654321,
121 { 0x1a2b3c4d, 0x5a6b7c8d },
123 { 0x0101, 0x0202, 0x0303, 0x0404 },
124 { 0x11223344, 0x55667788 },
125 { (FLOAT
)1234.5678, (FLOAT
)8765.4321 },
126 { { 0x01020304, 0x05060708 }, { 0x10203040, 0x50607080 }, { 0x11223344, 0x55667788 } },
130 static const char metadata_unknown
[] = "lalala";
132 static const char metadata_tEXt
[] = {
133 0,0,0,14, /* chunk length */
134 't','E','X','t', /* chunk type */
135 'w','i','n','e','t','e','s','t',0, /* keyword */
136 'v','a','l','u','e', /* text */
137 0x3f,0x64,0x19,0xf3 /* chunk CRC */
140 static const char pngimage
[285] = {
141 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
142 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,
143 0xde,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,
144 0x13,0x01,0x00,0x9a,0x9c,0x18,0x00,0x00,0x00,0x07,0x74,0x49,0x4d,0x45,0x07,0xd5,
145 0x06,0x03,0x0f,0x07,0x2d,0x12,0x10,0xf0,0xfd,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,
146 0x54,0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,
147 0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
151 static const char gifimage
[35] = {
152 0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
153 0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
157 /* 1x1 pixel gif, 2 frames; first frame is white, second is black */
158 static const char animatedgif
[] = {
159 'G','I','F','8','9','a',0x01,0x00,0x01,0x00,0xA1,0x00,0x00,
160 0x6F,0x6F,0x6F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
161 /*0x21,0xFF,0x0B,'N','E','T','S','C','A','P','E','2','.','0',*/
162 0x21,0xFF,0x0B,'A','N','I','M','E','X','T','S','1','.','0',
163 0x03,0x01,0x05,0x00,0x00,
164 0x21,0xFE,0x0C,'H','e','l','l','o',' ','W','o','r','l','d','!',0x00,
165 0x21,0x01,0x0D,'a','n','i','m','a','t','i','o','n','.','g','i','f',0x00,
166 0x21,0xF9,0x04,0x00,0x0A,0x00,0xFF,0x00,0x2C,
167 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
168 0xDE,0xDE,0xDE,0x00,0x00,0x00,
169 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x4C,0x01,0x00,
170 0x21,0xFE,0x08,'i','m','a','g','e',' ','#','1',0x00,
171 0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','1',0x00,
172 0x21,0xF9,0x04,0x01,0x0A,0x00,0x01,0x00,0x2C,
173 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
174 0x4D,0x4D,0x4D,0x00,0x00,0x00,
175 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x44,0x01,0x00,
176 0x21,0xFE,0x08,'i','m','a','g','e',' ','#','2',0x00,
177 0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','2',0x00,0x3B
180 static IStream
*create_stream(const char *data
, int data_size
)
187 hdata
= GlobalAlloc(GMEM_MOVEABLE
, data_size
);
188 ok(hdata
!= 0, "GlobalAlloc failed\n");
189 if (!hdata
) return NULL
;
191 locked_data
= GlobalLock(hdata
);
192 memcpy(locked_data
, data
, data_size
);
195 hr
= CreateStreamOnHGlobal(hdata
, TRUE
, &stream
);
196 ok(hr
== S_OK
, "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
201 static void load_stream(IUnknown
*reader
, const char *data
, int data_size
, DWORD persist_options
)
204 IWICPersistStream
*persist
;
207 ULARGE_INTEGER cur_pos
;
209 stream
= create_stream(data
, data_size
);
213 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void**)&persist
);
214 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
218 hr
= IWICPersistStream_LoadEx(persist
, stream
, NULL
, persist_options
);
219 ok(hr
== S_OK
, "LoadEx failed, hr=%x\n", hr
);
221 IWICPersistStream_Release(persist
);
225 hr
= IStream_Seek(stream
, pos
, SEEK_CUR
, &cur_pos
);
226 ok(hr
== S_OK
, "IStream_Seek error %#x\n", hr
);
227 /* IFD metadata reader doesn't rewind the stream to the start */
228 ok(cur_pos
.QuadPart
== 0 || cur_pos
.QuadPart
<= data_size
,
229 "current stream pos is at %x/%x, data size %x\n", cur_pos
.u
.LowPart
, cur_pos
.u
.HighPart
, data_size
);
231 IStream_Release(stream
);
234 static void test_metadata_unknown(void)
237 IWICMetadataReader
*reader
;
238 IWICEnumMetadataItem
*enumerator
;
239 IWICMetadataBlockReader
*blockreader
;
240 PROPVARIANT schema
, id
, value
;
241 ULONG items_returned
;
243 hr
= CoCreateInstance(&CLSID_WICUnknownMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
244 &IID_IWICMetadataReader
, (void**)&reader
);
245 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
246 if (FAILED(hr
)) return;
248 load_stream((IUnknown
*)reader
, metadata_unknown
, sizeof(metadata_unknown
), WICPersistOptionsDefault
);
250 hr
= IWICMetadataReader_GetEnumerator(reader
, &enumerator
);
251 ok(hr
== S_OK
, "GetEnumerator failed, hr=%x\n", hr
);
255 PropVariantInit(&schema
);
256 PropVariantInit(&id
);
257 PropVariantInit(&value
);
259 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
260 ok(hr
== S_OK
, "Next failed, hr=%x\n", hr
);
261 ok(items_returned
== 1, "unexpected item count %i\n", items_returned
);
263 if (hr
== S_OK
&& items_returned
== 1)
265 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %i\n", schema
.vt
);
266 ok(id
.vt
== VT_EMPTY
, "unexpected vt: %i\n", id
.vt
);
267 expect_blob(value
, metadata_unknown
, sizeof(metadata_unknown
));
269 PropVariantClear(&schema
);
270 PropVariantClear(&id
);
271 PropVariantClear(&value
);
274 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
275 ok(hr
== S_FALSE
, "Next failed, hr=%x\n", hr
);
276 ok(items_returned
== 0, "unexpected item count %i\n", items_returned
);
278 IWICEnumMetadataItem_Release(enumerator
);
281 hr
= IWICMetadataReader_QueryInterface(reader
, &IID_IWICMetadataBlockReader
, (void**)&blockreader
);
282 ok(hr
== E_NOINTERFACE
, "QueryInterface failed, hr=%x\n", hr
);
285 IWICMetadataBlockReader_Release(blockreader
);
287 IWICMetadataReader_Release(reader
);
290 static void test_metadata_tEXt(void)
293 IWICMetadataReader
*reader
;
294 IWICEnumMetadataItem
*enumerator
;
295 PROPVARIANT schema
, id
, value
;
296 ULONG items_returned
, count
;
299 PropVariantInit(&schema
);
300 PropVariantInit(&id
);
301 PropVariantInit(&value
);
303 hr
= CoCreateInstance(&CLSID_WICPngTextMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
304 &IID_IWICMetadataReader
, (void**)&reader
);
305 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
306 if (FAILED(hr
)) return;
308 hr
= IWICMetadataReader_GetCount(reader
, NULL
);
309 ok(hr
== E_INVALIDARG
, "GetCount failed, hr=%x\n", hr
);
311 hr
= IWICMetadataReader_GetCount(reader
, &count
);
312 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
313 ok(count
== 0, "unexpected count %i\n", count
);
315 load_stream((IUnknown
*)reader
, metadata_tEXt
, sizeof(metadata_tEXt
), WICPersistOptionsDefault
);
317 hr
= IWICMetadataReader_GetCount(reader
, &count
);
318 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
319 ok(count
== 1, "unexpected count %i\n", count
);
321 hr
= IWICMetadataReader_GetEnumerator(reader
, NULL
);
322 ok(hr
== E_INVALIDARG
, "GetEnumerator failed, hr=%x\n", hr
);
324 hr
= IWICMetadataReader_GetEnumerator(reader
, &enumerator
);
325 ok(hr
== S_OK
, "GetEnumerator failed, hr=%x\n", hr
);
329 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
330 ok(hr
== S_OK
, "Next failed, hr=%x\n", hr
);
331 ok(items_returned
== 1, "unexpected item count %i\n", items_returned
);
333 if (hr
== S_OK
&& items_returned
== 1)
335 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %i\n", schema
.vt
);
336 ok(id
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
337 ok(!strcmp(U(id
).pszVal
, "winetest"), "unexpected id: %s\n", U(id
).pszVal
);
338 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", value
.vt
);
339 ok(!strcmp(U(value
).pszVal
, "value"), "unexpected value: %s\n", U(value
).pszVal
);
341 PropVariantClear(&schema
);
342 PropVariantClear(&id
);
343 PropVariantClear(&value
);
346 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
347 ok(hr
== S_FALSE
, "Next failed, hr=%x\n", hr
);
348 ok(items_returned
== 0, "unexpected item count %i\n", items_returned
);
350 IWICEnumMetadataItem_Release(enumerator
);
353 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
354 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
355 ok(IsEqualGUID(&format
, &GUID_MetadataFormatChunktEXt
), "unexpected format %s\n", wine_dbgstr_guid(&format
));
357 hr
= IWICMetadataReader_GetMetadataFormat(reader
, NULL
);
358 ok(hr
== E_INVALIDARG
, "GetMetadataFormat failed, hr=%x\n", hr
);
361 U(id
).pszVal
= CoTaskMemAlloc(strlen("winetest") + 1);
362 strcpy(U(id
).pszVal
, "winetest");
364 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, NULL
);
365 ok(hr
== S_OK
, "GetValue failed, hr=%x\n", hr
);
367 hr
= IWICMetadataReader_GetValue(reader
, &schema
, NULL
, &value
);
368 ok(hr
== E_INVALIDARG
, "GetValue failed, hr=%x\n", hr
);
370 hr
= IWICMetadataReader_GetValue(reader
, &schema
, &id
, &value
);
371 ok(hr
== S_OK
, "GetValue failed, hr=%x\n", hr
);
372 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
373 ok(!strcmp(U(value
).pszVal
, "value"), "unexpected value: %s\n", U(value
).pszVal
);
374 PropVariantClear(&value
);
376 strcpy(U(id
).pszVal
, "test");
378 hr
= IWICMetadataReader_GetValue(reader
, &schema
, &id
, &value
);
379 ok(hr
== WINCODEC_ERR_PROPERTYNOTFOUND
, "GetValue failed, hr=%x\n", hr
);
381 PropVariantClear(&id
);
383 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, NULL
, NULL
);
384 ok(hr
== S_OK
, "GetValueByIndex failed, hr=%x\n", hr
);
386 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, &schema
, NULL
, NULL
);
387 ok(hr
== S_OK
, "GetValueByIndex failed, hr=%x\n", hr
);
388 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %i\n", schema
.vt
);
390 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, &id
, NULL
);
391 ok(hr
== S_OK
, "GetValueByIndex failed, hr=%x\n", hr
);
392 ok(id
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
393 ok(!strcmp(U(id
).pszVal
, "winetest"), "unexpected id: %s\n", U(id
).pszVal
);
394 PropVariantClear(&id
);
396 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, NULL
, &value
);
397 ok(hr
== S_OK
, "GetValueByIndex failed, hr=%x\n", hr
);
398 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", value
.vt
);
399 ok(!strcmp(U(value
).pszVal
, "value"), "unexpected value: %s\n", U(value
).pszVal
);
400 PropVariantClear(&value
);
402 hr
= IWICMetadataReader_GetValueByIndex(reader
, 1, NULL
, NULL
, NULL
);
403 ok(hr
== E_INVALIDARG
, "GetValueByIndex failed, hr=%x\n", hr
);
405 IWICMetadataReader_Release(reader
);
408 static inline USHORT
ushort_bswap(USHORT s
)
410 return (s
>> 8) | (s
<< 8);
413 static inline ULONG
ulong_bswap(ULONG l
)
415 return ((ULONG
)ushort_bswap((USHORT
)l
) << 16) | ushort_bswap((USHORT
)(l
>> 16));
418 static inline ULONGLONG
ulonglong_bswap(ULONGLONG ll
)
420 return ((ULONGLONG
)ulong_bswap((ULONG
)ll
) << 32) | ulong_bswap((ULONG
)(ll
>> 32));
423 static void byte_swap_ifd_data(char *data
)
425 USHORT number_of_entries
, i
;
426 struct IFD_entry
*entry
;
427 char *data_start
= data
;
429 number_of_entries
= *(USHORT
*)data
;
430 *(USHORT
*)data
= ushort_bswap(*(USHORT
*)data
);
431 data
+= sizeof(USHORT
);
433 for (i
= 0; i
< number_of_entries
; i
++)
435 entry
= (struct IFD_entry
*)data
;
443 if (entry
->count
> 4)
444 entry
->value
= ulong_bswap(entry
->value
);
449 if (entry
->count
> 2)
451 ULONG j
, count
= entry
->count
;
452 USHORT
*us
= (USHORT
*)(data_start
+ entry
->value
);
453 if (!count
) count
= 1;
454 for (j
= 0; j
< count
; j
++)
455 us
[j
] = ushort_bswap(us
[j
]);
457 entry
->value
= ulong_bswap(entry
->value
);
461 ULONG j
, count
= entry
->count
;
462 USHORT
*us
= (USHORT
*)&entry
->value
;
463 if (!count
) count
= 1;
464 for (j
= 0; j
< count
; j
++)
465 us
[j
] = ushort_bswap(us
[j
]);
472 if (entry
->count
> 1)
474 ULONG j
, count
= entry
->count
;
475 ULONG
*ul
= (ULONG
*)(data_start
+ entry
->value
);
476 if (!count
) count
= 1;
477 for (j
= 0; j
< count
; j
++)
478 ul
[j
] = ulong_bswap(ul
[j
]);
480 entry
->value
= ulong_bswap(entry
->value
);
487 ULONG
*ul
= (ULONG
*)(data_start
+ entry
->value
);
488 for (j
= 0; j
< entry
->count
* 2; j
++)
489 ul
[j
] = ulong_bswap(ul
[j
]);
491 entry
->value
= ulong_bswap(entry
->value
);
497 ULONGLONG
*ull
= (ULONGLONG
*)(data_start
+ entry
->value
);
498 for (j
= 0; j
< entry
->count
; j
++)
499 ull
[j
] = ulonglong_bswap(ull
[j
]);
501 entry
->value
= ulong_bswap(entry
->value
);
509 entry
->id
= ushort_bswap(entry
->id
);
510 entry
->type
= ushort_bswap(entry
->type
);
511 entry
->count
= ulong_bswap(entry
->count
);
512 data
+= sizeof(*entry
);
519 int count
; /* if VT_VECTOR */
522 const WCHAR id_string
[32];
525 static void compare_metadata(IWICMetadataReader
*reader
, const struct test_data
*td
, ULONG count
)
528 IWICEnumMetadataItem
*enumerator
;
529 PROPVARIANT schema
, id
, value
;
530 ULONG items_returned
, i
;
532 hr
= IWICMetadataReader_GetEnumerator(reader
, NULL
);
533 ok(hr
== E_INVALIDARG
, "GetEnumerator error %#x\n", hr
);
535 hr
= IWICMetadataReader_GetEnumerator(reader
, &enumerator
);
536 ok(hr
== S_OK
, "GetEnumerator error %#x\n", hr
);
538 PropVariantInit(&schema
);
539 PropVariantInit(&id
);
540 PropVariantInit(&value
);
542 for (i
= 0; i
< count
; i
++)
544 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
545 ok(hr
== S_OK
, "Next error %#x\n", hr
);
546 ok(items_returned
== 1, "unexpected item count %u\n", items_returned
);
548 ok(schema
.vt
== VT_EMPTY
, "%u: unexpected vt: %u\n", i
, schema
.vt
);
549 ok(id
.vt
== VT_UI2
|| id
.vt
== VT_LPWSTR
|| id
.vt
== VT_EMPTY
, "%u: unexpected vt: %u\n", i
, id
.vt
);
551 ok(U(id
).uiVal
== td
[i
].id
, "%u: expected id %#x, got %#x\n", i
, td
[i
].id
, U(id
).uiVal
);
552 else if (id
.vt
== VT_LPWSTR
)
553 ok(!lstrcmpW(td
[i
].id_string
, U(id
).pwszVal
),
554 "%u: expected %s, got %s\n", i
, wine_dbgstr_w(td
[i
].id_string
), wine_dbgstr_w(U(id
).pwszVal
));
556 ok(value
.vt
== td
[i
].type
, "%u: expected vt %#x, got %#x\n", i
, td
[i
].type
, value
.vt
);
557 if (value
.vt
& VT_VECTOR
)
560 switch (value
.vt
& ~VT_VECTOR
)
564 ok(td
[i
].count
== U(value
).caub
.cElems
, "%u: expected cElems %d, got %d\n", i
, td
[i
].count
, U(value
).caub
.cElems
);
565 for (j
= 0; j
< U(value
).caub
.cElems
; j
++)
566 ok(td
[i
].value
[j
] == U(value
).caub
.pElems
[j
], "%u: expected value[%d] %#x/%#x, got %#x\n", i
, j
, (ULONG
)td
[i
].value
[j
], (ULONG
)(td
[i
].value
[j
] >> 32), U(value
).caub
.pElems
[j
]);
570 ok(td
[i
].count
== U(value
).caui
.cElems
, "%u: expected cElems %d, got %d\n", i
, td
[i
].count
, U(value
).caui
.cElems
);
571 for (j
= 0; j
< U(value
).caui
.cElems
; j
++)
572 ok(td
[i
].value
[j
] == U(value
).caui
.pElems
[j
], "%u: expected value[%d] %#x/%#x, got %#x\n", i
, j
, (ULONG
)td
[i
].value
[j
], (ULONG
)(td
[i
].value
[j
] >> 32), U(value
).caui
.pElems
[j
]);
577 ok(td
[i
].count
== U(value
).caul
.cElems
, "%u: expected cElems %d, got %d\n", i
, td
[i
].count
, U(value
).caul
.cElems
);
578 for (j
= 0; j
< U(value
).caul
.cElems
; j
++)
579 ok(td
[i
].value
[j
] == U(value
).caul
.pElems
[j
], "%u: expected value[%d] %#x/%#x, got %#x\n", i
, j
, (ULONG
)td
[i
].value
[j
], (ULONG
)(td
[i
].value
[j
] >> 32), U(value
).caul
.pElems
[j
]);
584 ok(td
[i
].count
== U(value
).cauh
.cElems
, "%u: expected cElems %d, got %d\n", i
, td
[i
].count
, U(value
).cauh
.cElems
);
585 for (j
= 0; j
< U(value
).cauh
.cElems
; j
++)
586 ok(td
[i
].value
[j
] == U(value
).cauh
.pElems
[j
].QuadPart
, "%u: expected value[%d] %08x/%08x, got %08x/%08x\n", i
, j
, (ULONG
)td
[i
].value
[j
], (ULONG
)(td
[i
].value
[j
] >> 32), U(value
).cauh
.pElems
[j
].u
.LowPart
, U(value
).cauh
.pElems
[j
].u
.HighPart
);
589 ok(td
[i
].count
== U(value
).calpstr
.cElems
, "%u: expected cElems %d, got %d\n", i
, td
[i
].count
, U(value
).caub
.cElems
);
590 for (j
= 0; j
< U(value
).calpstr
.cElems
; j
++)
591 trace("%u: %s\n", j
, U(value
).calpstr
.pElems
[j
]);
592 /* fall through to not handled message */
594 ok(0, "%u: array of type %d is not handled\n", i
, value
.vt
& ~VT_VECTOR
);
598 else if (value
.vt
== VT_LPSTR
)
600 ok(td
[i
].count
== strlen(U(value
).pszVal
) ||
601 broken(td
[i
].count
== strlen(U(value
).pszVal
) + 1), /* before Win7 */
602 "%u: expected count %d, got %d\n", i
, td
[i
].count
, lstrlenA(U(value
).pszVal
));
603 if (td
[i
].count
== strlen(U(value
).pszVal
))
604 ok(!strcmp(td
[i
].string
, U(value
).pszVal
),
605 "%u: expected %s, got %s\n", i
, td
[i
].string
, U(value
).pszVal
);
607 else if (value
.vt
== VT_BLOB
)
609 ok(td
[i
].count
== U(value
).blob
.cbSize
, "%u: expected count %d, got %d\n", i
, td
[i
].count
, U(value
).blob
.cbSize
);
610 ok(!memcmp(td
[i
].string
, U(value
).blob
.pBlobData
, td
[i
].count
), "%u: expected %s, got %s\n", i
, td
[i
].string
, U(value
).blob
.pBlobData
);
613 ok(U(value
).uhVal
.QuadPart
== td
[i
].value
[0], "%u: expected value %#x/%#x got %#x/%#x\n",
614 i
, (UINT
)td
[i
].value
[0], (UINT
)(td
[i
].value
[0] >> 32), U(value
).uhVal
.u
.LowPart
, U(value
).uhVal
.u
.HighPart
);
616 PropVariantClear(&schema
);
617 PropVariantClear(&id
);
618 PropVariantClear(&value
);
621 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
622 ok(hr
== S_FALSE
, "Next should fail\n");
623 ok(items_returned
== 0, "unexpected item count %u\n", items_returned
);
625 IWICEnumMetadataItem_Release(enumerator
);
628 static void test_metadata_IFD(void)
630 static const struct test_data td
[28] =
632 { VT_UI2
, 0xfe, 0, { 1 } },
633 { VT_UI4
, 0x100, 0, { 222 } },
634 { VT_UI4
, 0x101, 0, { 333 } },
635 { VT_UI2
, 0x102, 0, { 24 } },
636 { VT_UI4
, 0x103, 0, { 32773 } },
637 { VT_UI8
, 0x11a, 0, { ((LONGLONG
)3 << 32) | 900 } },
638 { VT_UI1
, 0xf001, 0, { 0x44 } },
639 { VT_UI1
|VT_VECTOR
, 0xf002, 4, { 0x44, 0x33, 0x22, 0x11 } },
640 { VT_I1
, 0xf003, 0, { 0x44 } },
641 { VT_I2
, 0xf004, 0, { 0x3344 } },
642 { VT_I2
|VT_VECTOR
, 0xf005, 2, { 0x3344, 0x1122 } },
643 { VT_I4
, 0xf006, 0, { 0x11223344 } },
644 { VT_R4
, 0xf007, 0, { 0x11223344 } },
645 { VT_R8
, 0xf008, 0, { ((LONGLONG
)0x41d26580 << 32) | 0xb486522c } },
646 { VT_I8
, 0xf009, 0, { ((LONGLONG
)0x5a6b7c8d << 32) | 0x1a2b3c4d } },
647 { VT_UI1
|VT_VECTOR
, 0xf00a, 13, { 'H','e','l','l','o',' ','W','o','r','l','d','!',0 } },
648 { VT_I2
|VT_VECTOR
, 0xf00b, 4, { 0x0101, 0x0202, 0x0303, 0x0404 } },
649 { VT_I4
|VT_VECTOR
, 0xf00c, 2, { 0x11223344, 0x55667788 } },
650 { VT_R4
|VT_VECTOR
, 0xf00d, 2, { 0x449a522b, 0x4608f5ba } },
651 { VT_LPSTR
, 0xf00e, 12, { 0 }, "Hello World!" },
652 { VT_LPSTR
, 0xf00f, 4, { 0 }, "abcd" },
653 { VT_BLOB
, 0xf010, 13, { 0 }, "Hello World!" },
654 { VT_BLOB
, 0xf011, 4, { 0 }, "abcd" },
655 { VT_UI1
, 0xf012, 0, { 0x44 } },
656 { VT_UI2
, 0xf013, 0, { 0x3344 } },
657 { VT_UI4
, 0xf014, 0, { 0x11223344 } },
658 { VT_R4
, 0xf015, 0, { 0x11223344 } },
659 { VT_I8
|VT_VECTOR
, 0xf016, 3,
660 { ((LONGLONG
)0x05060708 << 32) | 0x01020304,
661 ((LONGLONG
)0x50607080 << 32) | 0x10203040,
662 ((LONGLONG
)0x55667788 << 32) | 0x11223344 } },
665 IWICMetadataReader
*reader
;
666 IWICMetadataBlockReader
*blockreader
;
667 PROPVARIANT schema
, id
, value
;
670 char *IFD_data_swapped
;
671 #ifdef WORDS_BIGENDIAN
672 DWORD persist_options
= WICPersistOptionsBigEndian
;
674 DWORD persist_options
= WICPersistOptionsLittleEndian
;
677 hr
= CoCreateInstance(&CLSID_WICIfdMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
678 &IID_IWICMetadataReader
, (void**)&reader
);
679 ok(hr
== S_OK
, "CoCreateInstance error %#x\n", hr
);
681 hr
= IWICMetadataReader_GetCount(reader
, NULL
);
682 ok(hr
== E_INVALIDARG
, "GetCount error %#x\n", hr
);
684 hr
= IWICMetadataReader_GetCount(reader
, &count
);
685 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
686 ok(count
== 0, "unexpected count %u\n", count
);
688 load_stream((IUnknown
*)reader
, (const char *)&IFD_data
, sizeof(IFD_data
), persist_options
);
690 hr
= IWICMetadataReader_GetCount(reader
, &count
);
691 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
692 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
694 compare_metadata(reader
, td
, count
);
696 /* test IFD data with different endianness */
697 if (persist_options
== WICPersistOptionsLittleEndian
)
698 persist_options
= WICPersistOptionsBigEndian
;
700 persist_options
= WICPersistOptionsLittleEndian
;
702 IFD_data_swapped
= HeapAlloc(GetProcessHeap(), 0, sizeof(IFD_data
));
703 memcpy(IFD_data_swapped
, &IFD_data
, sizeof(IFD_data
));
704 byte_swap_ifd_data(IFD_data_swapped
);
705 load_stream((IUnknown
*)reader
, IFD_data_swapped
, sizeof(IFD_data
), persist_options
);
706 hr
= IWICMetadataReader_GetCount(reader
, &count
);
707 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
708 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
709 compare_metadata(reader
, td
, count
);
710 HeapFree(GetProcessHeap(), 0, IFD_data_swapped
);
712 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
713 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
714 ok(IsEqualGUID(&format
, &GUID_MetadataFormatIfd
), "unexpected format %s\n", wine_dbgstr_guid(&format
));
716 hr
= IWICMetadataReader_GetMetadataFormat(reader
, NULL
);
717 ok(hr
== E_INVALIDARG
, "GetMetadataFormat should fail\n");
719 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, NULL
, NULL
);
720 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
722 PropVariantInit(&schema
);
723 PropVariantInit(&id
);
724 PropVariantInit(&value
);
726 hr
= IWICMetadataReader_GetValueByIndex(reader
, count
- 1, NULL
, NULL
, NULL
);
727 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
729 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, &schema
, NULL
, NULL
);
730 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
731 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %u\n", schema
.vt
);
733 hr
= IWICMetadataReader_GetValueByIndex(reader
, count
- 1, &schema
, NULL
, NULL
);
734 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
735 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %u\n", schema
.vt
);
737 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, &id
, NULL
);
738 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
739 ok(id
.vt
== VT_UI2
, "unexpected vt: %u\n", id
.vt
);
740 ok(U(id
).uiVal
== 0xfe, "unexpected id: %#x\n", U(id
).uiVal
);
741 PropVariantClear(&id
);
743 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, NULL
, &value
);
744 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
745 ok(value
.vt
== VT_UI2
, "unexpected vt: %u\n", value
.vt
);
746 ok(U(value
).uiVal
== 1, "unexpected id: %#x\n", U(value
).uiVal
);
747 PropVariantClear(&value
);
749 hr
= IWICMetadataReader_GetValueByIndex(reader
, count
, &schema
, NULL
, NULL
);
750 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
752 PropVariantInit(&schema
);
753 PropVariantInit(&id
);
754 PropVariantInit(&value
);
756 hr
= IWICMetadataReader_GetValue(reader
, &schema
, &id
, &value
);
757 ok(hr
== WINCODEC_ERR_PROPERTYNOTFOUND
, "expected WINCODEC_ERR_PROPERTYNOTFOUND, got %#x\n", hr
);
759 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, NULL
);
760 ok(hr
== WINCODEC_ERR_PROPERTYNOTFOUND
, "expected WINCODEC_ERR_PROPERTYNOTFOUND, got %#x\n", hr
);
762 hr
= IWICMetadataReader_GetValue(reader
, &schema
, NULL
, NULL
);
763 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
765 hr
= IWICMetadataReader_GetValue(reader
, &schema
, &id
, NULL
);
766 ok(hr
== WINCODEC_ERR_PROPERTYNOTFOUND
, "expected WINCODEC_ERR_PROPERTYNOTFOUND, got %#x\n", hr
);
768 hr
= IWICMetadataReader_GetValue(reader
, &schema
, NULL
, &value
);
769 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
772 U(id
).uiVal
= 0xf00e;
773 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, NULL
);
774 ok(hr
== S_OK
, "GetValue error %#x\n", hr
);
776 /* schema is ignored by Ifd metadata reader */
778 U(schema
).ulVal
= 0xdeadbeef;
779 hr
= IWICMetadataReader_GetValue(reader
, &schema
, &id
, &value
);
780 ok(hr
== S_OK
, "GetValue error %#x\n", hr
);
781 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
782 ok(!strcmp(U(value
).pszVal
, "Hello World!"), "unexpected value: %s\n", U(value
).pszVal
);
783 PropVariantClear(&value
);
785 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, &value
);
786 ok(hr
== S_OK
, "GetValue error %#x\n", hr
);
787 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
788 ok(!strcmp(U(value
).pszVal
, "Hello World!"), "unexpected value: %s\n", U(value
).pszVal
);
789 PropVariantClear(&value
);
791 hr
= IWICMetadataReader_QueryInterface(reader
, &IID_IWICMetadataBlockReader
, (void**)&blockreader
);
792 ok(hr
== E_NOINTERFACE
, "QueryInterface failed, hr=%x\n", hr
);
795 IWICMetadataBlockReader_Release(blockreader
);
797 IWICMetadataReader_Release(reader
);
800 static void test_metadata_Exif(void)
803 IWICMetadataReader
*reader
;
804 IWICMetadataBlockReader
*blockreader
;
807 hr
= CoCreateInstance(&CLSID_WICExifMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
808 &IID_IWICMetadataReader
, (void**)&reader
);
809 todo_wine
ok(hr
== S_OK
, "CoCreateInstance error %#x\n", hr
);
810 if (FAILED(hr
)) return;
812 hr
= IWICMetadataReader_GetCount(reader
, NULL
);
813 ok(hr
== E_INVALIDARG
, "GetCount error %#x\n", hr
);
815 hr
= IWICMetadataReader_GetCount(reader
, &count
);
816 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
817 ok(count
== 0, "unexpected count %u\n", count
);
819 hr
= IWICMetadataReader_QueryInterface(reader
, &IID_IWICMetadataBlockReader
, (void**)&blockreader
);
820 ok(hr
== E_NOINTERFACE
, "QueryInterface failed, hr=%x\n", hr
);
823 IWICMetadataBlockReader_Release(blockreader
);
825 IWICMetadataReader_Release(reader
);
828 static void test_create_reader(void)
831 IWICComponentFactory
*factory
;
833 IWICMetadataReader
*reader
;
837 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
838 &IID_IWICComponentFactory
, (void**)&factory
);
839 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
841 stream
= create_stream(metadata_tEXt
, sizeof(metadata_tEXt
));
843 hr
= IWICComponentFactory_CreateMetadataReaderFromContainer(factory
,
844 &GUID_ContainerFormatPng
, NULL
, WICPersistOptionsDefault
,
847 ok(hr
== S_OK
, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr
);
848 if (FAILED(hr
)) return;
852 hr
= IWICMetadataReader_GetCount(reader
, &count
);
853 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
854 ok(count
== 1, "unexpected count %i\n", count
);
856 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
857 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
858 ok(IsEqualGUID(&format
, &GUID_MetadataFormatChunktEXt
), "unexpected format %s\n", wine_dbgstr_guid(&format
));
860 IWICMetadataReader_Release(reader
);
863 hr
= IWICComponentFactory_CreateMetadataReaderFromContainer(factory
,
864 &GUID_ContainerFormatWmp
, NULL
, WICPersistOptionsDefault
,
866 ok(hr
== S_OK
, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr
);
870 hr
= IWICMetadataReader_GetCount(reader
, &count
);
871 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
872 ok(count
== 1, "unexpected count %i\n", count
);
874 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
875 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
876 ok(IsEqualGUID(&format
, &GUID_MetadataFormatUnknown
), "unexpected format %s\n", wine_dbgstr_guid(&format
));
878 IWICMetadataReader_Release(reader
);
881 IStream_Release(stream
);
883 IWICComponentFactory_Release(factory
);
886 static void test_metadata_png(void)
888 static const struct test_data td
[6] =
890 { VT_UI2
, 0, 0, { 2005 }, NULL
, { 'Y','e','a','r',0 } },
891 { VT_UI1
, 0, 0, { 6 }, NULL
, { 'M','o','n','t','h',0 } },
892 { VT_UI1
, 0, 0, { 3 }, NULL
, { 'D','a','y',0 } },
893 { VT_UI1
, 0, 0, { 15 }, NULL
, { 'H','o','u','r',0 } },
894 { VT_UI1
, 0, 0, { 7 }, NULL
, { 'M','i','n','u','t','e',0 } },
895 { VT_UI1
, 0, 0, { 45 }, NULL
, { 'S','e','c','o','n','d',0 } }
898 IWICBitmapDecoder
*decoder
;
899 IWICBitmapFrameDecode
*frame
;
900 IWICMetadataBlockReader
*blockreader
;
901 IWICMetadataReader
*reader
;
902 GUID containerformat
;
906 hr
= CoCreateInstance(&CLSID_WICPngDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
907 &IID_IWICBitmapDecoder
, (void**)&decoder
);
908 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
910 if (FAILED(hr
)) return;
912 stream
= create_stream(pngimage
, sizeof(pngimage
));
914 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnLoad
);
915 ok(hr
== S_OK
, "Initialize failed, hr=%x\n", hr
);
917 hr
= IWICBitmapDecoder_QueryInterface(decoder
, &IID_IWICMetadataBlockReader
, (void**)&blockreader
);
918 ok(hr
== E_NOINTERFACE
, "QueryInterface failed, hr=%x\n", hr
);
920 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &frame
);
921 ok(hr
== S_OK
, "GetFrame failed, hr=%x\n", hr
);
923 hr
= IWICBitmapFrameDecode_QueryInterface(frame
, &IID_IWICMetadataBlockReader
, (void**)&blockreader
);
924 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
928 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, NULL
);
929 ok(hr
== E_INVALIDARG
, "GetContainerFormat failed, hr=%x\n", hr
);
931 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, &containerformat
);
932 ok(hr
== S_OK
, "GetContainerFormat failed, hr=%x\n", hr
);
933 ok(IsEqualGUID(&containerformat
, &GUID_ContainerFormatPng
), "unexpected container format\n");
935 hr
= IWICMetadataBlockReader_GetCount(blockreader
, NULL
);
936 todo_wine
ok(hr
== E_INVALIDARG
, "GetCount failed, hr=%x\n", hr
);
938 hr
= IWICMetadataBlockReader_GetCount(blockreader
, &count
);
939 todo_wine
ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
940 todo_wine
ok(count
== 1, "unexpected count %d\n", count
);
944 /* Crashes on Windows XP */
945 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, NULL
);
946 ok(hr
== E_INVALIDARG
, "GetReaderByIndex failed, hr=%x\n", hr
);
949 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, &reader
);
950 todo_wine
ok(hr
== S_OK
, "GetReaderByIndex failed, hr=%x\n", hr
);
954 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &containerformat
);
955 ok(IsEqualGUID(&containerformat
, &GUID_MetadataFormatChunktIME
) ||
956 broken(IsEqualGUID(&containerformat
, &GUID_MetadataFormatUnknown
)) /* Windows XP */,
957 "unexpected container format\n");
959 hr
= IWICMetadataReader_GetCount(reader
, &count
);
960 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
961 ok(count
== 6 || broken(count
== 1) /* XP */, "expected 6, got %u\n", count
);
963 compare_metadata(reader
, td
, count
);
965 IWICMetadataReader_Release(reader
);
968 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 1, &reader
);
969 todo_wine
ok(hr
== WINCODEC_ERR_VALUEOUTOFRANGE
, "GetReaderByIndex failed, hr=%x\n", hr
);
971 IWICMetadataBlockReader_Release(blockreader
);
974 IWICBitmapFrameDecode_Release(frame
);
976 IWICBitmapDecoder_Release(decoder
);
978 IStream_Release(stream
);
981 static void test_metadata_gif(void)
983 static const struct test_data gif_LSD
[9] =
985 { VT_UI1
|VT_VECTOR
, 0, 6, {'G','I','F','8','7','a'}, NULL
, { 'S','i','g','n','a','t','u','r','e',0 } },
986 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'W','i','d','t','h',0 } },
987 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'H','e','i','g','h','t',0 } },
988 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
989 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'C','o','l','o','r','R','e','s','o','l','u','t','i','o','n',0 } },
990 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
991 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } },
992 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'B','a','c','k','g','r','o','u','n','d','C','o','l','o','r','I','n','d','e','x',0 } },
993 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'P','i','x','e','l','A','s','p','e','c','t','R','a','t','i','o',0 } }
995 static const struct test_data gif_IMD
[8] =
997 { VT_UI2
, 0, 0, { 0 }, NULL
, { 'L','e','f','t',0 } },
998 { VT_UI2
, 0, 0, { 0 }, NULL
, { 'T','o','p',0 } },
999 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'W','i','d','t','h',0 } },
1000 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'H','e','i','g','h','t',0 } },
1001 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1002 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'I','n','t','e','r','l','a','c','e','F','l','a','g',0 } },
1003 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1004 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } }
1006 static const struct test_data animated_gif_LSD
[9] =
1008 { VT_UI1
|VT_VECTOR
, 0, 6, {'G','I','F','8','9','a'}, NULL
, { 'S','i','g','n','a','t','u','r','e',0 } },
1009 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'W','i','d','t','h',0 } },
1010 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'H','e','i','g','h','t',0 } },
1011 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1012 { VT_UI1
, 0, 0, { 2 }, NULL
, { 'C','o','l','o','r','R','e','s','o','l','u','t','i','o','n',0 } },
1013 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1014 { VT_UI1
, 0, 0, { 1 }, NULL
, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } },
1015 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'B','a','c','k','g','r','o','u','n','d','C','o','l','o','r','I','n','d','e','x',0 } },
1016 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'P','i','x','e','l','A','s','p','e','c','t','R','a','t','i','o',0 } }
1018 static const struct test_data animated_gif_IMD
[8] =
1020 { VT_UI2
, 0, 0, { 0 }, NULL
, { 'L','e','f','t',0 } },
1021 { VT_UI2
, 0, 0, { 0 }, NULL
, { 'T','o','p',0 } },
1022 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'W','i','d','t','h',0 } },
1023 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'H','e','i','g','h','t',0 } },
1024 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1025 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'I','n','t','e','r','l','a','c','e','F','l','a','g',0 } },
1026 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1027 { VT_UI1
, 0, 0, { 1 }, NULL
, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } }
1029 static const struct test_data animated_gif_GCE
[5] =
1031 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'D','i','s','p','o','s','a','l',0 } },
1032 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'U','s','e','r','I','n','p','u','t','F','l','a','g',0 } },
1033 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'T','r','a','n','s','p','a','r','e','n','c','y','F','l','a','g',0 } },
1034 { VT_UI2
, 0, 0, { 10 }, NULL
, { 'D','e','l','a','y',0 } },
1035 { VT_UI1
, 0, 0, { 1 }, NULL
, { 'T','r','a','n','s','p','a','r','e','n','t','C','o','l','o','r','I','n','d','e','x',0 } }
1037 static const struct test_data animated_gif_APE
[2] =
1039 { VT_UI1
|VT_VECTOR
, 0, 11, { 'A','N','I','M','E','X','T','S','1','.','0' }, NULL
, { 'A','p','p','l','i','c','a','t','i','o','n',0 } },
1040 { VT_UI1
|VT_VECTOR
, 0, 4, { 0x03,0x01,0x05,0x00 }, NULL
, { 'D','a','t','a',0 } }
1042 static const struct test_data animated_gif_comment_1
[1] =
1044 { VT_LPSTR
, 0, 12, { 0 }, "Hello World!", { 'T','e','x','t','E','n','t','r','y',0 } }
1046 static const struct test_data animated_gif_comment_2
[1] =
1048 { VT_LPSTR
, 0, 8, { 0 }, "image #1", { 'T','e','x','t','E','n','t','r','y',0 } }
1050 static const struct test_data animated_gif_plain_1
[1] =
1052 { VT_BLOB
, 0, 17, { 0 }, "\x21\x01\x0d\x61nimation.gif" }
1054 static const struct test_data animated_gif_plain_2
[1] =
1056 { VT_BLOB
, 0, 16, { 0 }, "\x21\x01\x0cplaintext #1" }
1059 IWICBitmapDecoder
*decoder
;
1060 IWICBitmapFrameDecode
*frame
;
1061 IWICMetadataBlockReader
*blockreader
;
1062 IWICMetadataReader
*reader
;
1068 stream
= create_stream(gifimage
, sizeof(gifimage
));
1070 hr
= CoCreateInstance(&CLSID_WICGifDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
1071 &IID_IWICBitmapDecoder
, (void **)&decoder
);
1072 ok(hr
== S_OK
, "CoCreateInstance error %#x\n", hr
);
1073 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnLoad
);
1074 ok(hr
== S_OK
, "Initialize error %#x\n", hr
);
1076 IStream_Release(stream
);
1078 /* global metadata block */
1079 hr
= IWICBitmapDecoder_QueryInterface(decoder
, &IID_IWICMetadataBlockReader
, (void **)&blockreader
);
1080 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* before Win7 */, "QueryInterface error %#x\n", hr
);
1084 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, &format
);
1085 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
1086 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
1087 "wrong container format %s\n", wine_dbgstr_guid(&format
));
1089 hr
= IWICMetadataBlockReader_GetCount(blockreader
, &count
);
1090 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1091 ok(count
== 1, "expected 1, got %u\n", count
);
1093 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, &reader
);
1094 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1098 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1099 ok(IsEqualGUID(&format
, &GUID_MetadataFormatLSD
), /* Logical Screen Descriptor */
1100 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1102 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1103 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1104 ok(count
== sizeof(gif_LSD
)/sizeof(gif_LSD
[0]), "unexpected count %u\n", count
);
1106 compare_metadata(reader
, gif_LSD
, count
);
1108 IWICMetadataReader_Release(reader
);
1111 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 1, &reader
);
1112 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1114 IWICMetadataBlockReader_Release(blockreader
);
1117 /* frame metadata block */
1118 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &frame
);
1119 ok(hr
== S_OK
, "GetFrame error %#x\n", hr
);
1121 hr
= IWICBitmapFrameDecode_QueryInterface(frame
, &IID_IWICMetadataBlockReader
, (void **)&blockreader
);
1122 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* before Win7 */, "QueryInterface error %#x\n", hr
);
1126 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, NULL
);
1127 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1129 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, &format
);
1130 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
1131 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
1132 "wrong container format %s\n", wine_dbgstr_guid(&format
));
1134 hr
= IWICMetadataBlockReader_GetCount(blockreader
, NULL
);
1135 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1137 hr
= IWICMetadataBlockReader_GetCount(blockreader
, &count
);
1138 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1139 ok(count
== 1, "expected 1, got %u\n", count
);
1141 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, &reader
);
1142 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1146 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1147 ok(IsEqualGUID(&format
, &GUID_MetadataFormatIMD
), /* Image Descriptor */
1148 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1150 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1151 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1152 ok(count
== sizeof(gif_IMD
)/sizeof(gif_IMD
[0]), "unexpected count %u\n", count
);
1154 compare_metadata(reader
, gif_IMD
, count
);
1156 IWICMetadataReader_Release(reader
);
1159 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 1, &reader
);
1160 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1162 IWICMetadataBlockReader_Release(blockreader
);
1165 IWICBitmapFrameDecode_Release(frame
);
1166 IWICBitmapDecoder_Release(decoder
);
1168 /* 1x1 pixel gif, 2 frames */
1169 stream
= create_stream(animatedgif
, sizeof(animatedgif
));
1171 hr
= CoCreateInstance(&CLSID_WICGifDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
1172 &IID_IWICBitmapDecoder
, (void **)&decoder
);
1173 ok(hr
== S_OK
, "CoCreateInstance error %#x\n", hr
);
1174 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnLoad
);
1175 ok(hr
== S_OK
, "Initialize error %#x\n", hr
);
1177 IStream_Release(stream
);
1179 /* global metadata block */
1180 hr
= IWICBitmapDecoder_QueryInterface(decoder
, &IID_IWICMetadataBlockReader
, (void **)&blockreader
);
1181 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* before Win7 */, "QueryInterface error %#x\n", hr
);
1185 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, &format
);
1186 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
1187 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
1188 "wrong container format %s\n", wine_dbgstr_guid(&format
));
1190 hr
= IWICMetadataBlockReader_GetCount(blockreader
, &count
);
1191 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1192 ok(count
== 4, "expected 4, got %u\n", count
);
1194 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, &reader
);
1195 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1199 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1200 ok(IsEqualGUID(&format
, &GUID_MetadataFormatLSD
), /* Logical Screen Descriptor */
1201 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1203 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1204 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1205 ok(count
== sizeof(animated_gif_LSD
)/sizeof(animated_gif_LSD
[0]), "unexpected count %u\n", count
);
1207 compare_metadata(reader
, animated_gif_LSD
, count
);
1209 IWICMetadataReader_Release(reader
);
1212 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 1, &reader
);
1213 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1217 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1218 ok(IsEqualGUID(&format
, &GUID_MetadataFormatAPE
), /* Application Extension */
1219 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1221 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1222 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1223 ok(count
== sizeof(animated_gif_APE
)/sizeof(animated_gif_APE
[0]), "unexpected count %u\n", count
);
1225 compare_metadata(reader
, animated_gif_APE
, count
);
1227 IWICMetadataReader_Release(reader
);
1230 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 2, &reader
);
1231 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1235 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1236 ok(IsEqualGUID(&format
, &GUID_MetadataFormatGifComment
), /* Comment Extension */
1237 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1239 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1240 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1241 ok(count
== sizeof(animated_gif_comment_1
)/sizeof(animated_gif_comment_1
[0]), "unexpected count %u\n", count
);
1243 compare_metadata(reader
, animated_gif_comment_1
, count
);
1245 IWICMetadataReader_Release(reader
);
1248 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 3, &reader
);
1249 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1253 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1254 ok(IsEqualGUID(&format
, &GUID_MetadataFormatUnknown
),
1255 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1257 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1258 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1259 ok(count
== sizeof(animated_gif_plain_1
)/sizeof(animated_gif_plain_1
[0]), "unexpected count %u\n", count
);
1261 compare_metadata(reader
, animated_gif_plain_1
, count
);
1263 IWICMetadataReader_Release(reader
);
1266 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 4, &reader
);
1267 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1269 IWICMetadataBlockReader_Release(blockreader
);
1272 /* frame metadata block */
1273 hr
= IWICBitmapDecoder_GetFrame(decoder
, 1, &frame
);
1274 ok(hr
== S_OK
, "GetFrame error %#x\n", hr
);
1276 hr
= IWICBitmapFrameDecode_QueryInterface(frame
, &IID_IWICMetadataBlockReader
, (void **)&blockreader
);
1277 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* before Win7 */, "QueryInterface error %#x\n", hr
);
1281 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, NULL
);
1282 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1284 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, &format
);
1285 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
1286 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
1287 "wrong container format %s\n", wine_dbgstr_guid(&format
));
1289 hr
= IWICMetadataBlockReader_GetCount(blockreader
, NULL
);
1290 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1292 hr
= IWICMetadataBlockReader_GetCount(blockreader
, &count
);
1293 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1294 ok(count
== 4, "expected 4, got %u\n", count
);
1296 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, &reader
);
1297 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1301 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1302 ok(IsEqualGUID(&format
, &GUID_MetadataFormatIMD
), /* Image Descriptor */
1303 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1305 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1306 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1307 ok(count
== sizeof(animated_gif_IMD
)/sizeof(animated_gif_IMD
[0]), "unexpected count %u\n", count
);
1309 compare_metadata(reader
, animated_gif_IMD
, count
);
1311 IWICMetadataReader_Release(reader
);
1314 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 1, &reader
);
1315 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1319 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1320 ok(IsEqualGUID(&format
, &GUID_MetadataFormatGifComment
), /* Comment Extension */
1321 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1323 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1324 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1325 ok(count
== sizeof(animated_gif_comment_2
)/sizeof(animated_gif_comment_2
[0]), "unexpected count %u\n", count
);
1328 compare_metadata(reader
, animated_gif_comment_2
, count
);
1330 IWICMetadataReader_Release(reader
);
1333 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 2, &reader
);
1334 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1338 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1339 ok(IsEqualGUID(&format
, &GUID_MetadataFormatUnknown
),
1340 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1342 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1343 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1344 ok(count
== sizeof(animated_gif_plain_2
)/sizeof(animated_gif_plain_2
[0]), "unexpected count %u\n", count
);
1346 compare_metadata(reader
, animated_gif_plain_2
, count
);
1348 IWICMetadataReader_Release(reader
);
1351 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 3, &reader
);
1352 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1356 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1357 ok(IsEqualGUID(&format
, &GUID_MetadataFormatGCE
), /* Graphic Control Extension */
1358 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1360 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1361 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1362 ok(count
== sizeof(animated_gif_GCE
)/sizeof(animated_gif_GCE
[0]), "unexpected count %u\n", count
);
1364 compare_metadata(reader
, animated_gif_GCE
, count
);
1366 IWICMetadataReader_Release(reader
);
1369 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 4, &reader
);
1370 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1372 IWICMetadataBlockReader_Release(blockreader
);
1375 IWICBitmapFrameDecode_Release(frame
);
1376 IWICBitmapDecoder_Release(decoder
);
1379 static void test_metadata_LSD(void)
1381 static const WCHAR LSD_name
[] = {'L','o','g','i','c','a','l',' ','S','c','r','e','e','n',' ','D','e','s','c','r','i','p','t','o','r',' ','R','e','a','d','e','r',0};
1382 static const char LSD_data
[] = "hello world!\x1\x2\x3\x4\xab\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf";
1383 static const struct test_data td
[9] =
1385 { VT_UI1
|VT_VECTOR
, 0, 6, {'w','o','r','l','d','!'}, NULL
, { 'S','i','g','n','a','t','u','r','e',0 } },
1386 { VT_UI2
, 0, 0, { 0x201 }, NULL
, { 'W','i','d','t','h',0 } },
1387 { VT_UI2
, 0, 0, { 0x403 }, NULL
, { 'H','e','i','g','h','t',0 } },
1388 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1389 { VT_UI1
, 0, 0, { 2 }, NULL
, { 'C','o','l','o','r','R','e','s','o','l','u','t','i','o','n',0 } },
1390 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1391 { VT_UI1
, 0, 0, { 3 }, NULL
, { 'G','l','o','b','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } },
1392 { VT_UI1
, 0, 0, { 6 }, NULL
, { 'B','a','c','k','g','r','o','u','n','d','C','o','l','o','r','I','n','d','e','x',0 } },
1393 { VT_UI1
, 0, 0, { 7 }, NULL
, { 'P','i','x','e','l','A','s','p','e','c','t','R','a','t','i','o',0 } }
1398 IWICPersistStream
*persist
;
1399 IWICMetadataReader
*reader
;
1400 IWICMetadataHandlerInfo
*info
;
1406 hr
= CoCreateInstance(&CLSID_WICLSDMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
1407 &IID_IWICMetadataReader
, (void **)&reader
);
1408 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
|| hr
== REGDB_E_CLASSNOTREG
) /* before Win7 */,
1409 "CoCreateInstance error %#x\n", hr
);
1411 stream
= create_stream(LSD_data
, sizeof(LSD_data
));
1416 hr
= IStream_Seek(stream
, pos
, SEEK_SET
, NULL
);
1417 ok(hr
== S_OK
, "IStream_Seek error %#x\n", hr
);
1419 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
1420 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1422 hr
= IWICPersistStream_Load(persist
, stream
);
1423 ok(hr
== S_OK
, "Load error %#x\n", hr
);
1425 IWICPersistStream_Release(persist
);
1430 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1431 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1432 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
1434 compare_metadata(reader
, td
, count
);
1436 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1437 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
1438 ok(IsEqualGUID(&format
, &GUID_MetadataFormatLSD
), "wrong format %s\n", wine_dbgstr_guid(&format
));
1440 hr
= IWICMetadataReader_GetMetadataHandlerInfo(reader
, &info
);
1441 ok(hr
== S_OK
, "GetMetadataHandlerInfo error %#x\n", hr
);
1443 hr
= IWICMetadataHandlerInfo_GetCLSID(info
, &id
);
1444 ok(hr
== S_OK
, "GetCLSID error %#x\n", hr
);
1445 ok(IsEqualGUID(&id
, &CLSID_WICLSDMetadataReader
), "wrong CLSID %s\n", wine_dbgstr_guid(&id
));
1447 hr
= IWICMetadataHandlerInfo_GetFriendlyName(info
, 64, name
, &dummy
);
1448 ok(hr
== S_OK
, "GetFriendlyName error %#x\n", hr
);
1449 ok(lstrcmpW(name
, LSD_name
) == 0, "wrong LSD reader name %s\n", wine_dbgstr_w(name
));
1451 IWICMetadataHandlerInfo_Release(info
);
1452 IWICMetadataReader_Release(reader
);
1455 IStream_Release(stream
);
1458 static void test_metadata_IMD(void)
1460 static const WCHAR IMD_name
[] = {'I','m','a','g','e',' ','D','e','s','c','r','i','p','t','o','r',' ','R','e','a','d','e','r',0};
1461 static const char IMD_data
[] = "hello world!\x1\x2\x3\x4\x5\x6\x7\x8\xed\xa\xb\xc\xd\xe\xf";
1462 static const struct test_data td
[8] =
1464 { VT_UI2
, 0, 0, { 0x201 }, NULL
, { 'L','e','f','t',0 } },
1465 { VT_UI2
, 0, 0, { 0x403 }, NULL
, { 'T','o','p',0 } },
1466 { VT_UI2
, 0, 0, { 0x605 }, NULL
, { 'W','i','d','t','h',0 } },
1467 { VT_UI2
, 0, 0, { 0x807 }, NULL
, { 'H','e','i','g','h','t',0 } },
1468 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','F','l','a','g',0 } },
1469 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'I','n','t','e','r','l','a','c','e','F','l','a','g',0 } },
1470 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1471 { VT_UI1
, 0, 0, { 5 }, NULL
, { 'L','o','c','a','l','C','o','l','o','r','T','a','b','l','e','S','i','z','e',0 } }
1476 IWICPersistStream
*persist
;
1477 IWICMetadataReader
*reader
;
1478 IWICMetadataHandlerInfo
*info
;
1484 hr
= CoCreateInstance(&CLSID_WICIMDMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
1485 &IID_IWICMetadataReader
, (void **)&reader
);
1486 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
|| hr
== REGDB_E_CLASSNOTREG
) /* before Win7 */,
1487 "CoCreateInstance error %#x\n", hr
);
1489 stream
= create_stream(IMD_data
, sizeof(IMD_data
));
1494 hr
= IStream_Seek(stream
, pos
, SEEK_SET
, NULL
);
1495 ok(hr
== S_OK
, "IStream_Seek error %#x\n", hr
);
1497 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
1498 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1500 hr
= IWICPersistStream_Load(persist
, stream
);
1501 ok(hr
== S_OK
, "Load error %#x\n", hr
);
1503 IWICPersistStream_Release(persist
);
1508 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1509 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1510 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
1512 compare_metadata(reader
, td
, count
);
1514 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1515 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
1516 ok(IsEqualGUID(&format
, &GUID_MetadataFormatIMD
), "wrong format %s\n", wine_dbgstr_guid(&format
));
1518 hr
= IWICMetadataReader_GetMetadataHandlerInfo(reader
, &info
);
1519 ok(hr
== S_OK
, "GetMetadataHandlerInfo error %#x\n", hr
);
1521 hr
= IWICMetadataHandlerInfo_GetCLSID(info
, &id
);
1522 ok(hr
== S_OK
, "GetCLSID error %#x\n", hr
);
1523 ok(IsEqualGUID(&id
, &CLSID_WICIMDMetadataReader
), "wrong CLSID %s\n", wine_dbgstr_guid(&id
));
1525 hr
= IWICMetadataHandlerInfo_GetFriendlyName(info
, 64, name
, &dummy
);
1526 ok(hr
== S_OK
, "GetFriendlyName error %#x\n", hr
);
1527 ok(lstrcmpW(name
, IMD_name
) == 0, "wrong IMD reader name %s\n", wine_dbgstr_w(name
));
1529 IWICMetadataHandlerInfo_Release(info
);
1530 IWICMetadataReader_Release(reader
);
1533 IStream_Release(stream
);
1536 static void test_metadata_GCE(void)
1538 static const WCHAR GCE_name
[] = {'G','r','a','p','h','i','c',' ','C','o','n','t','r','o','l',' ','E','x','t','e','n','s','i','o','n',' ','R','e','a','d','e','r',0};
1539 static const char GCE_data
[] = "hello world!\xa\x2\x3\x4\x5\x6\x7\x8\xed\xa\xb\xc\xd\xe\xf";
1540 static const struct test_data td
[5] =
1542 { VT_UI1
, 0, 0, { 2 }, NULL
, { 'D','i','s','p','o','s','a','l',0 } },
1543 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'U','s','e','r','I','n','p','u','t','F','l','a','g',0 } },
1544 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'T','r','a','n','s','p','a','r','e','n','c','y','F','l','a','g',0 } },
1545 { VT_UI2
, 0, 0, { 0x302 }, NULL
, { 'D','e','l','a','y',0 } },
1546 { VT_UI1
, 0, 0, { 4 }, NULL
, { 'T','r','a','n','s','p','a','r','e','n','t','C','o','l','o','r','I','n','d','e','x',0 } }
1551 IWICPersistStream
*persist
;
1552 IWICMetadataReader
*reader
;
1553 IWICMetadataHandlerInfo
*info
;
1559 hr
= CoCreateInstance(&CLSID_WICGCEMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
1560 &IID_IWICMetadataReader
, (void **)&reader
);
1561 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
|| hr
== REGDB_E_CLASSNOTREG
) /* before Win7 */,
1562 "CoCreateInstance error %#x\n", hr
);
1564 stream
= create_stream(GCE_data
, sizeof(GCE_data
));
1569 hr
= IStream_Seek(stream
, pos
, SEEK_SET
, NULL
);
1570 ok(hr
== S_OK
, "IStream_Seek error %#x\n", hr
);
1572 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
1573 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1575 hr
= IWICPersistStream_Load(persist
, stream
);
1576 ok(hr
== S_OK
, "Load error %#x\n", hr
);
1578 IWICPersistStream_Release(persist
);
1583 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1584 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1585 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
1587 compare_metadata(reader
, td
, count
);
1589 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1590 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
1591 ok(IsEqualGUID(&format
, &GUID_MetadataFormatGCE
), "wrong format %s\n", wine_dbgstr_guid(&format
));
1593 hr
= IWICMetadataReader_GetMetadataHandlerInfo(reader
, &info
);
1594 ok(hr
== S_OK
, "GetMetadataHandlerInfo error %#x\n", hr
);
1596 hr
= IWICMetadataHandlerInfo_GetCLSID(info
, &id
);
1597 ok(hr
== S_OK
, "GetCLSID error %#x\n", hr
);
1598 ok(IsEqualGUID(&id
, &CLSID_WICGCEMetadataReader
), "wrong CLSID %s\n", wine_dbgstr_guid(&id
));
1600 hr
= IWICMetadataHandlerInfo_GetFriendlyName(info
, 64, name
, &dummy
);
1601 ok(hr
== S_OK
, "GetFriendlyName error %#x\n", hr
);
1602 ok(lstrcmpW(name
, GCE_name
) == 0, "wrong GCE reader name %s\n", wine_dbgstr_w(name
));
1604 IWICMetadataHandlerInfo_Release(info
);
1605 IWICMetadataReader_Release(reader
);
1608 IStream_Release(stream
);
1611 static void test_metadata_APE(void)
1613 static const WCHAR APE_name
[] = {'A','p','p','l','i','c','a','t','i','o','n',' ','E','x','t','e','n','s','i','o','n',' ','R','e','a','d','e','r',0};
1614 static const char APE_data
[] = { 0x21,0xff,0x0b,'H','e','l','l','o',' ','W','o','r','l','d',
1615 /*sub-block*/1,0x11,
1616 /*sub-block*/2,0x22,0x33,
1617 /*sub-block*/4,0x44,0x55,0x66,0x77,
1619 static const struct test_data td
[2] =
1621 { VT_UI1
|VT_VECTOR
, 0, 11, { 'H','e','l','l','o',' ','W','o','r','l','d' }, NULL
, { 'A','p','p','l','i','c','a','t','i','o','n',0 } },
1622 { VT_UI1
|VT_VECTOR
, 0, 10, { 1,0x11,2,0x22,0x33,4,0x44,0x55,0x66,0x77 }, NULL
, { 'D','a','t','a',0 } }
1624 WCHAR dataW
[] = { 'd','a','t','a',0 };
1627 IWICPersistStream
*persist
;
1628 IWICMetadataReader
*reader
;
1629 IWICMetadataHandlerInfo
*info
;
1631 UINT count
, dummy
, i
;
1634 PROPVARIANT id
, value
;
1636 hr
= CoCreateInstance(&CLSID_WICAPEMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
1637 &IID_IWICMetadataReader
, (void **)&reader
);
1638 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
|| hr
== REGDB_E_CLASSNOTREG
) /* before Win7 */,
1639 "CoCreateInstance error %#x\n", hr
);
1641 stream
= create_stream(APE_data
, sizeof(APE_data
));
1645 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
1646 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1648 hr
= IWICPersistStream_Load(persist
, stream
);
1649 ok(hr
== S_OK
, "Load error %#x\n", hr
);
1651 IWICPersistStream_Release(persist
);
1656 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1657 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1658 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
1660 compare_metadata(reader
, td
, count
);
1662 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1663 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
1664 ok(IsEqualGUID(&format
, &GUID_MetadataFormatAPE
), "wrong format %s\n", wine_dbgstr_guid(&format
));
1666 PropVariantInit(&value
);
1668 U(id
).pwszVal
= dataW
;
1670 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, &value
);
1671 ok(hr
== S_OK
, "GetValue error %#x\n", hr
);
1672 ok(value
.vt
== (VT_UI1
|VT_VECTOR
), "unexpected vt: %i\n", id
.vt
);
1673 ok(td
[1].count
== U(value
).caub
.cElems
, "expected cElems %d, got %d\n", td
[1].count
, U(value
).caub
.cElems
);
1674 for (i
= 0; i
< U(value
).caub
.cElems
; i
++)
1675 ok(td
[1].value
[i
] == U(value
).caub
.pElems
[i
], "%u: expected value %#x/%#x, got %#x\n", i
, (ULONG
)td
[1].value
[i
], (ULONG
)(td
[1].value
[i
] >> 32), U(value
).caub
.pElems
[i
]);
1676 PropVariantClear(&value
);
1678 hr
= IWICMetadataReader_GetMetadataHandlerInfo(reader
, &info
);
1679 ok(hr
== S_OK
, "GetMetadataHandlerInfo error %#x\n", hr
);
1681 hr
= IWICMetadataHandlerInfo_GetCLSID(info
, &clsid
);
1682 ok(hr
== S_OK
, "GetCLSID error %#x\n", hr
);
1683 ok(IsEqualGUID(&clsid
, &CLSID_WICAPEMetadataReader
), "wrong CLSID %s\n", wine_dbgstr_guid(&clsid
));
1685 hr
= IWICMetadataHandlerInfo_GetFriendlyName(info
, 64, name
, &dummy
);
1686 ok(hr
== S_OK
, "GetFriendlyName error %#x\n", hr
);
1687 ok(lstrcmpW(name
, APE_name
) == 0, "wrong APE reader name %s\n", wine_dbgstr_w(name
));
1689 IWICMetadataHandlerInfo_Release(info
);
1690 IWICMetadataReader_Release(reader
);
1693 IStream_Release(stream
);
1696 static void test_metadata_GIF_comment(void)
1698 static const WCHAR GIF_comment_name
[] = {'C','o','m','m','e','n','t',' ','E','x','t','e','n','s','i','o','n',' ','R','e','a','d','e','r',0};
1699 static const char GIF_comment_data
[] = { 0x21,0xfe,
1700 /*sub-block*/5,'H','e','l','l','o',
1702 /*sub-block*/6,'W','o','r','l','d','!',
1704 static const struct test_data td
[1] =
1706 { VT_LPSTR
, 0, 12, { 0 }, "Hello World!", { 'T','e','x','t','E','n','t','r','y',0 } }
1708 WCHAR text_entryW
[] = { 'T','E','X','T','E','N','T','R','Y',0 };
1711 IWICPersistStream
*persist
;
1712 IWICMetadataReader
*reader
;
1713 IWICMetadataHandlerInfo
*info
;
1718 PROPVARIANT id
, value
;
1720 hr
= CoCreateInstance(&CLSID_WICGifCommentMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
1721 &IID_IWICMetadataReader
, (void **)&reader
);
1722 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
|| hr
== REGDB_E_CLASSNOTREG
) /* before Win7 */,
1723 "CoCreateInstance error %#x\n", hr
);
1725 stream
= create_stream(GIF_comment_data
, sizeof(GIF_comment_data
));
1729 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
1730 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1732 hr
= IWICPersistStream_Load(persist
, stream
);
1733 ok(hr
== S_OK
, "Load error %#x\n", hr
);
1735 IWICPersistStream_Release(persist
);
1740 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1741 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1742 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
1744 compare_metadata(reader
, td
, count
);
1746 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1747 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
1748 ok(IsEqualGUID(&format
, &GUID_MetadataFormatGifComment
), "wrong format %s\n", wine_dbgstr_guid(&format
));
1750 PropVariantInit(&value
);
1752 U(id
).pwszVal
= text_entryW
;
1754 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, &value
);
1755 ok(hr
== S_OK
, "GetValue error %#x\n", hr
);
1756 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
1757 ok(!strcmp(U(value
).pszVal
, "Hello World!"), "unexpected value: %s\n", U(value
).pszVal
);
1758 PropVariantClear(&value
);
1760 hr
= IWICMetadataReader_GetMetadataHandlerInfo(reader
, &info
);
1761 ok(hr
== S_OK
, "GetMetadataHandlerInfo error %#x\n", hr
);
1763 hr
= IWICMetadataHandlerInfo_GetCLSID(info
, &clsid
);
1764 ok(hr
== S_OK
, "GetCLSID error %#x\n", hr
);
1765 ok(IsEqualGUID(&clsid
, &CLSID_WICGifCommentMetadataReader
), "wrong CLSID %s\n", wine_dbgstr_guid(&clsid
));
1767 hr
= IWICMetadataHandlerInfo_GetFriendlyName(info
, 64, name
, &dummy
);
1768 ok(hr
== S_OK
, "GetFriendlyName error %#x\n", hr
);
1769 ok(lstrcmpW(name
, GIF_comment_name
) == 0, "wrong APE reader name %s\n", wine_dbgstr_w(name
));
1771 IWICMetadataHandlerInfo_Release(info
);
1772 IWICMetadataReader_Release(reader
);
1775 IStream_Release(stream
);
1778 START_TEST(metadata
)
1780 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
1782 test_metadata_unknown();
1783 test_metadata_tEXt();
1784 test_metadata_IFD();
1785 test_metadata_Exif();
1786 test_create_reader();
1787 test_metadata_png();
1788 test_metadata_gif();
1789 test_metadata_LSD();
1790 test_metadata_IMD();
1791 test_metadata_GCE();
1792 test_metadata_APE();
1793 test_metadata_GIF_comment();