Module: wine Branch: master Commit: dd5c5b82777217d5a713f4c3da3b93d14346386b URL: http://source.winehq.org/git/wine.git/?a=commit;h=dd5c5b82777217d5a713f4c3da...
Author: Vincent Povirk vincent@codeweavers.com Date: Thu Aug 20 09:50:06 2009 -0500
windowscodecs: Implement Initialize for the ICO decoder.
---
dlls/windowscodecs/icoformat.c | 31 +++++++++++++++++++++++++++++-- 1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/dlls/windowscodecs/icoformat.c b/dlls/windowscodecs/icoformat.c index f61ae01..e26de5f 100644 --- a/dlls/windowscodecs/icoformat.c +++ b/dlls/windowscodecs/icoformat.c @@ -58,6 +58,9 @@ typedef struct typedef struct { const IWICBitmapDecoderVtbl *lpVtbl; LONG ref; + BOOL initialized; + IStream *stream; + ICONHEADER header; } IcoDecoder;
static HRESULT WINAPI IcoDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid, @@ -101,6 +104,7 @@ static ULONG WINAPI IcoDecoder_Release(IWICBitmapDecoder *iface)
if (ref == 0) { + if (This->stream) IStream_Release(This->stream); HeapFree(GetProcessHeap(), 0, This); }
@@ -117,8 +121,29 @@ static HRESULT WINAPI IcoDecoder_QueryCapability(IWICBitmapDecoder *iface, IStre static HRESULT WINAPI IcoDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream, WICDecodeOptions cacheOptions) { - FIXME("(%p,%p,%x): stub\n", iface, pIStream, cacheOptions); - return E_NOTIMPL; + IcoDecoder *This = (IcoDecoder*)iface; + LARGE_INTEGER seek; + HRESULT hr; + ULONG bytesread; + TRACE("(%p,%p,%x)\n", iface, pIStream, cacheOptions); + + if (This->initialized) return WINCODEC_ERR_WRONGSTATE; + + seek.QuadPart = 0; + hr = IStream_Seek(pIStream, seek, STREAM_SEEK_SET, NULL); + if (FAILED(hr)) return hr; + + hr = IStream_Read(pIStream, &This->header, sizeof(ICONHEADER), &bytesread); + if (FAILED(hr)) return hr; + if (bytesread != sizeof(ICONHEADER) || + This->header.idReserved != 0 || + This->header.idType != 1) return E_FAIL; + + This->initialized = TRUE; + This->stream = pIStream; + IStream_AddRef(pIStream); + + return S_OK; }
static HRESULT WINAPI IcoDecoder_GetContainerFormat(IWICBitmapDecoder *iface, @@ -217,6 +242,8 @@ HRESULT IcoDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
This->lpVtbl = &IcoDecoder_Vtbl; This->ref = 1; + This->stream = NULL; + This->initialized = FALSE;
ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv); IUnknown_Release((IUnknown*)This);