From 00fa05c73310577620ba3564fcffeb6d37408bd0 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Wed, 1 Jul 2009 16:03:37 -0500 Subject: [PATCH] windowscodecs: implement QueryCapability for BMP decoder --- dlls/windowscodecs/bmpdecode.c | 19 +++++++++++++++++-- dlls/windowscodecs/tests/bmpformat.c | 10 +++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/dlls/windowscodecs/bmpdecode.c b/dlls/windowscodecs/bmpdecode.c index a6b7577..b81987c 100644 --- a/dlls/windowscodecs/bmpdecode.c +++ b/dlls/windowscodecs/bmpdecode.c @@ -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, 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 @@ 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); -- 1.5.4.3