Commit 2322254c authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

windowscodecs: Implement QueryCapability for BMP decoder.

parent 5b7de464
......@@ -329,9 +329,14 @@ static HRESULT BmpDecoder_ReadHeaders(BmpDecoder* This, IStream *stream)
{
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 ULONG WINAPI BmpDecoder_Release(IWICBitmapDecoder *iface)
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,
......
......@@ -157,7 +157,7 @@ static void test_decode_24bpp(void)
/* 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 @@ static void test_decode_24bpp(void)
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment