[1/3] windowscodecs: Add test for png cHRM metadata.
Vincent Povirk
madewokherd at gmail.com
Wed Jun 15 12:43:39 CDT 2016
From: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
dlls/windowscodecs/tests/metadata.c | 72 +++++++++++++++++++++++++++++++++++++
include/wincodecsdk.idl | 2 ++
2 files changed, 74 insertions(+)
diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c
index aa096f0..c44cf9f 100644
--- a/dlls/windowscodecs/tests/metadata.c
+++ b/dlls/windowscodecs/tests/metadata.c
@@ -144,6 +144,16 @@ static const char metadata_gAMA[] = {
0xff,0xff,0xff,0xff /* chunk CRC */
};
+static const char metadata_cHRM[] = {
+ 0,0,0,32, /* chunk length */
+ 'c','H','R','M', /* chunk type */
+ 0,0,122,38, 0,0,128,132, /* white point */
+ 0,0,250,0, 0,0,128,232, /* red */
+ 0,0,117,48, 0,0,234,96, /* green */
+ 0,0,58,152, 0,0,23,112, /* blue */
+ 0xff,0xff,0xff,0xff /* chunk CRC */
+};
+
static const char pngimage[285] = {
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,
@@ -457,6 +467,67 @@ static void test_metadata_gAMA(void)
IWICMetadataReader_Release(reader);
}
+static void test_metadata_cHRM(void)
+{
+ HRESULT hr;
+ IWICMetadataReader *reader;
+ PROPVARIANT schema, id, value;
+ ULONG count;
+ GUID format;
+ int i;
+ static const WCHAR expected_names[8][12] = {
+ {'W','h','i','t','e','P','o','i','n','t','X',0},
+ {'W','h','i','t','e','P','o','i','n','t','Y',0},
+ {'R','e','d','X',0},
+ {'R','e','d','Y',0},
+ {'G','r','e','e','n','X',0},
+ {'G','r','e','e','n','Y',0},
+ {'B','l','u','e','X',0},
+ {'B','l','u','e','Y',0},
+ };
+ static const ULONG expected_vals[8] = {
+ 31270,32900, 64000,33000, 30000,60000, 15000,6000
+ };
+
+ PropVariantInit(&schema);
+ PropVariantInit(&id);
+ PropVariantInit(&value);
+
+ hr = CoCreateInstance(&CLSID_WICPngChrmMetadataReader, 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_cHRM, sizeof(metadata_cHRM), WICPersistOptionsDefault);
+
+ hr = IWICMetadataReader_GetMetadataFormat(reader, &format);
+ ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
+ ok(IsEqualGUID(&format, &GUID_MetadataFormatChunkcHRM), "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 == 8, "unexpected count %i\n", count);
+
+ for (i=0; i<8; i++)
+ {
+ hr = IWICMetadataReader_GetValueByIndex(reader, i, &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, expected_names[i]), "got %s, expected %s\n", wine_dbgstr_w(U(id).pwszVal), wine_dbgstr_w(expected_names[i]));
+ PropVariantClear(&id);
+
+ ok(value.vt == VT_UI4, "unexpected vt: %i\n", value.vt);
+ ok(U(value).ulVal == expected_vals[i], "got %u, expected %u\n", U(value).ulVal, expected_vals[i]);
+ PropVariantClear(&value);
+ }
+
+ IWICMetadataReader_Release(reader);
+}
+
static inline USHORT ushort_bswap(USHORT s)
{
return (s >> 8) | (s << 8);
@@ -1896,6 +1967,7 @@ START_TEST(metadata)
test_metadata_unknown();
test_metadata_tEXt();
test_metadata_gAMA();
+ test_metadata_cHRM();
test_metadata_IFD();
test_metadata_Exif();
test_create_reader();
diff --git a/include/wincodecsdk.idl b/include/wincodecsdk.idl
index 7fc07b8..9ce3f30 100644
--- a/include/wincodecsdk.idl
+++ b/include/wincodecsdk.idl
@@ -37,6 +37,7 @@ typedef enum WICMetadataCreationOptions {
} WICMetadataCreationOptions;
cpp_quote("DEFINE_GUID(GUID_MetadataFormatUnknown, 0xa45e592f,0x9078,0x4a7c,0xad,0xb5,0x4e,0xdc,0x4f,0xd6,0x1b,0x1f);")
+cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunkcHRM, 0x9db3655b,0x2842,0x44b3,0x80,0x67,0x12,0xe9,0xb3,0x75,0x55,0x6a);")
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_MetadataFormatChunktIME, 0x6b00ae2d,0xe24b,0x460a,0x98,0xb6,0x87,0x8b,0xd0,0x30,0x72,0xfd);")
@@ -52,6 +53,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_WICUnknownMetadataWriter, 0xa09cca86,0x27ba,0x4f39,0x90,0x53,0x12,0x1f,0xa4,0xdc,0x08,0xfc);")
+cpp_quote("DEFINE_GUID(CLSID_WICPngChrmMetadataReader, 0xf90b5f36,0x367b,0x402a,0x9d,0xd1,0xbc,0x0f,0xd5,0x9d,0x8f,0x62);")
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_WICPngTextMetadataWriter, 0xb5ebafb9,0x253e,0x4a72,0xa7,0x44,0x07,0x62,0xd2,0x68,0x56,0x83);")
--
2.7.4
More information about the wine-patches
mailing list