From ec6974e1f835856bb779f21ea1370aa7bf928283 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Thu, 20 Aug 2009 09:22:16 -0500 Subject: [PATCH] windowscodecs: add stub ICO decoder --- dlls/windowscodecs/Makefile.in | 1 + dlls/windowscodecs/clsfactory.c | 1 + dlls/windowscodecs/icoformat.c | 225 ++++++++++++++++++++++++++++++++ dlls/windowscodecs/regsvr.c | 28 ++++ dlls/windowscodecs/wincodecs_private.h | 1 + 5 files changed, 256 insertions(+), 0 deletions(-) create mode 100644 dlls/windowscodecs/icoformat.c diff --git a/dlls/windowscodecs/Makefile.in b/dlls/windowscodecs/Makefile.in index 30146e4..1b391cd 100644 --- a/dlls/windowscodecs/Makefile.in +++ b/dlls/windowscodecs/Makefile.in @@ -12,6 +12,7 @@ C_SRCS = \ clsfactory.c \ converter.c \ gifformat.c \ + icoformat.c \ imgfactory.c \ info.c \ main.c \ diff --git a/dlls/windowscodecs/clsfactory.c b/dlls/windowscodecs/clsfactory.c index 876cbbb..0ce08b3 100644 --- a/dlls/windowscodecs/clsfactory.c +++ b/dlls/windowscodecs/clsfactory.c @@ -46,6 +46,7 @@ static classinfo wic_classes[] = { {&CLSID_WICBmpDecoder, BmpDecoder_CreateInstance}, {&CLSID_WICBmpEncoder, BmpEncoder_CreateInstance}, {&CLSID_WICGifDecoder, GifDecoder_CreateInstance}, + {&CLSID_WICIcoDecoder, IcoDecoder_CreateInstance}, {&CLSID_WICDefaultFormatConverter, FormatConverter_CreateInstance}, {0}}; diff --git a/dlls/windowscodecs/icoformat.c b/dlls/windowscodecs/icoformat.c new file mode 100644 index 0000000..f61ae01 --- /dev/null +++ b/dlls/windowscodecs/icoformat.c @@ -0,0 +1,225 @@ +/* + * Copyright 2009 Vincent Povirk for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" + +#include + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "objbase.h" +#include "wincodec.h" + +#include "wincodecs_private.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(wincodecs); + +#include "pshpack1.h" + +typedef struct { + BYTE bWidth; + BYTE bHeight; + BYTE bColorCount; + BYTE bReserved; + WORD wPlanes; + WORD wBitCount; + DWORD dwDIBSize; + DWORD dwDIBOffset; +} ICONDIRENTRY; + +typedef struct +{ + WORD idReserved; + WORD idType; + WORD idCount; +} ICONHEADER; + +#include "poppack.h" + +typedef struct { + const IWICBitmapDecoderVtbl *lpVtbl; + LONG ref; +} IcoDecoder; + +static HRESULT WINAPI IcoDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid, + void **ppv) +{ + IcoDecoder *This = (IcoDecoder*)iface; + TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv); + + if (!ppv) return E_INVALIDARG; + + if (IsEqualIID(&IID_IUnknown, iid) || IsEqualIID(&IID_IWICBitmapDecoder, iid)) + { + *ppv = This; + } + else + { + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI IcoDecoder_AddRef(IWICBitmapDecoder *iface) +{ + IcoDecoder *This = (IcoDecoder*)iface; + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) refcount=%u\n", iface, ref); + + return ref; +} + +static ULONG WINAPI IcoDecoder_Release(IWICBitmapDecoder *iface) +{ + IcoDecoder *This = (IcoDecoder*)iface; + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) refcount=%u\n", iface, ref); + + if (ref == 0) + { + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static HRESULT WINAPI IcoDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *pIStream, + DWORD *pdwCapability) +{ + FIXME("(%p,%p,%p): stub\n", iface, pIStream, pdwCapability); + return E_NOTIMPL; +} + +static HRESULT WINAPI IcoDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream, + WICDecodeOptions cacheOptions) +{ + FIXME("(%p,%p,%x): stub\n", iface, pIStream, cacheOptions); + return E_NOTIMPL; +} + +static HRESULT WINAPI IcoDecoder_GetContainerFormat(IWICBitmapDecoder *iface, + GUID *pguidContainerFormat) +{ + FIXME("(%p,%p): stub\n", iface, pguidContainerFormat); + return E_NOTIMPL; +} + +static HRESULT WINAPI IcoDecoder_GetDecoderInfo(IWICBitmapDecoder *iface, + IWICBitmapDecoderInfo **ppIDecoderInfo) +{ + FIXME("(%p,%p): stub\n", iface, ppIDecoderInfo); + return E_NOTIMPL; +} + +static HRESULT WINAPI IcoDecoder_CopyPalette(IWICBitmapDecoder *iface, + IWICPalette *pIPalette) +{ + TRACE("(%p,%p)\n", iface, pIPalette); + return WINCODEC_ERR_PALETTEUNAVAILABLE; +} + +static HRESULT WINAPI IcoDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface, + IWICMetadataQueryReader **ppIMetadataQueryReader) +{ + TRACE("(%p,%p)\n", iface, ppIMetadataQueryReader); + return WINCODEC_ERR_UNSUPPORTEDOPERATION; +} + +static HRESULT WINAPI IcoDecoder_GetPreview(IWICBitmapDecoder *iface, + IWICBitmapSource **ppIBitmapSource) +{ + TRACE("(%p,%p)\n", iface, ppIBitmapSource); + return WINCODEC_ERR_UNSUPPORTEDOPERATION; +} + +static HRESULT WINAPI IcoDecoder_GetColorContexts(IWICBitmapDecoder *iface, + UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount) +{ + TRACE("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount); + return WINCODEC_ERR_UNSUPPORTEDOPERATION; +} + +static HRESULT WINAPI IcoDecoder_GetThumbnail(IWICBitmapDecoder *iface, + IWICBitmapSource **ppIThumbnail) +{ + TRACE("(%p,%p)\n", iface, ppIThumbnail); + return WINCODEC_ERR_CODECNOTHUMBNAIL; +} + +static HRESULT WINAPI IcoDecoder_GetFrameCount(IWICBitmapDecoder *iface, + UINT *pCount) +{ + FIXME("(%p,%p): stub\n", iface, pCount); + return E_NOTIMPL; +} + +static HRESULT WINAPI IcoDecoder_GetFrame(IWICBitmapDecoder *iface, + UINT index, IWICBitmapFrameDecode **ppIBitmapFrame) +{ + FIXME("(%p,%u,%p): stub\n", iface, index, ppIBitmapFrame); + return E_NOTIMPL; +} + +static const IWICBitmapDecoderVtbl IcoDecoder_Vtbl = { + IcoDecoder_QueryInterface, + IcoDecoder_AddRef, + IcoDecoder_Release, + IcoDecoder_QueryCapability, + IcoDecoder_Initialize, + IcoDecoder_GetContainerFormat, + IcoDecoder_GetDecoderInfo, + IcoDecoder_CopyPalette, + IcoDecoder_GetMetadataQueryReader, + IcoDecoder_GetPreview, + IcoDecoder_GetColorContexts, + IcoDecoder_GetThumbnail, + IcoDecoder_GetFrameCount, + IcoDecoder_GetFrame +}; + +HRESULT IcoDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv) +{ + IcoDecoder *This; + HRESULT ret; + + TRACE("(%p,%s,%p)\n", pUnkOuter, debugstr_guid(iid), ppv); + + *ppv = NULL; + + if (pUnkOuter) return CLASS_E_NOAGGREGATION; + + This = HeapAlloc(GetProcessHeap(), 0, sizeof(IcoDecoder)); + if (!This) return E_OUTOFMEMORY; + + This->lpVtbl = &IcoDecoder_Vtbl; + This->ref = 1; + + ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv); + IUnknown_Release((IUnknown*)This); + + return ret; +} diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c index 5860a82..b931b19 100644 --- a/dlls/windowscodecs/regsvr.c +++ b/dlls/windowscodecs/regsvr.c @@ -747,6 +747,12 @@ static struct regsvr_coclass const coclass_list[] = { "windowscodecs.dll", "Apartment" }, + { &CLSID_WICIcoDecoder, + "WIC ICO Decoder", + NULL, + "windowscodecs.dll", + "Apartment" + }, { &CLSID_WICDefaultFormatConverter, "WIC Default Format Converter", NULL, @@ -795,6 +801,18 @@ static struct decoder_pattern const gif_patterns[] = { {0} }; +static const BYTE ico_magic[] = {00,00,01,00}; + +static GUID const * const ico_formats[] = { + &GUID_WICPixelFormat32bppBGRA, + NULL +}; + +static struct decoder_pattern const ico_patterns[] = { + {4,0,ico_magic,mask_all,0}, + {0} +}; + static struct regsvr_decoder const decoder_list[] = { { &CLSID_WICBmpDecoder, "The Wine Project", @@ -816,6 +834,16 @@ static struct regsvr_decoder const decoder_list[] = { gif_formats, gif_patterns }, + { &CLSID_WICIcoDecoder, + "The Wine Project", + "ICO Decoder", + "1.0.0.0", + &GUID_VendorMicrosoft, + "image/vnd.microsoft.icon", + ".ico", + ico_formats, + ico_patterns + }, { NULL } /* list terminator */ }; diff --git a/dlls/windowscodecs/wincodecs_private.h b/dlls/windowscodecs/wincodecs_private.h index 6dcd47e..1c0583b 100644 --- a/dlls/windowscodecs/wincodecs_private.h +++ b/dlls/windowscodecs/wincodecs_private.h @@ -24,6 +24,7 @@ extern HRESULT ImagingFactory_CreateInstance(IUnknown *pUnkOuter, REFIID riid, v extern HRESULT BmpDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv); extern HRESULT BmpEncoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv); extern HRESULT GifDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv); +extern HRESULT IcoDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv); extern HRESULT PaletteImpl_Create(IWICPalette **palette); -- 1.5.4.3