windowscodecs: Add test for PNG gAMA metadata.

This commit is contained in:
Vincent Povirk 2015-04-01 14:41:50 -05:00 committed by Alexandre Julliard
parent d4f4c76bc6
commit 5b893587bd
2 changed files with 55 additions and 0 deletions

View File

@ -137,6 +137,13 @@ static const char metadata_tEXt[] = {
0x3f,0x64,0x19,0xf3 /* chunk CRC */ 0x3f,0x64,0x19,0xf3 /* chunk CRC */
}; };
static const char metadata_gAMA[] = {
0,0,0,4, /* chunk length */
'g','A','M','A', /* chunk type */
0,0,130,53, /* gamma */
0xff,0xff,0xff,0xff /* chunk CRC */
};
static const char pngimage[285] = { static const char pngimage[285] = {
0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53, 0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,
@ -405,6 +412,51 @@ static void test_metadata_tEXt(void)
IWICMetadataReader_Release(reader); IWICMetadataReader_Release(reader);
} }
static void test_metadata_gAMA(void)
{
HRESULT hr;
IWICMetadataReader *reader;
PROPVARIANT schema, id, value;
ULONG count;
GUID format;
static const WCHAR ImageGamma[] = {'I','m','a','g','e','G','a','m','m','a',0};
PropVariantInit(&schema);
PropVariantInit(&id);
PropVariantInit(&value);
hr = CoCreateInstance(&CLSID_WICPngGamaMetadataReader, NULL, CLSCTX_INPROC_SERVER,
&IID_IWICMetadataReader, (void**)&reader);
todo_wine ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG) /*winxp*/, "CoCreateInstance failed, hr=%x\n", hr);
if (FAILED(hr)) return;
load_stream((IUnknown*)reader, metadata_gAMA, sizeof(metadata_gAMA), WICPersistOptionsDefault);
hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
ok(IsEqualGUID(&format, &GUID_MetadataFormatChunkgAMA), "unexpected format %s\n", wine_dbgstr_guid(&format));
hr = IWICMetadataReader_GetCount(reader, &count);
ok(hr == S_OK, "GetCount failed, hr=%x\n", hr);
ok(count == 1, "unexpected count %i\n", count);
hr = IWICMetadataReader_GetValueByIndex(reader, 0, &schema, &id, &value);
ok(hr == S_OK, "GetValue failed, hr=%x\n", hr);
ok(schema.vt == VT_EMPTY, "unexpected vt: %i\n", schema.vt);
PropVariantClear(&schema);
ok(id.vt == VT_LPWSTR, "unexpected vt: %i\n", id.vt);
ok(!lstrcmpW(U(id).pwszVal, ImageGamma), "unexpected value: %s\n", wine_dbgstr_w(U(id).pwszVal));
PropVariantClear(&id);
ok(value.vt == VT_UI4, "unexpected vt: %i\n", value.vt);
ok(value.ulVal == 33333, "unexpected value: %u\n", value.ulVal);
PropVariantClear(&value);
IWICMetadataReader_Release(reader);
}
static inline USHORT ushort_bswap(USHORT s) static inline USHORT ushort_bswap(USHORT s)
{ {
return (s >> 8) | (s << 8); return (s >> 8) | (s << 8);
@ -1805,6 +1857,7 @@ START_TEST(metadata)
test_metadata_unknown(); test_metadata_unknown();
test_metadata_tEXt(); test_metadata_tEXt();
test_metadata_gAMA();
test_metadata_IFD(); test_metadata_IFD();
test_metadata_Exif(); test_metadata_Exif();
test_create_reader(); test_create_reader();

View File

@ -37,6 +37,7 @@ typedef enum WICMetadataCreationOptions {
} WICMetadataCreationOptions; } WICMetadataCreationOptions;
cpp_quote("DEFINE_GUID(GUID_MetadataFormatUnknown, 0xa45e592f,0x9078,0x4a7c,0xad,0xb5,0x4e,0xdc,0x4f,0xd6,0x1b,0x1f);") cpp_quote("DEFINE_GUID(GUID_MetadataFormatUnknown, 0xa45e592f,0x9078,0x4a7c,0xad,0xb5,0x4e,0xdc,0x4f,0xd6,0x1b,0x1f);")
cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunkgAMA, 0xf00935a5,0x1d5d,0x4cd1,0x81,0xb2,0x93,0x24,0xd7,0xec,0xa7,0x81);")
cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunktEXt, 0x568d8936,0xc0a9,0x4923,0x90,0x5d,0xdf,0x2b,0x38,0x23,0x8f,0xbc);") cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunktEXt, 0x568d8936,0xc0a9,0x4923,0x90,0x5d,0xdf,0x2b,0x38,0x23,0x8f,0xbc);")
cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunktIME, 0x6b00ae2d,0xe24b,0x460a,0x98,0xb6,0x87,0x8b,0xd0,0x30,0x72,0xfd);") cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunktIME, 0x6b00ae2d,0xe24b,0x460a,0x98,0xb6,0x87,0x8b,0xd0,0x30,0x72,0xfd);")
cpp_quote("DEFINE_GUID(GUID_MetadataFormatIfd, 0x537396c6,0x2d8a,0x4bb6,0x9b,0xf8,0x2f,0x0a,0x8e,0x2a,0x3a,0xdf);") cpp_quote("DEFINE_GUID(GUID_MetadataFormatIfd, 0x537396c6,0x2d8a,0x4bb6,0x9b,0xf8,0x2f,0x0a,0x8e,0x2a,0x3a,0xdf);")
@ -51,6 +52,7 @@ cpp_quote("DEFINE_GUID(GUID_MetadataFormatGifComment, 0xc4b6e0e0,0xcfb4,0x4ad3,0
cpp_quote("DEFINE_GUID(CLSID_WICUnknownMetadataReader, 0x699745c2,0x5066,0x4b82,0xa8,0xe3,0xd4,0x04,0x78,0xdb,0xec,0x8c);") cpp_quote("DEFINE_GUID(CLSID_WICUnknownMetadataReader, 0x699745c2,0x5066,0x4b82,0xa8,0xe3,0xd4,0x04,0x78,0xdb,0xec,0x8c);")
cpp_quote("DEFINE_GUID(CLSID_WICUnknownMetadataWriter, 0xa09cca86,0x27ba,0x4f39,0x90,0x53,0x12,0x1f,0xa4,0xdc,0x08,0xfc);") cpp_quote("DEFINE_GUID(CLSID_WICUnknownMetadataWriter, 0xa09cca86,0x27ba,0x4f39,0x90,0x53,0x12,0x1f,0xa4,0xdc,0x08,0xfc);")
cpp_quote("DEFINE_GUID(CLSID_WICPngGamaMetadataReader, 0x3692ca39,0xe082,0x4350,0x9e,0x1f,0x37,0x04,0xcb,0x08,0x3c,0xd5);")
cpp_quote("DEFINE_GUID(CLSID_WICPngTextMetadataReader, 0x4b59afcc,0xb8c3,0x408a,0xb6,0x70,0x89,0xe5,0xfa,0xb6,0xfd,0xa7);") cpp_quote("DEFINE_GUID(CLSID_WICPngTextMetadataReader, 0x4b59afcc,0xb8c3,0x408a,0xb6,0x70,0x89,0xe5,0xfa,0xb6,0xfd,0xa7);")
cpp_quote("DEFINE_GUID(CLSID_WICPngTextMetadataWriter, 0xb5ebafb9,0x253e,0x4a72,0xa7,0x44,0x07,0x62,0xd2,0x68,0x56,0x83);") cpp_quote("DEFINE_GUID(CLSID_WICPngTextMetadataWriter, 0xb5ebafb9,0x253e,0x4a72,0xa7,0x44,0x07,0x62,0xd2,0x68,0x56,0x83);")
cpp_quote("DEFINE_GUID(CLSID_WICIfdMetadataReader, 0x8f914656,0x9d0a,0x4eb2,0x90,0x19,0x0b,0xf9,0x6d,0x8a,0x9e,0xe6);") cpp_quote("DEFINE_GUID(CLSID_WICIfdMetadataReader, 0x8f914656,0x9d0a,0x4eb2,0x90,0x19,0x0b,0xf9,0x6d,0x8a,0x9e,0xe6);")