windowscodecs: Implement QueryCapability for BMP decoder.
diff --git a/dlls/windowscodecs/bmpdecode.c b/dlls/windowscodecs/bmpdecode.c index a6b7577..b81987c6 100644 --- a/dlls/windowscodecs/bmpdecode.c +++ b/dlls/windowscodecs/bmpdecode.c
@@ -329,9 +329,14 @@ { HRESULT hr; ULONG bytestoread, bytesread; + LARGE_INTEGER seek; if (This->initialized) return WINCODEC_ERR_WRONGSTATE; + seek.QuadPart = 0; + hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL); + if (FAILED(hr)) return hr; + hr = IStream_Read(stream, &This->bfh, sizeof(BITMAPFILEHEADER), &bytesread); if (FAILED(hr)) return hr; if (bytesread != sizeof(BITMAPFILEHEADER) || @@ -483,8 +488,18 @@ static HRESULT WINAPI BmpDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *pIStream, DWORD *pdwCapability) { - FIXME("(%p,%p,%p): stub\n", iface, pIStream, pdwCapability); - return E_NOTIMPL; + HRESULT hr; + BmpDecoder *This = (BmpDecoder*)iface; + + hr = BmpDecoder_ReadHeaders(This, pIStream); + if (FAILED(hr)) return hr; + + if (This->read_data_func == BmpFrameDecode_ReadUnsupported) + *pdwCapability = 0; + else + *pdwCapability = WICBitmapDecoderCapabilityCanDecodeAllImages; + + return S_OK; } static HRESULT WINAPI BmpDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream,
diff --git a/dlls/windowscodecs/tests/bmpformat.c b/dlls/windowscodecs/tests/bmpformat.c index c266dda..fb6f491 100644 --- a/dlls/windowscodecs/tests/bmpformat.c +++ b/dlls/windowscodecs/tests/bmpformat.c
@@ -157,7 +157,7 @@ /* cannot querycapability after initialize */ hr = IWICBitmapDecoder_QueryCapability(decoder, bmpstream, &capability); - todo_wine ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr); + ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr); hr = CoCreateInstance(&CLSID_WICBmpDecoder, NULL, CLSCTX_INPROC_SERVER, &IID_IWICBitmapDecoder, (void**)&decoder2); @@ -165,17 +165,17 @@ if (SUCCEEDED(hr)) { hr = IWICBitmapDecoder_QueryCapability(decoder2, bmpstream, &capability); - todo_wine ok(hr == S_OK, "QueryCapability failed, hr=%x\n", hr); - todo_wine ok(capability == (WICBitmapDecoderCapabilityCanDecodeAllImages), + ok(hr == S_OK, "QueryCapability failed, hr=%x\n", hr); + ok(capability == (WICBitmapDecoderCapabilityCanDecodeAllImages), "unexpected capabilities: %x\n", capability); /* cannot initialize after querycapability */ hr = IWICBitmapDecoder_Initialize(decoder2, bmpstream, WICDecodeMetadataCacheOnLoad); - todo_wine ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr); + ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr); /* cannot querycapability twice */ hr = IWICBitmapDecoder_QueryCapability(decoder2, bmpstream, &capability); - todo_wine ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr); + ok(hr == WINCODEC_ERR_WRONGSTATE, "expected WINCODEC_ERR_WRONGSTATE, hr=%x\n", hr); } IStream_Release(bmpstream);