diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c index ce9950974d5..c440d3e9dd6 100644 --- a/dlls/windowscodecs/pngformat.c +++ b/dlls/windowscodecs/pngformat.c @@ -31,6 +31,7 @@ #include "winbase.h" #include "objbase.h" #include "wincodec.h" +#include "wincodecsdk.h" #include "wincodecs_private.h" @@ -152,6 +153,7 @@ static void user_warning_fn(png_structp png_ptr, png_const_charp warning_message typedef struct { IWICBitmapDecoder IWICBitmapDecoder_iface; IWICBitmapFrameDecode IWICBitmapFrameDecode_iface; + IWICMetadataBlockReader IWICMetadataBlockReader_iface; LONG ref; png_structp png_ptr; png_infop info_ptr; @@ -175,6 +177,11 @@ static inline PngDecoder *impl_from_IWICBitmapFrameDecode(IWICBitmapFrameDecode return CONTAINING_RECORD(iface, PngDecoder, IWICBitmapFrameDecode_iface); } +static inline PngDecoder *impl_from_IWICMetadataBlockReader(IWICMetadataBlockReader *iface) +{ + return CONTAINING_RECORD(iface, PngDecoder, IWICMetadataBlockReader_iface); +} + static const IWICBitmapFrameDecodeVtbl PngDecoder_FrameVtbl; static HRESULT WINAPI PngDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid, @@ -559,6 +566,7 @@ static const IWICBitmapDecoderVtbl PngDecoder_Vtbl = { static HRESULT WINAPI PngDecoder_Frame_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid, void **ppv) { + PngDecoder *This = impl_from_IWICBitmapFrameDecode(iface); if (!ppv) return E_INVALIDARG; if (IsEqualIID(&IID_IUnknown, iid) || @@ -567,6 +575,10 @@ static HRESULT WINAPI PngDecoder_Frame_QueryInterface(IWICBitmapFrameDecode *ifa { *ppv = iface; } + else if (IsEqualIID(&IID_IWICMetadataBlockReader, iid)) + { + *ppv = (void**)&This->IWICMetadataBlockReader_iface; + } else { *ppv = NULL; @@ -744,6 +756,64 @@ static const IWICBitmapFrameDecodeVtbl PngDecoder_FrameVtbl = { PngDecoder_Frame_GetThumbnail }; +static HRESULT WINAPI PngDecoder_Block_QueryInterface(IWICMetadataBlockReader *iface, REFIID iid, + void **ppv) +{ + PngDecoder *This = impl_from_IWICMetadataBlockReader(iface); + return IWICBitmapFrameDecode_QueryInterface(&This->IWICBitmapFrameDecode_iface, iid, ppv); +} + +static ULONG WINAPI PngDecoder_Block_AddRef(IWICMetadataBlockReader *iface) +{ + PngDecoder *This = impl_from_IWICMetadataBlockReader(iface); + return IUnknown_AddRef((IUnknown*)This); +} + +static ULONG WINAPI PngDecoder_Block_Release(IWICMetadataBlockReader *iface) +{ + PngDecoder *This = impl_from_IWICMetadataBlockReader(iface); + return IUnknown_Release((IUnknown*)This); +} + +static HRESULT WINAPI PngDecoder_Block_GetContainerFormat(IWICMetadataBlockReader *iface, + GUID *pguidContainerFormat) +{ + if (!pguidContainerFormat) return E_INVALIDARG; + memcpy(pguidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID)); + return S_OK; +} + +static HRESULT WINAPI PngDecoder_Block_GetCount(IWICMetadataBlockReader *iface, + UINT *pcCount) +{ + FIXME("%p,%p: stub\n", iface, pcCount); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_Block_GetReaderByIndex(IWICMetadataBlockReader *iface, + UINT nIndex, IWICMetadataReader **ppIMetadataReader) +{ + FIXME("%p,%d,%p\n", iface, nIndex, ppIMetadataReader); + return E_NOTIMPL; +} + +static HRESULT WINAPI PngDecoder_Block_GetEnumerator(IWICMetadataBlockReader *iface, + IEnumUnknown **ppIEnumMetadata) +{ + FIXME("%p,%p\n", iface, ppIEnumMetadata); + return E_NOTIMPL; +} + +static const IWICMetadataBlockReaderVtbl PngDecoder_BlockVtbl = { + PngDecoder_Block_QueryInterface, + PngDecoder_Block_AddRef, + PngDecoder_Block_Release, + PngDecoder_Block_GetContainerFormat, + PngDecoder_Block_GetCount, + PngDecoder_Block_GetReaderByIndex, + PngDecoder_Block_GetEnumerator, +}; + HRESULT PngDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) { PngDecoder *This; @@ -766,6 +836,7 @@ HRESULT PngDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) This->IWICBitmapDecoder_iface.lpVtbl = &PngDecoder_Vtbl; This->IWICBitmapFrameDecode_iface.lpVtbl = &PngDecoder_FrameVtbl; + This->IWICMetadataBlockReader_iface.lpVtbl = &PngDecoder_BlockVtbl; This->ref = 1; This->png_ptr = NULL; This->info_ptr = NULL; diff --git a/dlls/windowscodecs/tests/metadata.c b/dlls/windowscodecs/tests/metadata.c index b87c5c4c1c9..9f74c0ac24e 100644 --- a/dlls/windowscodecs/tests/metadata.c +++ b/dlls/windowscodecs/tests/metadata.c @@ -569,7 +569,7 @@ static void test_metadata_png(void) ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr); hr = IWICBitmapFrameDecode_QueryInterface(frame, &IID_IWICMetadataBlockReader, (void**)&blockreader); - todo_wine ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr); + ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr); if (SUCCEEDED(hr)) { @@ -581,11 +581,11 @@ static void test_metadata_png(void) ok(IsEqualGUID(&containerformat, &GUID_ContainerFormatPng), "unexpected container format\n"); hr = IWICMetadataBlockReader_GetCount(blockreader, NULL); - ok(hr == E_INVALIDARG, "GetCount failed, hr=%x\n", hr); + todo_wine ok(hr == E_INVALIDARG, "GetCount failed, hr=%x\n", hr); hr = IWICMetadataBlockReader_GetCount(blockreader, &count); - ok(hr == S_OK, "GetCount failed, hr=%x\n", hr); - ok(count == 1, "unexpected count %d\n", count); + todo_wine ok(hr == S_OK, "GetCount failed, hr=%x\n", hr); + todo_wine ok(count == 1, "unexpected count %d\n", count); if (0) { @@ -595,7 +595,7 @@ static void test_metadata_png(void) } hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 0, &reader); - ok(hr == S_OK, "GetReaderByIndex failed, hr=%x\n", hr); + todo_wine ok(hr == S_OK, "GetReaderByIndex failed, hr=%x\n", hr); if (SUCCEEDED(hr)) { @@ -608,7 +608,7 @@ static void test_metadata_png(void) } hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 1, &reader); - ok(hr == WINCODEC_ERR_VALUEOUTOFRANGE, "GetReaderByIndex failed, hr=%x\n", hr); + todo_wine ok(hr == WINCODEC_ERR_VALUEOUTOFRANGE, "GetReaderByIndex failed, hr=%x\n", hr); IWICMetadataBlockReader_Release(blockreader); }