[2/9] windowscodecs: add a stub decoder for the BMP format

Vincent Povirk madewokherd+8cd9 at gmail.com
Sat Jun 27 20:49:10 CDT 2009


Vincent Povirk
-------------- next part --------------
From 48a447309fedd12ba35e95fd36921ac3d08a9aa6 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Wed, 10 Jun 2009 15:40:27 -0500
Subject: [PATCH 2/9] windowscodecs: add a stub decoder for the BMP format

---
 dlls/windowscodecs/Makefile.in         |    1 +
 dlls/windowscodecs/bmpdecode.c         |  202 ++++++++++++++++++++++++++++++++
 dlls/windowscodecs/clsfactory.c        |    1 +
 dlls/windowscodecs/regsvr.c            |    6 +
 dlls/windowscodecs/wincodecs_private.h |    1 +
 5 files changed, 211 insertions(+), 0 deletions(-)
 create mode 100644 dlls/windowscodecs/bmpdecode.c

diff --git a/dlls/windowscodecs/Makefile.in b/dlls/windowscodecs/Makefile.in
index 7e6f97c..324d315 100644
--- a/dlls/windowscodecs/Makefile.in
+++ b/dlls/windowscodecs/Makefile.in
@@ -6,6 +6,7 @@ MODULE    = windowscodecs.dll
 IMPORTS   = kernel32 uuid advapi32 ole32
 
 C_SRCS = \
+	bmpdecode.c \
 	clsfactory.c \
 	imgfactory.c \
 	regsvr.c \
diff --git a/dlls/windowscodecs/bmpdecode.c b/dlls/windowscodecs/bmpdecode.c
new file mode 100644
index 0000000..52ffb80
--- /dev/null
+++ b/dlls/windowscodecs/bmpdecode.c
@@ -0,0 +1,202 @@
+/*
+ * 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 <stdarg.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "winreg.h"
+#include "objbase.h"
+#include "wincodec.h"
+
+#include "wincodecs_private.h"
+
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
+
+typedef struct {
+    const IWICBitmapDecoderVtbl *lpIWICBitmapDecoderVtbl;
+    LONG ref;
+} BmpDecoder;
+
+HRESULT WINAPI BmpDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid,
+    void **ppv)
+{
+    BmpDecoder *This = (BmpDecoder*)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 BmpDecoder_AddRef(IWICBitmapDecoder *iface)
+{
+    BmpDecoder *This = (BmpDecoder*)iface;
+    ULONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p) refcount=%u\n", iface, ref);
+
+    return ref;
+}
+
+static ULONG WINAPI BmpDecoder_Release(IWICBitmapDecoder *iface)
+{
+    BmpDecoder *This = (BmpDecoder*)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 BmpDecoder_QueryCapability(IWICBitmapDecoder *iface, IStream *pIStream,
+    DWORD *pdwCapability)
+{
+    FIXME("(%p,%p,%p): stub\n", iface, pIStream, pdwCapability);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpDecoder_Initialize(IWICBitmapDecoder *iface, IStream *pIStream,
+    WICDecodeOptions cacheOptions)
+{
+    FIXME("(%p,%p,%x): stub\n", iface, pIStream, cacheOptions);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
+    GUID *pguidContainerFormat)
+{
+    FIXME("(%p,%p): stub\n", iface, pguidContainerFormat);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
+    IWICBitmapDecoderInfo **ppIDecoderInfo)
+{
+    FIXME("(%p,%p): stub\n", iface, ppIDecoderInfo);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpDecoder_CopyPalette(IWICBitmapDecoder *iface,
+    IWICPalette *pIPalette)
+{
+    FIXME("(%p,%p): stub\n", iface, pIPalette);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
+    IWICMetadataQueryReader **ppIMetadataQueryReader)
+{
+    FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpDecoder_GetPreview(IWICBitmapDecoder *iface,
+    IWICBitmapSource **ppIBitmapSource)
+{
+    FIXME("(%p,%p): stub\n", iface, ppIBitmapSource);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpDecoder_GetColorContexts(IWICBitmapDecoder *iface,
+    UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
+{
+    FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpDecoder_GetThumbnail(IWICBitmapDecoder *iface,
+    IWICBitmapSource **ppIThumbnail)
+{
+    FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpDecoder_GetFrameCount(IWICBitmapDecoder *iface,
+    UINT *pCount)
+{
+    FIXME("(%p,%p): stub\n", iface, pCount);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpDecoder_GetFrame(IWICBitmapDecoder *iface,
+    UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
+{
+    FIXME("(%p,%u,%p): stub\n", iface, index, ppIBitmapFrame);
+    return E_NOTIMPL;
+}
+
+static const IWICBitmapDecoderVtbl BmpDecoder_Vtbl = {
+    BmpDecoder_QueryInterface,
+    BmpDecoder_AddRef,
+    BmpDecoder_Release,
+    BmpDecoder_QueryCapability,
+    BmpDecoder_Initialize,
+    BmpDecoder_GetContainerFormat,
+    BmpDecoder_GetDecoderInfo,
+    BmpDecoder_CopyPalette,
+    BmpDecoder_GetMetadataQueryReader,
+    BmpDecoder_GetPreview,
+    BmpDecoder_GetColorContexts,
+    BmpDecoder_GetThumbnail,
+    BmpDecoder_GetFrameCount,
+    BmpDecoder_GetFrame
+};
+
+HRESULT BmpDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
+{
+    BmpDecoder *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(BmpDecoder));
+    if (!This) return E_OUTOFMEMORY;
+
+    This->lpIWICBitmapDecoderVtbl = &BmpDecoder_Vtbl;
+    This->ref = 1;
+
+    ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
+    IUnknown_Release((IUnknown*)This);
+
+    return ret;
+}
diff --git a/dlls/windowscodecs/clsfactory.c b/dlls/windowscodecs/clsfactory.c
index 103f928..77dbad6 100644
--- a/dlls/windowscodecs/clsfactory.c
+++ b/dlls/windowscodecs/clsfactory.c
@@ -43,6 +43,7 @@ typedef struct {
 
 static classinfo wic_classes[] = {
     {&CLSID_WICImagingFactory, ImagingFactory_CreateInstance},
+    {&CLSID_WICBmpDecoder, BmpDecoder_CreateInstance},
     {0}};
 
 typedef struct {
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index fef2979..ddb781a 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -309,6 +309,12 @@ static struct regsvr_coclass const coclass_list[] = {
 	"windowscodecs.dll",
 	"Apartment"
     },
+    {   &CLSID_WICBmpDecoder,
+	"WIC BMP Decoder",
+	NULL,
+	"windowscodecs.dll",
+	"Apartment"
+    },
     { NULL }			/* list terminator */
 };
 
diff --git a/dlls/windowscodecs/wincodecs_private.h b/dlls/windowscodecs/wincodecs_private.h
index b453920..0070bfc 100644
--- a/dlls/windowscodecs/wincodecs_private.h
+++ b/dlls/windowscodecs/wincodecs_private.h
@@ -20,5 +20,6 @@
 #define WINCODECS_PRIVATE_H
 
 extern HRESULT ImagingFactory_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv);
+extern HRESULT BmpDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv);
 
 #endif /* WINCODECS_PRIVATE_H */
-- 
1.6.3.1


More information about the wine-patches mailing list