forked from Mirrors/wine-wine
windowscodecs: Implement PngDecoder_Block_GetReaderByIndex.
parent
43c97b871f
commit
f2f5cd831b
|
@ -1062,8 +1062,51 @@ static HRESULT WINAPI PngDecoder_Block_GetCount(IWICMetadataBlockReader *iface,
|
|||
static HRESULT WINAPI PngDecoder_Block_GetReaderByIndex(IWICMetadataBlockReader *iface,
|
||||
UINT nIndex, IWICMetadataReader **ppIMetadataReader)
|
||||
{
|
||||
FIXME("%p,%d,%p\n", iface, nIndex, ppIMetadataReader);
|
||||
return E_NOTIMPL;
|
||||
PngDecoder *This = impl_from_IWICMetadataBlockReader(iface);
|
||||
HRESULT hr;
|
||||
IWICComponentFactory* factory;
|
||||
IWICStream* stream;
|
||||
|
||||
TRACE("%p,%d,%p\n", iface, nIndex, ppIMetadataReader);
|
||||
|
||||
if (nIndex >= This->metadata_count || !ppIMetadataReader)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (!This->metadata_blocks[nIndex].reader)
|
||||
{
|
||||
hr = StreamImpl_Create(&stream);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICStream_InitializeFromIStreamRegion(stream, This->stream,
|
||||
This->metadata_blocks[nIndex].ofs, This->metadata_blocks[nIndex].len);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = ComponentFactory_CreateInstance(&IID_IWICComponentFactory, (void**)&factory);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory,
|
||||
&GUID_ContainerFormatPng, NULL, WICMetadataCreationAllowUnknown,
|
||||
(IStream*)stream, &This->metadata_blocks[nIndex].reader);
|
||||
|
||||
IWICComponentFactory_Release(factory);
|
||||
}
|
||||
|
||||
IWICStream_Release(stream);
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
*ppIMetadataReader = NULL;
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
*ppIMetadataReader = This->metadata_blocks[nIndex].reader;
|
||||
IWICMetadataReader_AddRef(*ppIMetadataReader);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI PngDecoder_Block_GetEnumerator(IWICMetadataBlockReader *iface,
|
||||
|
|
|
@ -960,19 +960,19 @@ static void test_metadata_png(void)
|
|||
}
|
||||
|
||||
hr = IWICMetadataBlockReader_GetReaderByIndex(blockreader, 0, &reader);
|
||||
todo_wine ok(hr == S_OK, "GetReaderByIndex failed, hr=%x\n", hr);
|
||||
ok(hr == S_OK, "GetReaderByIndex failed, hr=%x\n", hr);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = IWICMetadataReader_GetMetadataFormat(reader, &containerformat);
|
||||
ok(hr == S_OK, "GetMetadataFormat failed, hr=%#x\n", hr);
|
||||
ok(IsEqualGUID(&containerformat, &GUID_MetadataFormatChunktIME) ||
|
||||
todo_wine ok(IsEqualGUID(&containerformat, &GUID_MetadataFormatChunktIME) ||
|
||||
broken(IsEqualGUID(&containerformat, &GUID_MetadataFormatUnknown)) /* Windows XP */,
|
||||
"unexpected container format\n");
|
||||
|
||||
hr = IWICMetadataReader_GetCount(reader, &count);
|
||||
ok(hr == S_OK, "GetCount error %#x\n", hr);
|
||||
ok(count == 6 || broken(count == 1) /* XP */, "expected 6, got %u\n", count);
|
||||
todo_wine ok(count == 6 || broken(count == 1) /* XP */, "expected 6, got %u\n", count);
|
||||
if (count == 6)
|
||||
compare_metadata(reader, td, count);
|
||||
|
||||
|
|
Loading…
Reference in New Issue