windowscodecs: Implement QueryCapability for BMP decoder.

This commit is contained in:
Vincent Povirk 2009-07-01 16:03:37 -05:00 committed by Alexandre Julliard
parent 5b7de464ca
commit 2322254c83
2 changed files with 22 additions and 7 deletions

View File

@ -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,

View File

@ -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);