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 metadata_gAMA
[] = {
141 0,0,0,4, /* chunk length */
142 'g','A','M','A', /* chunk type */
143 0,0,130,53, /* gamma */
144 0xff,0xff,0xff,0xff /* chunk CRC */
147 static const char metadata_cHRM
[] = {
148 0,0,0,32, /* chunk length */
149 'c','H','R','M', /* chunk type */
150 0,0,122,38, 0,0,128,132, /* white point */
151 0,0,250,0, 0,0,128,232, /* red */
152 0,0,117,48, 0,0,234,96, /* green */
153 0,0,58,152, 0,0,23,112, /* blue */
154 0xff,0xff,0xff,0xff /* chunk CRC */
157 static const char pngimage
[285] = {
158 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
159 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,
160 0xde,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b,
161 0x13,0x01,0x00,0x9a,0x9c,0x18,0x00,0x00,0x00,0x07,0x74,0x49,0x4d,0x45,0x07,0xd5,
162 0x06,0x03,0x0f,0x07,0x2d,0x12,0x10,0xf0,0xfd,0x00,0x00,0x00,0x0c,0x49,0x44,0x41,
163 0x54,0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,
164 0xe7,0x00,0x00,0x00,0x00,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82
168 static const char gifimage
[35] = {
169 0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x00,0xff,0xff,0xff,
170 0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44,
174 /* 1x1 pixel gif, 2 frames; first frame is white, second is black */
175 static const char animatedgif
[] = {
176 'G','I','F','8','9','a',0x01,0x00,0x01,0x00,0xA1,0x00,0x00,
177 0x6F,0x6F,0x6F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
178 /*0x21,0xFF,0x0B,'N','E','T','S','C','A','P','E','2','.','0',*/
179 0x21,0xFF,0x0B,'A','N','I','M','E','X','T','S','1','.','0',
180 0x03,0x01,0x05,0x00,0x00,
181 0x21,0xFE,0x0C,'H','e','l','l','o',' ','W','o','r','l','d','!',0x00,
182 0x21,0x01,0x0D,'a','n','i','m','a','t','i','o','n','.','g','i','f',0x00,
183 0x21,0xF9,0x04,0x00,0x0A,0x00,0xFF,0x00,0x2C,
184 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
185 0xDE,0xDE,0xDE,0x00,0x00,0x00,
186 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x4C,0x01,0x00,
187 0x21,0xFE,0x08,'i','m','a','g','e',' ','#','1',0x00,
188 0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','1',0x00,
189 0x21,0xF9,0x04,0x01,0x0A,0x00,0x01,0x00,0x2C,
190 0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x81,
191 0x4D,0x4D,0x4D,0x00,0x00,0x00,
192 0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x02,0x44,0x01,0x00,
193 0x21,0xFE,0x08,'i','m','a','g','e',' ','#','2',0x00,
194 0x21,0x01,0x0C,'p','l','a','i','n','t','e','x','t',' ','#','2',0x00,0x3B
197 static IStream
*create_stream(const char *data
, int data_size
)
204 hdata
= GlobalAlloc(GMEM_MOVEABLE
, data_size
);
205 ok(hdata
!= 0, "GlobalAlloc failed\n");
206 if (!hdata
) return NULL
;
208 locked_data
= GlobalLock(hdata
);
209 memcpy(locked_data
, data
, data_size
);
212 hr
= CreateStreamOnHGlobal(hdata
, TRUE
, &stream
);
213 ok(hr
== S_OK
, "CreateStreamOnHGlobal failed, hr=%x\n", hr
);
218 static void load_stream(IUnknown
*reader
, const char *data
, int data_size
, DWORD persist_options
)
221 IWICPersistStream
*persist
;
224 ULARGE_INTEGER cur_pos
;
226 stream
= create_stream(data
, data_size
);
230 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void**)&persist
);
231 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
235 hr
= IWICPersistStream_LoadEx(persist
, stream
, NULL
, persist_options
);
236 ok(hr
== S_OK
, "LoadEx failed, hr=%x\n", hr
);
238 IWICPersistStream_Release(persist
);
242 hr
= IStream_Seek(stream
, pos
, SEEK_CUR
, &cur_pos
);
243 ok(hr
== S_OK
, "IStream_Seek error %#x\n", hr
);
244 /* IFD metadata reader doesn't rewind the stream to the start */
245 ok(cur_pos
.QuadPart
== 0 || cur_pos
.QuadPart
<= data_size
,
246 "current stream pos is at %x/%x, data size %x\n", cur_pos
.u
.LowPart
, cur_pos
.u
.HighPart
, data_size
);
248 IStream_Release(stream
);
251 static void test_metadata_unknown(void)
254 IWICMetadataReader
*reader
;
255 IWICEnumMetadataItem
*enumerator
;
256 IWICMetadataBlockReader
*blockreader
;
257 PROPVARIANT schema
, id
, value
;
258 ULONG items_returned
;
260 hr
= CoCreateInstance(&CLSID_WICUnknownMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
261 &IID_IWICMetadataReader
, (void**)&reader
);
262 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
263 if (FAILED(hr
)) return;
265 load_stream((IUnknown
*)reader
, metadata_unknown
, sizeof(metadata_unknown
), WICPersistOptionDefault
);
267 hr
= IWICMetadataReader_GetEnumerator(reader
, &enumerator
);
268 ok(hr
== S_OK
, "GetEnumerator failed, hr=%x\n", hr
);
272 PropVariantInit(&schema
);
273 PropVariantInit(&id
);
274 PropVariantInit(&value
);
276 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
277 ok(hr
== S_OK
, "Next failed, hr=%x\n", hr
);
278 ok(items_returned
== 1, "unexpected item count %i\n", items_returned
);
280 if (hr
== S_OK
&& items_returned
== 1)
282 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %i\n", schema
.vt
);
283 ok(id
.vt
== VT_EMPTY
, "unexpected vt: %i\n", id
.vt
);
284 expect_blob(value
, metadata_unknown
, sizeof(metadata_unknown
));
286 PropVariantClear(&schema
);
287 PropVariantClear(&id
);
288 PropVariantClear(&value
);
291 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
292 ok(hr
== S_FALSE
, "Next failed, hr=%x\n", hr
);
293 ok(items_returned
== 0, "unexpected item count %i\n", items_returned
);
295 IWICEnumMetadataItem_Release(enumerator
);
298 hr
= IWICMetadataReader_QueryInterface(reader
, &IID_IWICMetadataBlockReader
, (void**)&blockreader
);
299 ok(hr
== E_NOINTERFACE
, "QueryInterface failed, hr=%x\n", hr
);
302 IWICMetadataBlockReader_Release(blockreader
);
304 IWICMetadataReader_Release(reader
);
307 static void test_metadata_tEXt(void)
310 IWICMetadataReader
*reader
;
311 IWICEnumMetadataItem
*enumerator
;
312 PROPVARIANT schema
, id
, value
;
313 ULONG items_returned
, count
;
316 PropVariantInit(&schema
);
317 PropVariantInit(&id
);
318 PropVariantInit(&value
);
320 hr
= CoCreateInstance(&CLSID_WICPngTextMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
321 &IID_IWICMetadataReader
, (void**)&reader
);
322 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
323 if (FAILED(hr
)) return;
325 hr
= IWICMetadataReader_GetCount(reader
, NULL
);
326 ok(hr
== E_INVALIDARG
, "GetCount failed, hr=%x\n", hr
);
328 hr
= IWICMetadataReader_GetCount(reader
, &count
);
329 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
330 ok(count
== 0, "unexpected count %i\n", count
);
332 load_stream((IUnknown
*)reader
, metadata_tEXt
, sizeof(metadata_tEXt
), WICPersistOptionDefault
);
334 hr
= IWICMetadataReader_GetCount(reader
, &count
);
335 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
336 ok(count
== 1, "unexpected count %i\n", count
);
338 hr
= IWICMetadataReader_GetEnumerator(reader
, NULL
);
339 ok(hr
== E_INVALIDARG
, "GetEnumerator failed, hr=%x\n", hr
);
341 hr
= IWICMetadataReader_GetEnumerator(reader
, &enumerator
);
342 ok(hr
== S_OK
, "GetEnumerator failed, hr=%x\n", hr
);
346 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
347 ok(hr
== S_OK
, "Next failed, hr=%x\n", hr
);
348 ok(items_returned
== 1, "unexpected item count %i\n", items_returned
);
350 if (hr
== S_OK
&& items_returned
== 1)
352 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %i\n", schema
.vt
);
353 ok(id
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
354 ok(!strcmp(U(id
).pszVal
, "winetest"), "unexpected id: %s\n", U(id
).pszVal
);
355 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", value
.vt
);
356 ok(!strcmp(U(value
).pszVal
, "value"), "unexpected value: %s\n", U(value
).pszVal
);
358 PropVariantClear(&schema
);
359 PropVariantClear(&id
);
360 PropVariantClear(&value
);
363 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
364 ok(hr
== S_FALSE
, "Next failed, hr=%x\n", hr
);
365 ok(items_returned
== 0, "unexpected item count %i\n", items_returned
);
367 IWICEnumMetadataItem_Release(enumerator
);
370 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
371 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
372 ok(IsEqualGUID(&format
, &GUID_MetadataFormatChunktEXt
), "unexpected format %s\n", wine_dbgstr_guid(&format
));
374 hr
= IWICMetadataReader_GetMetadataFormat(reader
, NULL
);
375 ok(hr
== E_INVALIDARG
, "GetMetadataFormat failed, hr=%x\n", hr
);
378 U(id
).pszVal
= CoTaskMemAlloc(strlen("winetest") + 1);
379 strcpy(U(id
).pszVal
, "winetest");
381 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, NULL
);
382 ok(hr
== S_OK
, "GetValue failed, hr=%x\n", hr
);
384 hr
= IWICMetadataReader_GetValue(reader
, &schema
, NULL
, &value
);
385 ok(hr
== E_INVALIDARG
, "GetValue failed, hr=%x\n", hr
);
387 hr
= IWICMetadataReader_GetValue(reader
, &schema
, &id
, &value
);
388 ok(hr
== S_OK
, "GetValue failed, hr=%x\n", hr
);
389 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
390 ok(!strcmp(U(value
).pszVal
, "value"), "unexpected value: %s\n", U(value
).pszVal
);
391 PropVariantClear(&value
);
393 strcpy(U(id
).pszVal
, "test");
395 hr
= IWICMetadataReader_GetValue(reader
, &schema
, &id
, &value
);
396 ok(hr
== WINCODEC_ERR_PROPERTYNOTFOUND
, "GetValue failed, hr=%x\n", hr
);
398 PropVariantClear(&id
);
400 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, NULL
, NULL
);
401 ok(hr
== S_OK
, "GetValueByIndex failed, hr=%x\n", hr
);
403 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, &schema
, NULL
, NULL
);
404 ok(hr
== S_OK
, "GetValueByIndex failed, hr=%x\n", hr
);
405 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %i\n", schema
.vt
);
407 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, &id
, NULL
);
408 ok(hr
== S_OK
, "GetValueByIndex failed, hr=%x\n", hr
);
409 ok(id
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
410 ok(!strcmp(U(id
).pszVal
, "winetest"), "unexpected id: %s\n", U(id
).pszVal
);
411 PropVariantClear(&id
);
413 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, NULL
, &value
);
414 ok(hr
== S_OK
, "GetValueByIndex failed, hr=%x\n", hr
);
415 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", value
.vt
);
416 ok(!strcmp(U(value
).pszVal
, "value"), "unexpected value: %s\n", U(value
).pszVal
);
417 PropVariantClear(&value
);
419 hr
= IWICMetadataReader_GetValueByIndex(reader
, 1, NULL
, NULL
, NULL
);
420 ok(hr
== E_INVALIDARG
, "GetValueByIndex failed, hr=%x\n", hr
);
422 IWICMetadataReader_Release(reader
);
425 static void test_metadata_gAMA(void)
428 IWICMetadataReader
*reader
;
429 PROPVARIANT schema
, id
, value
;
432 static const WCHAR ImageGamma
[] = {'I','m','a','g','e','G','a','m','m','a',0};
434 PropVariantInit(&schema
);
435 PropVariantInit(&id
);
436 PropVariantInit(&value
);
438 hr
= CoCreateInstance(&CLSID_WICPngGamaMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
439 &IID_IWICMetadataReader
, (void**)&reader
);
440 ok(hr
== S_OK
|| broken(hr
== REGDB_E_CLASSNOTREG
) /*winxp*/, "CoCreateInstance failed, hr=%x\n", hr
);
441 if (FAILED(hr
)) return;
443 load_stream((IUnknown
*)reader
, metadata_gAMA
, sizeof(metadata_gAMA
), WICPersistOptionDefault
);
445 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
446 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
447 ok(IsEqualGUID(&format
, &GUID_MetadataFormatChunkgAMA
), "unexpected format %s\n", wine_dbgstr_guid(&format
));
449 hr
= IWICMetadataReader_GetCount(reader
, &count
);
450 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
451 ok(count
== 1, "unexpected count %i\n", count
);
453 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, &schema
, &id
, &value
);
454 ok(hr
== S_OK
, "GetValue failed, hr=%x\n", hr
);
456 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %i\n", schema
.vt
);
457 PropVariantClear(&schema
);
459 ok(id
.vt
== VT_LPWSTR
, "unexpected vt: %i\n", id
.vt
);
460 ok(!lstrcmpW(U(id
).pwszVal
, ImageGamma
), "unexpected value: %s\n", wine_dbgstr_w(U(id
).pwszVal
));
461 PropVariantClear(&id
);
463 ok(value
.vt
== VT_UI4
, "unexpected vt: %i\n", value
.vt
);
464 ok(U(value
).ulVal
== 33333, "unexpected value: %u\n", U(value
).ulVal
);
465 PropVariantClear(&value
);
467 IWICMetadataReader_Release(reader
);
470 static void test_metadata_cHRM(void)
473 IWICMetadataReader
*reader
;
474 PROPVARIANT schema
, id
, value
;
478 static const WCHAR expected_names
[8][12] = {
479 {'W','h','i','t','e','P','o','i','n','t','X',0},
480 {'W','h','i','t','e','P','o','i','n','t','Y',0},
483 {'G','r','e','e','n','X',0},
484 {'G','r','e','e','n','Y',0},
485 {'B','l','u','e','X',0},
486 {'B','l','u','e','Y',0},
488 static const ULONG expected_vals
[8] = {
489 31270,32900, 64000,33000, 30000,60000, 15000,6000
492 PropVariantInit(&schema
);
493 PropVariantInit(&id
);
494 PropVariantInit(&value
);
496 hr
= CoCreateInstance(&CLSID_WICPngChrmMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
497 &IID_IWICMetadataReader
, (void**)&reader
);
498 ok(hr
== S_OK
|| broken(hr
== REGDB_E_CLASSNOTREG
) /*winxp*/, "CoCreateInstance failed, hr=%x\n", hr
);
499 if (FAILED(hr
)) return;
501 load_stream((IUnknown
*)reader
, metadata_cHRM
, sizeof(metadata_cHRM
), WICPersistOptionDefault
);
503 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
504 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
505 ok(IsEqualGUID(&format
, &GUID_MetadataFormatChunkcHRM
), "unexpected format %s\n", wine_dbgstr_guid(&format
));
507 hr
= IWICMetadataReader_GetCount(reader
, &count
);
508 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
509 ok(count
== 8, "unexpected count %i\n", count
);
513 hr
= IWICMetadataReader_GetValueByIndex(reader
, i
, &schema
, &id
, &value
);
514 ok(hr
== S_OK
, "GetValue failed, hr=%x\n", hr
);
516 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %i\n", schema
.vt
);
517 PropVariantClear(&schema
);
519 ok(id
.vt
== VT_LPWSTR
, "unexpected vt: %i\n", id
.vt
);
520 ok(!lstrcmpW(U(id
).pwszVal
, expected_names
[i
]), "got %s, expected %s\n", wine_dbgstr_w(U(id
).pwszVal
), wine_dbgstr_w(expected_names
[i
]));
521 PropVariantClear(&id
);
523 ok(value
.vt
== VT_UI4
, "unexpected vt: %i\n", value
.vt
);
524 ok(U(value
).ulVal
== expected_vals
[i
], "got %u, expected %u\n", U(value
).ulVal
, expected_vals
[i
]);
525 PropVariantClear(&value
);
528 IWICMetadataReader_Release(reader
);
531 static inline USHORT
ushort_bswap(USHORT s
)
533 return (s
>> 8) | (s
<< 8);
536 static inline ULONG
ulong_bswap(ULONG l
)
538 return ((ULONG
)ushort_bswap((USHORT
)l
) << 16) | ushort_bswap((USHORT
)(l
>> 16));
541 static inline ULONGLONG
ulonglong_bswap(ULONGLONG ll
)
543 return ((ULONGLONG
)ulong_bswap((ULONG
)ll
) << 32) | ulong_bswap((ULONG
)(ll
>> 32));
546 static void byte_swap_ifd_data(char *data
)
548 USHORT number_of_entries
, i
;
549 struct IFD_entry
*entry
;
550 char *data_start
= data
;
552 number_of_entries
= *(USHORT
*)data
;
553 *(USHORT
*)data
= ushort_bswap(*(USHORT
*)data
);
554 data
+= sizeof(USHORT
);
556 for (i
= 0; i
< number_of_entries
; i
++)
558 entry
= (struct IFD_entry
*)data
;
566 if (entry
->count
> 4)
567 entry
->value
= ulong_bswap(entry
->value
);
572 if (entry
->count
> 2)
574 ULONG j
, count
= entry
->count
;
575 USHORT
*us
= (USHORT
*)(data_start
+ entry
->value
);
576 if (!count
) count
= 1;
577 for (j
= 0; j
< count
; j
++)
578 us
[j
] = ushort_bswap(us
[j
]);
580 entry
->value
= ulong_bswap(entry
->value
);
584 ULONG j
, count
= entry
->count
;
585 USHORT
*us
= (USHORT
*)&entry
->value
;
586 if (!count
) count
= 1;
587 for (j
= 0; j
< count
; j
++)
588 us
[j
] = ushort_bswap(us
[j
]);
595 if (entry
->count
> 1)
597 ULONG j
, count
= entry
->count
;
598 ULONG
*ul
= (ULONG
*)(data_start
+ entry
->value
);
599 if (!count
) count
= 1;
600 for (j
= 0; j
< count
; j
++)
601 ul
[j
] = ulong_bswap(ul
[j
]);
603 entry
->value
= ulong_bswap(entry
->value
);
610 ULONG
*ul
= (ULONG
*)(data_start
+ entry
->value
);
611 for (j
= 0; j
< entry
->count
* 2; j
++)
612 ul
[j
] = ulong_bswap(ul
[j
]);
614 entry
->value
= ulong_bswap(entry
->value
);
620 ULONGLONG
*ull
= (ULONGLONG
*)(data_start
+ entry
->value
);
621 for (j
= 0; j
< entry
->count
; j
++)
622 ull
[j
] = ulonglong_bswap(ull
[j
]);
624 entry
->value
= ulong_bswap(entry
->value
);
632 entry
->id
= ushort_bswap(entry
->id
);
633 entry
->type
= ushort_bswap(entry
->type
);
634 entry
->count
= ulong_bswap(entry
->count
);
635 data
+= sizeof(*entry
);
642 int count
; /* if VT_VECTOR */
645 const WCHAR id_string
[32];
648 static void compare_metadata(IWICMetadataReader
*reader
, const struct test_data
*td
, ULONG count
)
651 IWICEnumMetadataItem
*enumerator
;
652 PROPVARIANT schema
, id
, value
;
653 ULONG items_returned
, i
;
655 hr
= IWICMetadataReader_GetEnumerator(reader
, NULL
);
656 ok(hr
== E_INVALIDARG
, "GetEnumerator error %#x\n", hr
);
658 hr
= IWICMetadataReader_GetEnumerator(reader
, &enumerator
);
659 ok(hr
== S_OK
, "GetEnumerator error %#x\n", hr
);
661 PropVariantInit(&schema
);
662 PropVariantInit(&id
);
663 PropVariantInit(&value
);
665 for (i
= 0; i
< count
; i
++)
667 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
668 ok(hr
== S_OK
, "Next error %#x\n", hr
);
669 ok(items_returned
== 1, "unexpected item count %u\n", items_returned
);
671 ok(schema
.vt
== VT_EMPTY
, "%u: unexpected vt: %u\n", i
, schema
.vt
);
672 ok(id
.vt
== VT_UI2
|| id
.vt
== VT_LPWSTR
|| id
.vt
== VT_EMPTY
, "%u: unexpected vt: %u\n", i
, id
.vt
);
674 ok(U(id
).uiVal
== td
[i
].id
, "%u: expected id %#x, got %#x\n", i
, td
[i
].id
, U(id
).uiVal
);
675 else if (id
.vt
== VT_LPWSTR
)
676 ok(!lstrcmpW(td
[i
].id_string
, U(id
).pwszVal
),
677 "%u: expected %s, got %s\n", i
, wine_dbgstr_w(td
[i
].id_string
), wine_dbgstr_w(U(id
).pwszVal
));
679 ok(value
.vt
== td
[i
].type
, "%u: expected vt %#x, got %#x\n", i
, td
[i
].type
, value
.vt
);
680 if (value
.vt
& VT_VECTOR
)
683 switch (value
.vt
& ~VT_VECTOR
)
687 ok(td
[i
].count
== U(value
).caub
.cElems
, "%u: expected cElems %d, got %d\n", i
, td
[i
].count
, U(value
).caub
.cElems
);
688 for (j
= 0; j
< U(value
).caub
.cElems
; j
++)
689 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
]);
693 ok(td
[i
].count
== U(value
).caui
.cElems
, "%u: expected cElems %d, got %d\n", i
, td
[i
].count
, U(value
).caui
.cElems
);
694 for (j
= 0; j
< U(value
).caui
.cElems
; j
++)
695 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
]);
700 ok(td
[i
].count
== U(value
).caul
.cElems
, "%u: expected cElems %d, got %d\n", i
, td
[i
].count
, U(value
).caul
.cElems
);
701 for (j
= 0; j
< U(value
).caul
.cElems
; j
++)
702 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
]);
707 ok(td
[i
].count
== U(value
).cauh
.cElems
, "%u: expected cElems %d, got %d\n", i
, td
[i
].count
, U(value
).cauh
.cElems
);
708 for (j
= 0; j
< U(value
).cauh
.cElems
; j
++)
709 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
);
712 ok(td
[i
].count
== U(value
).calpstr
.cElems
, "%u: expected cElems %d, got %d\n", i
, td
[i
].count
, U(value
).caub
.cElems
);
713 for (j
= 0; j
< U(value
).calpstr
.cElems
; j
++)
714 trace("%u: %s\n", j
, U(value
).calpstr
.pElems
[j
]);
715 /* fall through to not handled message */
717 ok(0, "%u: array of type %d is not handled\n", i
, value
.vt
& ~VT_VECTOR
);
721 else if (value
.vt
== VT_LPSTR
)
723 ok(td
[i
].count
== strlen(U(value
).pszVal
) ||
724 broken(td
[i
].count
== strlen(U(value
).pszVal
) + 1), /* before Win7 */
725 "%u: expected count %d, got %d\n", i
, td
[i
].count
, lstrlenA(U(value
).pszVal
));
726 if (td
[i
].count
== strlen(U(value
).pszVal
))
727 ok(!strcmp(td
[i
].string
, U(value
).pszVal
),
728 "%u: expected %s, got %s\n", i
, td
[i
].string
, U(value
).pszVal
);
730 else if (value
.vt
== VT_BLOB
)
732 ok(td
[i
].count
== U(value
).blob
.cbSize
, "%u: expected count %d, got %d\n", i
, td
[i
].count
, U(value
).blob
.cbSize
);
733 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
);
736 ok(U(value
).uhVal
.QuadPart
== td
[i
].value
[0], "%u: expected value %#x/%#x got %#x/%#x\n",
737 i
, (UINT
)td
[i
].value
[0], (UINT
)(td
[i
].value
[0] >> 32), U(value
).uhVal
.u
.LowPart
, U(value
).uhVal
.u
.HighPart
);
739 PropVariantClear(&schema
);
740 PropVariantClear(&id
);
741 PropVariantClear(&value
);
744 hr
= IWICEnumMetadataItem_Next(enumerator
, 1, &schema
, &id
, &value
, &items_returned
);
745 ok(hr
== S_FALSE
, "Next should fail\n");
746 ok(items_returned
== 0, "unexpected item count %u\n", items_returned
);
748 IWICEnumMetadataItem_Release(enumerator
);
751 static void test_metadata_IFD(void)
753 static const struct test_data td
[28] =
755 { VT_UI2
, 0xfe, 0, { 1 } },
756 { VT_UI4
, 0x100, 0, { 222 } },
757 { VT_UI4
, 0x101, 0, { 333 } },
758 { VT_UI2
, 0x102, 0, { 24 } },
759 { VT_UI4
, 0x103, 0, { 32773 } },
760 { VT_UI8
, 0x11a, 0, { ((LONGLONG
)3 << 32) | 900 } },
761 { VT_UI1
, 0xf001, 0, { 0x44 } },
762 { VT_UI1
|VT_VECTOR
, 0xf002, 4, { 0x44, 0x33, 0x22, 0x11 } },
763 { VT_I1
, 0xf003, 0, { 0x44 } },
764 { VT_I2
, 0xf004, 0, { 0x3344 } },
765 { VT_I2
|VT_VECTOR
, 0xf005, 2, { 0x3344, 0x1122 } },
766 { VT_I4
, 0xf006, 0, { 0x11223344 } },
767 { VT_R4
, 0xf007, 0, { 0x11223344 } },
768 { VT_R8
, 0xf008, 0, { ((LONGLONG
)0x41d26580 << 32) | 0xb486522c } },
769 { VT_I8
, 0xf009, 0, { ((LONGLONG
)0x5a6b7c8d << 32) | 0x1a2b3c4d } },
770 { VT_UI1
|VT_VECTOR
, 0xf00a, 13, { 'H','e','l','l','o',' ','W','o','r','l','d','!',0 } },
771 { VT_I2
|VT_VECTOR
, 0xf00b, 4, { 0x0101, 0x0202, 0x0303, 0x0404 } },
772 { VT_I4
|VT_VECTOR
, 0xf00c, 2, { 0x11223344, 0x55667788 } },
773 { VT_R4
|VT_VECTOR
, 0xf00d, 2, { 0x449a522b, 0x4608f5ba } },
774 { VT_LPSTR
, 0xf00e, 12, { 0 }, "Hello World!" },
775 { VT_LPSTR
, 0xf00f, 4, { 0 }, "abcd" },
776 { VT_BLOB
, 0xf010, 13, { 0 }, "Hello World!" },
777 { VT_BLOB
, 0xf011, 4, { 0 }, "abcd" },
778 { VT_UI1
, 0xf012, 0, { 0x44 } },
779 { VT_UI2
, 0xf013, 0, { 0x3344 } },
780 { VT_UI4
, 0xf014, 0, { 0x11223344 } },
781 { VT_R4
, 0xf015, 0, { 0x11223344 } },
782 { VT_I8
|VT_VECTOR
, 0xf016, 3,
783 { ((LONGLONG
)0x05060708 << 32) | 0x01020304,
784 ((LONGLONG
)0x50607080 << 32) | 0x10203040,
785 ((LONGLONG
)0x55667788 << 32) | 0x11223344 } },
788 IWICMetadataReader
*reader
;
789 IWICMetadataBlockReader
*blockreader
;
790 PROPVARIANT schema
, id
, value
;
793 char *IFD_data_swapped
;
794 #ifdef WORDS_BIGENDIAN
795 DWORD persist_options
= WICPersistOptionBigEndian
;
797 DWORD persist_options
= WICPersistOptionLittleEndian
;
800 hr
= CoCreateInstance(&CLSID_WICIfdMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
801 &IID_IWICMetadataReader
, (void**)&reader
);
802 ok(hr
== S_OK
, "CoCreateInstance error %#x\n", hr
);
804 hr
= IWICMetadataReader_GetCount(reader
, NULL
);
805 ok(hr
== E_INVALIDARG
, "GetCount error %#x\n", hr
);
807 hr
= IWICMetadataReader_GetCount(reader
, &count
);
808 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
809 ok(count
== 0, "unexpected count %u\n", count
);
811 load_stream((IUnknown
*)reader
, (const char *)&IFD_data
, sizeof(IFD_data
), persist_options
);
813 hr
= IWICMetadataReader_GetCount(reader
, &count
);
814 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
815 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
817 compare_metadata(reader
, td
, count
);
819 /* test IFD data with different endianness */
820 if (persist_options
== WICPersistOptionLittleEndian
)
821 persist_options
= WICPersistOptionBigEndian
;
823 persist_options
= WICPersistOptionLittleEndian
;
825 IFD_data_swapped
= HeapAlloc(GetProcessHeap(), 0, sizeof(IFD_data
));
826 memcpy(IFD_data_swapped
, &IFD_data
, sizeof(IFD_data
));
827 byte_swap_ifd_data(IFD_data_swapped
);
828 load_stream((IUnknown
*)reader
, IFD_data_swapped
, sizeof(IFD_data
), persist_options
);
829 hr
= IWICMetadataReader_GetCount(reader
, &count
);
830 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
831 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
832 compare_metadata(reader
, td
, count
);
833 HeapFree(GetProcessHeap(), 0, IFD_data_swapped
);
835 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
836 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
837 ok(IsEqualGUID(&format
, &GUID_MetadataFormatIfd
), "unexpected format %s\n", wine_dbgstr_guid(&format
));
839 hr
= IWICMetadataReader_GetMetadataFormat(reader
, NULL
);
840 ok(hr
== E_INVALIDARG
, "GetMetadataFormat should fail\n");
842 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, NULL
, NULL
);
843 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
845 PropVariantInit(&schema
);
846 PropVariantInit(&id
);
847 PropVariantInit(&value
);
849 hr
= IWICMetadataReader_GetValueByIndex(reader
, count
- 1, NULL
, NULL
, NULL
);
850 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
852 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, &schema
, NULL
, NULL
);
853 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
854 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %u\n", schema
.vt
);
856 hr
= IWICMetadataReader_GetValueByIndex(reader
, count
- 1, &schema
, NULL
, NULL
);
857 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
858 ok(schema
.vt
== VT_EMPTY
, "unexpected vt: %u\n", schema
.vt
);
860 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, &id
, NULL
);
861 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
862 ok(id
.vt
== VT_UI2
, "unexpected vt: %u\n", id
.vt
);
863 ok(U(id
).uiVal
== 0xfe, "unexpected id: %#x\n", U(id
).uiVal
);
864 PropVariantClear(&id
);
866 hr
= IWICMetadataReader_GetValueByIndex(reader
, 0, NULL
, NULL
, &value
);
867 ok(hr
== S_OK
, "GetValueByIndex error %#x\n", hr
);
868 ok(value
.vt
== VT_UI2
, "unexpected vt: %u\n", value
.vt
);
869 ok(U(value
).uiVal
== 1, "unexpected id: %#x\n", U(value
).uiVal
);
870 PropVariantClear(&value
);
872 hr
= IWICMetadataReader_GetValueByIndex(reader
, count
, &schema
, NULL
, NULL
);
873 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
875 PropVariantInit(&schema
);
876 PropVariantInit(&id
);
877 PropVariantInit(&value
);
879 hr
= IWICMetadataReader_GetValue(reader
, &schema
, &id
, &value
);
880 ok(hr
== WINCODEC_ERR_PROPERTYNOTFOUND
, "expected WINCODEC_ERR_PROPERTYNOTFOUND, got %#x\n", hr
);
882 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, NULL
);
883 ok(hr
== WINCODEC_ERR_PROPERTYNOTFOUND
, "expected WINCODEC_ERR_PROPERTYNOTFOUND, got %#x\n", hr
);
885 hr
= IWICMetadataReader_GetValue(reader
, &schema
, NULL
, NULL
);
886 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
888 hr
= IWICMetadataReader_GetValue(reader
, &schema
, &id
, NULL
);
889 ok(hr
== WINCODEC_ERR_PROPERTYNOTFOUND
, "expected WINCODEC_ERR_PROPERTYNOTFOUND, got %#x\n", hr
);
891 hr
= IWICMetadataReader_GetValue(reader
, &schema
, NULL
, &value
);
892 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
895 U(id
).uiVal
= 0xf00e;
896 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, NULL
);
897 ok(hr
== S_OK
, "GetValue error %#x\n", hr
);
899 /* schema is ignored by Ifd metadata reader */
901 U(schema
).ulVal
= 0xdeadbeef;
902 hr
= IWICMetadataReader_GetValue(reader
, &schema
, &id
, &value
);
903 ok(hr
== S_OK
, "GetValue error %#x\n", hr
);
904 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
905 ok(!strcmp(U(value
).pszVal
, "Hello World!"), "unexpected value: %s\n", U(value
).pszVal
);
906 PropVariantClear(&value
);
908 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, &value
);
909 ok(hr
== S_OK
, "GetValue error %#x\n", hr
);
910 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
911 ok(!strcmp(U(value
).pszVal
, "Hello World!"), "unexpected value: %s\n", U(value
).pszVal
);
912 PropVariantClear(&value
);
914 hr
= IWICMetadataReader_QueryInterface(reader
, &IID_IWICMetadataBlockReader
, (void**)&blockreader
);
915 ok(hr
== E_NOINTERFACE
, "QueryInterface failed, hr=%x\n", hr
);
918 IWICMetadataBlockReader_Release(blockreader
);
920 IWICMetadataReader_Release(reader
);
923 static void test_metadata_Exif(void)
926 IWICMetadataReader
*reader
;
927 IWICMetadataBlockReader
*blockreader
;
930 hr
= CoCreateInstance(&CLSID_WICExifMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
931 &IID_IWICMetadataReader
, (void**)&reader
);
932 todo_wine
ok(hr
== S_OK
, "CoCreateInstance error %#x\n", hr
);
933 if (FAILED(hr
)) return;
935 hr
= IWICMetadataReader_GetCount(reader
, NULL
);
936 ok(hr
== E_INVALIDARG
, "GetCount error %#x\n", hr
);
938 hr
= IWICMetadataReader_GetCount(reader
, &count
);
939 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
940 ok(count
== 0, "unexpected count %u\n", count
);
942 hr
= IWICMetadataReader_QueryInterface(reader
, &IID_IWICMetadataBlockReader
, (void**)&blockreader
);
943 ok(hr
== E_NOINTERFACE
, "QueryInterface failed, hr=%x\n", hr
);
946 IWICMetadataBlockReader_Release(blockreader
);
948 IWICMetadataReader_Release(reader
);
951 static void test_create_reader(void)
954 IWICComponentFactory
*factory
;
956 IWICMetadataReader
*reader
;
960 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
961 &IID_IWICComponentFactory
, (void**)&factory
);
962 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
964 stream
= create_stream(metadata_tEXt
, sizeof(metadata_tEXt
));
966 hr
= IWICComponentFactory_CreateMetadataReaderFromContainer(factory
,
967 NULL
, NULL
, WICPersistOptionDefault
,
969 ok(hr
== E_INVALIDARG
, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr
);
971 hr
= IWICComponentFactory_CreateMetadataReaderFromContainer(factory
,
972 &GUID_ContainerFormatPng
, NULL
, WICPersistOptionDefault
,
974 ok(hr
== E_INVALIDARG
, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr
);
976 hr
= IWICComponentFactory_CreateMetadataReaderFromContainer(factory
,
977 &GUID_ContainerFormatPng
, NULL
, WICPersistOptionDefault
,
979 ok(hr
== E_INVALIDARG
, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr
);
981 hr
= IWICComponentFactory_CreateMetadataReaderFromContainer(factory
,
982 &GUID_ContainerFormatPng
, NULL
, WICPersistOptionDefault
,
984 ok(hr
== S_OK
, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr
);
988 hr
= IWICMetadataReader_GetCount(reader
, &count
);
989 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
990 ok(count
== 1, "unexpected count %i\n", count
);
992 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
993 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
994 ok(IsEqualGUID(&format
, &GUID_MetadataFormatChunktEXt
), "unexpected format %s\n", wine_dbgstr_guid(&format
));
996 IWICMetadataReader_Release(reader
);
999 hr
= IWICComponentFactory_CreateMetadataReaderFromContainer(factory
,
1000 &GUID_ContainerFormatWmp
, NULL
, WICPersistOptionDefault
,
1002 ok(hr
== S_OK
, "CreateMetadataReaderFromContainer failed, hr=%x\n", hr
);
1006 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1007 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
1008 ok(count
== 1, "unexpected count %i\n", count
);
1010 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1011 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
1012 ok(IsEqualGUID(&format
, &GUID_MetadataFormatUnknown
), "unexpected format %s\n", wine_dbgstr_guid(&format
));
1014 IWICMetadataReader_Release(reader
);
1017 IStream_Release(stream
);
1019 IWICComponentFactory_Release(factory
);
1022 static void test_metadata_png(void)
1024 static const struct test_data td
[6] =
1026 { VT_UI2
, 0, 0, { 2005 }, NULL
, { 'Y','e','a','r',0 } },
1027 { VT_UI1
, 0, 0, { 6 }, NULL
, { 'M','o','n','t','h',0 } },
1028 { VT_UI1
, 0, 0, { 3 }, NULL
, { 'D','a','y',0 } },
1029 { VT_UI1
, 0, 0, { 15 }, NULL
, { 'H','o','u','r',0 } },
1030 { VT_UI1
, 0, 0, { 7 }, NULL
, { 'M','i','n','u','t','e',0 } },
1031 { VT_UI1
, 0, 0, { 45 }, NULL
, { 'S','e','c','o','n','d',0 } }
1034 IWICBitmapDecoder
*decoder
;
1035 IWICBitmapFrameDecode
*frame
;
1036 IWICMetadataBlockReader
*blockreader
;
1037 IWICMetadataReader
*reader
;
1038 IWICMetadataQueryReader
*queryreader
;
1039 IWICComponentFactory
*factory
;
1040 GUID containerformat
;
1042 UINT count
=0xdeadbeef;
1044 hr
= CoCreateInstance(&CLSID_WICPngDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
1045 &IID_IWICBitmapDecoder
, (void**)&decoder
);
1046 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
1048 if (FAILED(hr
)) return;
1050 stream
= create_stream(pngimage
, sizeof(pngimage
));
1052 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnLoad
);
1053 ok(hr
== S_OK
, "Initialize failed, hr=%x\n", hr
);
1055 hr
= IWICBitmapDecoder_QueryInterface(decoder
, &IID_IWICMetadataBlockReader
, (void**)&blockreader
);
1056 ok(hr
== E_NOINTERFACE
, "QueryInterface failed, hr=%x\n", hr
);
1058 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &frame
);
1059 ok(hr
== S_OK
, "GetFrame failed, hr=%x\n", hr
);
1061 hr
= IWICBitmapFrameDecode_QueryInterface(frame
, &IID_IWICMetadataBlockReader
, (void**)&blockreader
);
1062 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
1066 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, NULL
);
1067 ok(hr
== E_INVALIDARG
, "GetContainerFormat failed, hr=%x\n", hr
);
1069 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, &containerformat
);
1070 ok(hr
== S_OK
, "GetContainerFormat failed, hr=%x\n", hr
);
1071 ok(IsEqualGUID(&containerformat
, &GUID_ContainerFormatPng
), "unexpected container format\n");
1073 hr
= IWICMetadataBlockReader_GetCount(blockreader
, NULL
);
1074 ok(hr
== E_INVALIDARG
, "GetCount failed, hr=%x\n", hr
);
1076 hr
= IWICMetadataBlockReader_GetCount(blockreader
, &count
);
1077 ok(hr
== S_OK
, "GetCount failed, hr=%x\n", hr
);
1078 ok(count
== 1, "unexpected count %d\n", count
);
1082 /* Crashes on Windows XP */
1083 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, NULL
);
1084 ok(hr
== E_INVALIDARG
, "GetReaderByIndex failed, hr=%x\n", hr
);
1087 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, &reader
);
1088 ok(hr
== S_OK
, "GetReaderByIndex failed, hr=%x\n", hr
);
1092 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &containerformat
);
1093 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1094 todo_wine
ok(IsEqualGUID(&containerformat
, &GUID_MetadataFormatChunktIME
) ||
1095 broken(IsEqualGUID(&containerformat
, &GUID_MetadataFormatUnknown
)) /* Windows XP */,
1096 "unexpected container format\n");
1098 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1099 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1100 todo_wine
ok(count
== 6 || broken(count
== 1) /* XP */, "expected 6, got %u\n", count
);
1102 compare_metadata(reader
, td
, count
);
1104 IWICMetadataReader_Release(reader
);
1107 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 1, &reader
);
1108 todo_wine
ok(hr
== WINCODEC_ERR_VALUEOUTOFRANGE
, "GetReaderByIndex failed, hr=%x\n", hr
);
1110 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
1111 &IID_IWICComponentFactory
, (void**)&factory
);
1112 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
1114 hr
= IWICComponentFactory_CreateQueryReaderFromBlockReader(factory
, NULL
, &queryreader
);
1115 ok(hr
== E_INVALIDARG
, "CreateQueryReaderFromBlockReader should have failed: %08x\n", hr
);
1117 hr
= IWICComponentFactory_CreateQueryReaderFromBlockReader(factory
, blockreader
, NULL
);
1118 ok(hr
== E_INVALIDARG
, "CreateQueryReaderFromBlockReader should have failed: %08x\n", hr
);
1120 hr
= IWICComponentFactory_CreateQueryReaderFromBlockReader(factory
, blockreader
, &queryreader
);
1121 ok(hr
== S_OK
, "CreateQueryReaderFromBlockReader failed: %08x\n", hr
);
1123 IWICMetadataQueryReader_Release(queryreader
);
1125 IWICComponentFactory_Release(factory
);
1127 IWICMetadataBlockReader_Release(blockreader
);
1130 hr
= IWICBitmapFrameDecode_GetMetadataQueryReader(frame
, &queryreader
);
1131 ok(hr
== S_OK
, "GetMetadataQueryReader failed: %08x\n", hr
);
1135 IWICMetadataQueryReader_Release(queryreader
);
1138 IWICBitmapFrameDecode_Release(frame
);
1140 IWICBitmapDecoder_Release(decoder
);
1142 IStream_Release(stream
);
1145 static void test_metadata_gif(void)
1147 static const struct test_data gif_LSD
[9] =
1149 { VT_UI1
|VT_VECTOR
, 0, 6, {'G','I','F','8','7','a'}, NULL
, { 'S','i','g','n','a','t','u','r','e',0 } },
1150 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'W','i','d','t','h',0 } },
1151 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'H','e','i','g','h','t',0 } },
1152 { 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 } },
1153 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'C','o','l','o','r','R','e','s','o','l','u','t','i','o','n',0 } },
1154 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1155 { 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 } },
1156 { 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 } },
1157 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'P','i','x','e','l','A','s','p','e','c','t','R','a','t','i','o',0 } }
1159 static const struct test_data gif_IMD
[8] =
1161 { VT_UI2
, 0, 0, { 0 }, NULL
, { 'L','e','f','t',0 } },
1162 { VT_UI2
, 0, 0, { 0 }, NULL
, { 'T','o','p',0 } },
1163 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'W','i','d','t','h',0 } },
1164 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'H','e','i','g','h','t',0 } },
1165 { 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 } },
1166 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'I','n','t','e','r','l','a','c','e','F','l','a','g',0 } },
1167 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1168 { 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 } }
1170 static const struct test_data animated_gif_LSD
[9] =
1172 { VT_UI1
|VT_VECTOR
, 0, 6, {'G','I','F','8','9','a'}, NULL
, { 'S','i','g','n','a','t','u','r','e',0 } },
1173 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'W','i','d','t','h',0 } },
1174 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'H','e','i','g','h','t',0 } },
1175 { 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 } },
1176 { VT_UI1
, 0, 0, { 2 }, NULL
, { 'C','o','l','o','r','R','e','s','o','l','u','t','i','o','n',0 } },
1177 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1178 { 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 } },
1179 { 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 } },
1180 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'P','i','x','e','l','A','s','p','e','c','t','R','a','t','i','o',0 } }
1182 static const struct test_data animated_gif_IMD
[8] =
1184 { VT_UI2
, 0, 0, { 0 }, NULL
, { 'L','e','f','t',0 } },
1185 { VT_UI2
, 0, 0, { 0 }, NULL
, { 'T','o','p',0 } },
1186 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'W','i','d','t','h',0 } },
1187 { VT_UI2
, 0, 0, { 1 }, NULL
, { 'H','e','i','g','h','t',0 } },
1188 { 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 } },
1189 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'I','n','t','e','r','l','a','c','e','F','l','a','g',0 } },
1190 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1191 { 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 } }
1193 static const struct test_data animated_gif_GCE
[5] =
1195 { VT_UI1
, 0, 0, { 0 }, NULL
, { 'D','i','s','p','o','s','a','l',0 } },
1196 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'U','s','e','r','I','n','p','u','t','F','l','a','g',0 } },
1197 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'T','r','a','n','s','p','a','r','e','n','c','y','F','l','a','g',0 } },
1198 { VT_UI2
, 0, 0, { 10 }, NULL
, { 'D','e','l','a','y',0 } },
1199 { 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 } }
1201 static const struct test_data animated_gif_APE
[2] =
1203 { 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 } },
1204 { VT_UI1
|VT_VECTOR
, 0, 4, { 0x03,0x01,0x05,0x00 }, NULL
, { 'D','a','t','a',0 } }
1206 static const struct test_data animated_gif_comment_1
[1] =
1208 { VT_LPSTR
, 0, 12, { 0 }, "Hello World!", { 'T','e','x','t','E','n','t','r','y',0 } }
1210 static const struct test_data animated_gif_comment_2
[1] =
1212 { VT_LPSTR
, 0, 8, { 0 }, "image #1", { 'T','e','x','t','E','n','t','r','y',0 } }
1214 static const struct test_data animated_gif_plain_1
[1] =
1216 { VT_BLOB
, 0, 17, { 0 }, "\x21\x01\x0d\x61nimation.gif" }
1218 static const struct test_data animated_gif_plain_2
[1] =
1220 { VT_BLOB
, 0, 16, { 0 }, "\x21\x01\x0cplaintext #1" }
1223 IWICBitmapDecoder
*decoder
;
1224 IWICBitmapFrameDecode
*frame
;
1225 IWICMetadataBlockReader
*blockreader
;
1226 IWICMetadataReader
*reader
;
1227 IWICMetadataQueryReader
*queryreader
;
1233 stream
= create_stream(gifimage
, sizeof(gifimage
));
1235 hr
= CoCreateInstance(&CLSID_WICGifDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
1236 &IID_IWICBitmapDecoder
, (void **)&decoder
);
1237 ok(hr
== S_OK
, "CoCreateInstance error %#x\n", hr
);
1238 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnLoad
);
1239 ok(hr
== S_OK
, "Initialize error %#x\n", hr
);
1241 IStream_Release(stream
);
1243 /* global metadata block */
1244 hr
= IWICBitmapDecoder_QueryInterface(decoder
, &IID_IWICMetadataBlockReader
, (void **)&blockreader
);
1245 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* before Win7 */, "QueryInterface error %#x\n", hr
);
1249 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, &format
);
1250 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
1251 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
1252 "wrong container format %s\n", wine_dbgstr_guid(&format
));
1254 hr
= IWICMetadataBlockReader_GetCount(blockreader
, &count
);
1255 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1256 ok(count
== 1, "expected 1, got %u\n", count
);
1258 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, &reader
);
1259 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1263 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1264 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1265 ok(IsEqualGUID(&format
, &GUID_MetadataFormatLSD
), /* Logical Screen Descriptor */
1266 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1268 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1269 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1270 ok(count
== sizeof(gif_LSD
)/sizeof(gif_LSD
[0]), "unexpected count %u\n", count
);
1272 compare_metadata(reader
, gif_LSD
, count
);
1274 IWICMetadataReader_Release(reader
);
1277 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 1, &reader
);
1278 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1280 IWICMetadataBlockReader_Release(blockreader
);
1283 /* frame metadata block */
1284 hr
= IWICBitmapDecoder_GetFrame(decoder
, 0, &frame
);
1285 ok(hr
== S_OK
, "GetFrame error %#x\n", hr
);
1287 hr
= IWICBitmapFrameDecode_QueryInterface(frame
, &IID_IWICMetadataBlockReader
, (void **)&blockreader
);
1288 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* before Win7 */, "QueryInterface error %#x\n", hr
);
1292 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, NULL
);
1293 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1295 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, &format
);
1296 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
1297 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
1298 "wrong container format %s\n", wine_dbgstr_guid(&format
));
1300 hr
= IWICMetadataBlockReader_GetCount(blockreader
, NULL
);
1301 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1303 hr
= IWICMetadataBlockReader_GetCount(blockreader
, &count
);
1304 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1305 ok(count
== 1, "expected 1, got %u\n", count
);
1307 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, &reader
);
1308 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1312 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1313 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1314 ok(IsEqualGUID(&format
, &GUID_MetadataFormatIMD
), /* Image Descriptor */
1315 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1317 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1318 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1319 ok(count
== sizeof(gif_IMD
)/sizeof(gif_IMD
[0]), "unexpected count %u\n", count
);
1321 compare_metadata(reader
, gif_IMD
, count
);
1323 IWICMetadataReader_Release(reader
);
1326 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 1, &reader
);
1327 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1329 IWICMetadataBlockReader_Release(blockreader
);
1332 IWICBitmapFrameDecode_Release(frame
);
1333 IWICBitmapDecoder_Release(decoder
);
1335 /* 1x1 pixel gif, 2 frames */
1336 stream
= create_stream(animatedgif
, sizeof(animatedgif
));
1338 hr
= CoCreateInstance(&CLSID_WICGifDecoder
, NULL
, CLSCTX_INPROC_SERVER
,
1339 &IID_IWICBitmapDecoder
, (void **)&decoder
);
1340 ok(hr
== S_OK
, "CoCreateInstance error %#x\n", hr
);
1341 hr
= IWICBitmapDecoder_Initialize(decoder
, stream
, WICDecodeMetadataCacheOnLoad
);
1342 ok(hr
== S_OK
, "Initialize error %#x\n", hr
);
1344 IStream_Release(stream
);
1346 /* global metadata block */
1347 hr
= IWICBitmapDecoder_QueryInterface(decoder
, &IID_IWICMetadataBlockReader
, (void **)&blockreader
);
1348 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* before Win7 */, "QueryInterface error %#x\n", hr
);
1352 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, &format
);
1353 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
1354 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
1355 "wrong container format %s\n", wine_dbgstr_guid(&format
));
1357 hr
= IWICMetadataBlockReader_GetCount(blockreader
, &count
);
1358 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1359 ok(count
== 4, "expected 4, got %u\n", count
);
1361 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, &reader
);
1362 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1366 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1367 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1368 ok(IsEqualGUID(&format
, &GUID_MetadataFormatLSD
), /* Logical Screen Descriptor */
1369 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1371 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1372 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1373 ok(count
== sizeof(animated_gif_LSD
)/sizeof(animated_gif_LSD
[0]), "unexpected count %u\n", count
);
1375 compare_metadata(reader
, animated_gif_LSD
, count
);
1377 IWICMetadataReader_Release(reader
);
1380 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 1, &reader
);
1381 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1385 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1386 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1387 ok(IsEqualGUID(&format
, &GUID_MetadataFormatAPE
), /* Application Extension */
1388 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1390 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1391 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1392 ok(count
== sizeof(animated_gif_APE
)/sizeof(animated_gif_APE
[0]), "unexpected count %u\n", count
);
1394 compare_metadata(reader
, animated_gif_APE
, count
);
1396 IWICMetadataReader_Release(reader
);
1399 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 2, &reader
);
1400 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1404 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1405 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1406 ok(IsEqualGUID(&format
, &GUID_MetadataFormatGifComment
), /* Comment Extension */
1407 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1409 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1410 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1411 ok(count
== sizeof(animated_gif_comment_1
)/sizeof(animated_gif_comment_1
[0]), "unexpected count %u\n", count
);
1413 compare_metadata(reader
, animated_gif_comment_1
, count
);
1415 IWICMetadataReader_Release(reader
);
1418 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 3, &reader
);
1419 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1423 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1424 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1425 ok(IsEqualGUID(&format
, &GUID_MetadataFormatUnknown
),
1426 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1428 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1429 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1430 ok(count
== sizeof(animated_gif_plain_1
)/sizeof(animated_gif_plain_1
[0]), "unexpected count %u\n", count
);
1432 compare_metadata(reader
, animated_gif_plain_1
, count
);
1434 IWICMetadataReader_Release(reader
);
1437 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 4, &reader
);
1438 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1440 IWICMetadataBlockReader_Release(blockreader
);
1443 /* frame metadata block */
1444 hr
= IWICBitmapDecoder_GetFrame(decoder
, 1, &frame
);
1445 ok(hr
== S_OK
, "GetFrame error %#x\n", hr
);
1447 hr
= IWICBitmapFrameDecode_QueryInterface(frame
, &IID_IWICMetadataBlockReader
, (void **)&blockreader
);
1448 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
) /* before Win7 */, "QueryInterface error %#x\n", hr
);
1452 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, NULL
);
1453 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1455 hr
= IWICMetadataBlockReader_GetContainerFormat(blockreader
, &format
);
1456 ok(hr
== S_OK
, "GetContainerFormat error %#x\n", hr
);
1457 ok(IsEqualGUID(&format
, &GUID_ContainerFormatGif
),
1458 "wrong container format %s\n", wine_dbgstr_guid(&format
));
1460 hr
= IWICMetadataBlockReader_GetCount(blockreader
, NULL
);
1461 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1463 hr
= IWICMetadataBlockReader_GetCount(blockreader
, &count
);
1464 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1465 ok(count
== 4, "expected 4, got %u\n", count
);
1467 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 0, &reader
);
1468 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1472 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1473 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1474 ok(IsEqualGUID(&format
, &GUID_MetadataFormatIMD
), /* Image Descriptor */
1475 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1477 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1478 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1479 ok(count
== sizeof(animated_gif_IMD
)/sizeof(animated_gif_IMD
[0]), "unexpected count %u\n", count
);
1481 compare_metadata(reader
, animated_gif_IMD
, count
);
1483 IWICMetadataReader_Release(reader
);
1486 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 1, &reader
);
1487 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1491 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1492 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1493 ok(IsEqualGUID(&format
, &GUID_MetadataFormatGifComment
), /* Comment Extension */
1494 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1496 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1497 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1498 ok(count
== sizeof(animated_gif_comment_2
)/sizeof(animated_gif_comment_2
[0]), "unexpected count %u\n", count
);
1501 compare_metadata(reader
, animated_gif_comment_2
, count
);
1503 IWICMetadataReader_Release(reader
);
1506 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 2, &reader
);
1507 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1511 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1512 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1513 ok(IsEqualGUID(&format
, &GUID_MetadataFormatUnknown
),
1514 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1516 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1517 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1518 ok(count
== sizeof(animated_gif_plain_2
)/sizeof(animated_gif_plain_2
[0]), "unexpected count %u\n", count
);
1520 compare_metadata(reader
, animated_gif_plain_2
, count
);
1522 IWICMetadataReader_Release(reader
);
1525 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 3, &reader
);
1526 ok(hr
== S_OK
, "GetReaderByIndex error %#x\n", hr
);
1530 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1531 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%#x\n", hr
);
1532 ok(IsEqualGUID(&format
, &GUID_MetadataFormatGCE
), /* Graphic Control Extension */
1533 "wrong metadata format %s\n", wine_dbgstr_guid(&format
));
1535 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1536 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1537 ok(count
== sizeof(animated_gif_GCE
)/sizeof(animated_gif_GCE
[0]), "unexpected count %u\n", count
);
1539 compare_metadata(reader
, animated_gif_GCE
, count
);
1541 IWICMetadataReader_Release(reader
);
1544 hr
= IWICMetadataBlockReader_GetReaderByIndex(blockreader
, 4, &reader
);
1545 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1547 IWICMetadataBlockReader_Release(blockreader
);
1550 hr
= IWICBitmapFrameDecode_GetMetadataQueryReader(frame
, &queryreader
);
1552 broken(hr
== WINCODEC_ERR_UNSUPPORTEDOPERATION
) /* before Vista */,
1553 "GetMetadataQueryReader failed: %08x\n", hr
);
1557 IWICMetadataQueryReader_Release(queryreader
);
1560 IWICBitmapFrameDecode_Release(frame
);
1561 IWICBitmapDecoder_Release(decoder
);
1564 static void test_metadata_LSD(void)
1566 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};
1567 static const char LSD_data
[] = "hello world!\x1\x2\x3\x4\xab\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf";
1568 static const struct test_data td
[9] =
1570 { VT_UI1
|VT_VECTOR
, 0, 6, {'w','o','r','l','d','!'}, NULL
, { 'S','i','g','n','a','t','u','r','e',0 } },
1571 { VT_UI2
, 0, 0, { 0x201 }, NULL
, { 'W','i','d','t','h',0 } },
1572 { VT_UI2
, 0, 0, { 0x403 }, NULL
, { 'H','e','i','g','h','t',0 } },
1573 { 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 } },
1574 { VT_UI1
, 0, 0, { 2 }, NULL
, { 'C','o','l','o','r','R','e','s','o','l','u','t','i','o','n',0 } },
1575 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1576 { 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 } },
1577 { 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 } },
1578 { VT_UI1
, 0, 0, { 7 }, NULL
, { 'P','i','x','e','l','A','s','p','e','c','t','R','a','t','i','o',0 } }
1583 IWICPersistStream
*persist
;
1584 IWICMetadataReader
*reader
;
1585 IWICMetadataHandlerInfo
*info
;
1591 hr
= CoCreateInstance(&CLSID_WICLSDMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
1592 &IID_IWICMetadataReader
, (void **)&reader
);
1593 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
|| hr
== REGDB_E_CLASSNOTREG
) /* before Win7 */,
1594 "CoCreateInstance error %#x\n", hr
);
1596 stream
= create_stream(LSD_data
, sizeof(LSD_data
));
1601 hr
= IStream_Seek(stream
, pos
, SEEK_SET
, NULL
);
1602 ok(hr
== S_OK
, "IStream_Seek error %#x\n", hr
);
1604 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
1605 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1607 hr
= IWICPersistStream_Load(persist
, stream
);
1608 ok(hr
== S_OK
, "Load error %#x\n", hr
);
1610 IWICPersistStream_Release(persist
);
1615 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1616 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1617 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
1619 compare_metadata(reader
, td
, count
);
1621 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1622 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
1623 ok(IsEqualGUID(&format
, &GUID_MetadataFormatLSD
), "wrong format %s\n", wine_dbgstr_guid(&format
));
1625 hr
= IWICMetadataReader_GetMetadataHandlerInfo(reader
, &info
);
1626 ok(hr
== S_OK
, "GetMetadataHandlerInfo error %#x\n", hr
);
1628 hr
= IWICMetadataHandlerInfo_GetCLSID(info
, &id
);
1629 ok(hr
== S_OK
, "GetCLSID error %#x\n", hr
);
1630 ok(IsEqualGUID(&id
, &CLSID_WICLSDMetadataReader
), "wrong CLSID %s\n", wine_dbgstr_guid(&id
));
1632 hr
= IWICMetadataHandlerInfo_GetFriendlyName(info
, 64, name
, &dummy
);
1633 ok(hr
== S_OK
, "GetFriendlyName error %#x\n", hr
);
1634 ok(lstrcmpW(name
, LSD_name
) == 0, "wrong LSD reader name %s\n", wine_dbgstr_w(name
));
1636 IWICMetadataHandlerInfo_Release(info
);
1637 IWICMetadataReader_Release(reader
);
1640 IStream_Release(stream
);
1643 static void test_metadata_IMD(void)
1645 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};
1646 static const char IMD_data
[] = "hello world!\x1\x2\x3\x4\x5\x6\x7\x8\xed\xa\xb\xc\xd\xe\xf";
1647 static const struct test_data td
[8] =
1649 { VT_UI2
, 0, 0, { 0x201 }, NULL
, { 'L','e','f','t',0 } },
1650 { VT_UI2
, 0, 0, { 0x403 }, NULL
, { 'T','o','p',0 } },
1651 { VT_UI2
, 0, 0, { 0x605 }, NULL
, { 'W','i','d','t','h',0 } },
1652 { VT_UI2
, 0, 0, { 0x807 }, NULL
, { 'H','e','i','g','h','t',0 } },
1653 { 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 } },
1654 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'I','n','t','e','r','l','a','c','e','F','l','a','g',0 } },
1655 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'S','o','r','t','F','l','a','g',0 } },
1656 { 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 } }
1661 IWICPersistStream
*persist
;
1662 IWICMetadataReader
*reader
;
1663 IWICMetadataHandlerInfo
*info
;
1669 hr
= CoCreateInstance(&CLSID_WICIMDMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
1670 &IID_IWICMetadataReader
, (void **)&reader
);
1671 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
|| hr
== REGDB_E_CLASSNOTREG
) /* before Win7 */,
1672 "CoCreateInstance error %#x\n", hr
);
1674 stream
= create_stream(IMD_data
, sizeof(IMD_data
));
1679 hr
= IStream_Seek(stream
, pos
, SEEK_SET
, NULL
);
1680 ok(hr
== S_OK
, "IStream_Seek error %#x\n", hr
);
1682 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
1683 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1685 hr
= IWICPersistStream_Load(persist
, stream
);
1686 ok(hr
== S_OK
, "Load error %#x\n", hr
);
1688 IWICPersistStream_Release(persist
);
1693 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1694 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1695 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
1697 compare_metadata(reader
, td
, count
);
1699 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1700 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
1701 ok(IsEqualGUID(&format
, &GUID_MetadataFormatIMD
), "wrong format %s\n", wine_dbgstr_guid(&format
));
1703 hr
= IWICMetadataReader_GetMetadataHandlerInfo(reader
, &info
);
1704 ok(hr
== S_OK
, "GetMetadataHandlerInfo error %#x\n", hr
);
1706 hr
= IWICMetadataHandlerInfo_GetCLSID(info
, &id
);
1707 ok(hr
== S_OK
, "GetCLSID error %#x\n", hr
);
1708 ok(IsEqualGUID(&id
, &CLSID_WICIMDMetadataReader
), "wrong CLSID %s\n", wine_dbgstr_guid(&id
));
1710 hr
= IWICMetadataHandlerInfo_GetFriendlyName(info
, 64, name
, &dummy
);
1711 ok(hr
== S_OK
, "GetFriendlyName error %#x\n", hr
);
1712 ok(lstrcmpW(name
, IMD_name
) == 0, "wrong IMD reader name %s\n", wine_dbgstr_w(name
));
1714 IWICMetadataHandlerInfo_Release(info
);
1715 IWICMetadataReader_Release(reader
);
1718 IStream_Release(stream
);
1721 static void test_metadata_GCE(void)
1723 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};
1724 static const char GCE_data
[] = "hello world!\xa\x2\x3\x4\x5\x6\x7\x8\xed\xa\xb\xc\xd\xe\xf";
1725 static const struct test_data td
[5] =
1727 { VT_UI1
, 0, 0, { 2 }, NULL
, { 'D','i','s','p','o','s','a','l',0 } },
1728 { VT_BOOL
, 0, 0, { 1 }, NULL
, { 'U','s','e','r','I','n','p','u','t','F','l','a','g',0 } },
1729 { VT_BOOL
, 0, 0, { 0 }, NULL
, { 'T','r','a','n','s','p','a','r','e','n','c','y','F','l','a','g',0 } },
1730 { VT_UI2
, 0, 0, { 0x302 }, NULL
, { 'D','e','l','a','y',0 } },
1731 { 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 } }
1736 IWICPersistStream
*persist
;
1737 IWICMetadataReader
*reader
;
1738 IWICMetadataHandlerInfo
*info
;
1744 hr
= CoCreateInstance(&CLSID_WICGCEMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
1745 &IID_IWICMetadataReader
, (void **)&reader
);
1746 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
|| hr
== REGDB_E_CLASSNOTREG
) /* before Win7 */,
1747 "CoCreateInstance error %#x\n", hr
);
1749 stream
= create_stream(GCE_data
, sizeof(GCE_data
));
1754 hr
= IStream_Seek(stream
, pos
, SEEK_SET
, NULL
);
1755 ok(hr
== S_OK
, "IStream_Seek error %#x\n", hr
);
1757 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
1758 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1760 hr
= IWICPersistStream_Load(persist
, stream
);
1761 ok(hr
== S_OK
, "Load error %#x\n", hr
);
1763 IWICPersistStream_Release(persist
);
1768 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1769 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1770 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
1772 compare_metadata(reader
, td
, count
);
1774 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1775 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
1776 ok(IsEqualGUID(&format
, &GUID_MetadataFormatGCE
), "wrong format %s\n", wine_dbgstr_guid(&format
));
1778 hr
= IWICMetadataReader_GetMetadataHandlerInfo(reader
, &info
);
1779 ok(hr
== S_OK
, "GetMetadataHandlerInfo error %#x\n", hr
);
1781 hr
= IWICMetadataHandlerInfo_GetCLSID(info
, &id
);
1782 ok(hr
== S_OK
, "GetCLSID error %#x\n", hr
);
1783 ok(IsEqualGUID(&id
, &CLSID_WICGCEMetadataReader
), "wrong CLSID %s\n", wine_dbgstr_guid(&id
));
1785 hr
= IWICMetadataHandlerInfo_GetFriendlyName(info
, 64, name
, &dummy
);
1786 ok(hr
== S_OK
, "GetFriendlyName error %#x\n", hr
);
1787 ok(lstrcmpW(name
, GCE_name
) == 0, "wrong GCE reader name %s\n", wine_dbgstr_w(name
));
1789 IWICMetadataHandlerInfo_Release(info
);
1790 IWICMetadataReader_Release(reader
);
1793 IStream_Release(stream
);
1796 static void test_metadata_APE(void)
1798 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};
1799 static const char APE_data
[] = { 0x21,0xff,0x0b,'H','e','l','l','o',' ','W','o','r','l','d',
1800 /*sub-block*/1,0x11,
1801 /*sub-block*/2,0x22,0x33,
1802 /*sub-block*/4,0x44,0x55,0x66,0x77,
1804 static const struct test_data td
[2] =
1806 { 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 } },
1807 { VT_UI1
|VT_VECTOR
, 0, 10, { 1,0x11,2,0x22,0x33,4,0x44,0x55,0x66,0x77 }, NULL
, { 'D','a','t','a',0 } }
1809 WCHAR dataW
[] = { 'd','a','t','a',0 };
1812 IWICPersistStream
*persist
;
1813 IWICMetadataReader
*reader
;
1814 IWICMetadataHandlerInfo
*info
;
1816 UINT count
, dummy
, i
;
1819 PROPVARIANT id
, value
;
1821 hr
= CoCreateInstance(&CLSID_WICAPEMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
1822 &IID_IWICMetadataReader
, (void **)&reader
);
1823 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
|| hr
== REGDB_E_CLASSNOTREG
) /* before Win7 */,
1824 "CoCreateInstance error %#x\n", hr
);
1826 stream
= create_stream(APE_data
, sizeof(APE_data
));
1830 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
1831 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1833 hr
= IWICPersistStream_Load(persist
, stream
);
1834 ok(hr
== S_OK
, "Load error %#x\n", hr
);
1836 IWICPersistStream_Release(persist
);
1841 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1842 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1843 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
1845 compare_metadata(reader
, td
, count
);
1847 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1848 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
1849 ok(IsEqualGUID(&format
, &GUID_MetadataFormatAPE
), "wrong format %s\n", wine_dbgstr_guid(&format
));
1851 PropVariantInit(&value
);
1853 U(id
).pwszVal
= dataW
;
1855 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, &value
);
1856 ok(hr
== S_OK
, "GetValue error %#x\n", hr
);
1857 ok(value
.vt
== (VT_UI1
|VT_VECTOR
), "unexpected vt: %i\n", id
.vt
);
1858 ok(td
[1].count
== U(value
).caub
.cElems
, "expected cElems %d, got %d\n", td
[1].count
, U(value
).caub
.cElems
);
1859 for (i
= 0; i
< U(value
).caub
.cElems
; i
++)
1860 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
]);
1861 PropVariantClear(&value
);
1863 hr
= IWICMetadataReader_GetMetadataHandlerInfo(reader
, &info
);
1864 ok(hr
== S_OK
, "GetMetadataHandlerInfo error %#x\n", hr
);
1866 hr
= IWICMetadataHandlerInfo_GetCLSID(info
, &clsid
);
1867 ok(hr
== S_OK
, "GetCLSID error %#x\n", hr
);
1868 ok(IsEqualGUID(&clsid
, &CLSID_WICAPEMetadataReader
), "wrong CLSID %s\n", wine_dbgstr_guid(&clsid
));
1870 hr
= IWICMetadataHandlerInfo_GetFriendlyName(info
, 64, name
, &dummy
);
1871 ok(hr
== S_OK
, "GetFriendlyName error %#x\n", hr
);
1872 ok(lstrcmpW(name
, APE_name
) == 0, "wrong APE reader name %s\n", wine_dbgstr_w(name
));
1874 IWICMetadataHandlerInfo_Release(info
);
1875 IWICMetadataReader_Release(reader
);
1878 IStream_Release(stream
);
1881 static void test_metadata_GIF_comment(void)
1883 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};
1884 static const char GIF_comment_data
[] = { 0x21,0xfe,
1885 /*sub-block*/5,'H','e','l','l','o',
1887 /*sub-block*/6,'W','o','r','l','d','!',
1889 static const struct test_data td
[1] =
1891 { VT_LPSTR
, 0, 12, { 0 }, "Hello World!", { 'T','e','x','t','E','n','t','r','y',0 } }
1893 WCHAR text_entryW
[] = { 'T','E','X','T','E','N','T','R','Y',0 };
1896 IWICPersistStream
*persist
;
1897 IWICMetadataReader
*reader
;
1898 IWICMetadataHandlerInfo
*info
;
1903 PROPVARIANT id
, value
;
1905 hr
= CoCreateInstance(&CLSID_WICGifCommentMetadataReader
, NULL
, CLSCTX_INPROC_SERVER
,
1906 &IID_IWICMetadataReader
, (void **)&reader
);
1907 ok(hr
== S_OK
|| broken(hr
== E_NOINTERFACE
|| hr
== REGDB_E_CLASSNOTREG
) /* before Win7 */,
1908 "CoCreateInstance error %#x\n", hr
);
1910 stream
= create_stream(GIF_comment_data
, sizeof(GIF_comment_data
));
1914 hr
= IUnknown_QueryInterface(reader
, &IID_IWICPersistStream
, (void **)&persist
);
1915 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1917 hr
= IWICPersistStream_Load(persist
, stream
);
1918 ok(hr
== S_OK
, "Load error %#x\n", hr
);
1920 IWICPersistStream_Release(persist
);
1925 hr
= IWICMetadataReader_GetCount(reader
, &count
);
1926 ok(hr
== S_OK
, "GetCount error %#x\n", hr
);
1927 ok(count
== sizeof(td
)/sizeof(td
[0]), "unexpected count %u\n", count
);
1929 compare_metadata(reader
, td
, count
);
1931 hr
= IWICMetadataReader_GetMetadataFormat(reader
, &format
);
1932 ok(hr
== S_OK
, "GetMetadataFormat error %#x\n", hr
);
1933 ok(IsEqualGUID(&format
, &GUID_MetadataFormatGifComment
), "wrong format %s\n", wine_dbgstr_guid(&format
));
1935 PropVariantInit(&value
);
1937 U(id
).pwszVal
= text_entryW
;
1939 hr
= IWICMetadataReader_GetValue(reader
, NULL
, &id
, &value
);
1940 ok(hr
== S_OK
, "GetValue error %#x\n", hr
);
1941 ok(value
.vt
== VT_LPSTR
, "unexpected vt: %i\n", id
.vt
);
1942 ok(!strcmp(U(value
).pszVal
, "Hello World!"), "unexpected value: %s\n", U(value
).pszVal
);
1943 PropVariantClear(&value
);
1945 hr
= IWICMetadataReader_GetMetadataHandlerInfo(reader
, &info
);
1946 ok(hr
== S_OK
, "GetMetadataHandlerInfo error %#x\n", hr
);
1948 hr
= IWICMetadataHandlerInfo_GetCLSID(info
, &clsid
);
1949 ok(hr
== S_OK
, "GetCLSID error %#x\n", hr
);
1950 ok(IsEqualGUID(&clsid
, &CLSID_WICGifCommentMetadataReader
), "wrong CLSID %s\n", wine_dbgstr_guid(&clsid
));
1952 hr
= IWICMetadataHandlerInfo_GetFriendlyName(info
, 64, name
, &dummy
);
1953 ok(hr
== S_OK
, "GetFriendlyName error %#x\n", hr
);
1954 ok(lstrcmpW(name
, GIF_comment_name
) == 0, "wrong APE reader name %s\n", wine_dbgstr_w(name
));
1956 IWICMetadataHandlerInfo_Release(info
);
1957 IWICMetadataReader_Release(reader
);
1960 IStream_Release(stream
);
1963 START_TEST(metadata
)
1965 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
1967 test_metadata_unknown();
1968 test_metadata_tEXt();
1969 test_metadata_gAMA();
1970 test_metadata_cHRM();
1971 test_metadata_IFD();
1972 test_metadata_Exif();
1973 test_create_reader();
1974 test_metadata_png();
1975 test_metadata_gif();
1976 test_metadata_LSD();
1977 test_metadata_IMD();
1978 test_metadata_GCE();
1979 test_metadata_APE();
1980 test_metadata_GIF_comment();