Vincent Povirk : windowscodecs: Implement GetFrame for BMP decoder.

Alexandre Julliard julliard at winehq.org
Mon Jun 29 09:17:48 CDT 2009


Module: wine
Branch: master
Commit: eca8ef6924724a009b63032ebc376c53cb4ef5c5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=eca8ef6924724a009b63032ebc376c53cb4ef5c5

Author: Vincent Povirk <madewokherd at gmail.com>
Date:   Sat Jun 13 17:32:16 2009 -0500

windowscodecs: Implement GetFrame for BMP decoder.

---

 dlls/windowscodecs/bmpdecode.c |  156 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 154 insertions(+), 2 deletions(-)

diff --git a/dlls/windowscodecs/bmpdecode.c b/dlls/windowscodecs/bmpdecode.c
index f60471e..5ab8121 100644
--- a/dlls/windowscodecs/bmpdecode.c
+++ b/dlls/windowscodecs/bmpdecode.c
@@ -59,12 +59,141 @@ typedef struct {
 } BITMAPCOREHEADER2;
 
 typedef struct {
+    const IWICBitmapFrameDecodeVtbl *lpVtbl;
+    LONG ref;
+    IStream *stream;
+    BITMAPFILEHEADER bfh;
+    BITMAPV5HEADER bih;
+} BmpFrameDecode;
+
+HRESULT WINAPI BmpFrameDecode_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid,
+    void **ppv)
+{
+    BmpFrameDecode *This = (BmpFrameDecode*)iface;
+    TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
+
+    if (!ppv) return E_INVALIDARG;
+
+    if (IsEqualIID(&IID_IUnknown, iid) ||
+        IsEqualIID(&IID_IWICBitmapSource, iid) ||
+        IsEqualIID(&IID_IWICBitmapFrameDecode, iid))
+    {
+        *ppv = This;
+    }
+    else
+    {
+        *ppv = NULL;
+        return E_NOINTERFACE;
+    }
+
+    IUnknown_AddRef((IUnknown*)*ppv);
+    return S_OK;
+}
+
+static ULONG WINAPI BmpFrameDecode_AddRef(IWICBitmapFrameDecode *iface)
+{
+    BmpFrameDecode *This = (BmpFrameDecode*)iface;
+    ULONG ref = InterlockedIncrement(&This->ref);
+
+    TRACE("(%p) refcount=%u\n", iface, ref);
+
+    return ref;
+}
+
+static ULONG WINAPI BmpFrameDecode_Release(IWICBitmapFrameDecode *iface)
+{
+    BmpFrameDecode *This = (BmpFrameDecode*)iface;
+    ULONG ref = InterlockedDecrement(&This->ref);
+
+    TRACE("(%p) refcount=%u\n", iface, ref);
+
+    if (ref == 0)
+    {
+        IStream_Release(This->stream);
+        HeapFree(GetProcessHeap(), 0, This);
+    }
+
+    return ref;
+}
+
+static HRESULT WINAPI BmpFrameDecode_GetSize(IWICBitmapFrameDecode *iface,
+    UINT *puiWidth, UINT *puiHeight)
+{
+    FIXME("(%p,%p,%p): stub\n", iface, puiWidth, puiHeight);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface,
+    WICPixelFormatGUID *pPixelFormat)
+{
+    FIXME("(%p,%p): stub\n", iface, pPixelFormat);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
+    double *pDpiX, double *pDpiY)
+{
+    FIXME("(%p,%p,%p): stub\n", iface, pDpiX, pDpiY);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
+    IWICPalette *pIPalette)
+{
+    FIXME("(%p,%p): stub\n", iface, pIPalette);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface,
+    const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
+{
+    FIXME("(%p,%p,%u,%u,%p): stub\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpFrameDecode_GetMetadataQueryReader(IWICBitmapFrameDecode *iface,
+    IWICMetadataQueryReader **ppIMetadataQueryReader)
+{
+    FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpFrameDecode_GetColorContexts(IWICBitmapFrameDecode *iface,
+    UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
+{
+    FIXME("(%p,%u,%p,%p): stub\n", iface, cCount, ppIColorContexts, pcActualCount);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI BmpFrameDecode_GetThumbnail(IWICBitmapFrameDecode *iface,
+    IWICBitmapSource **ppIThumbnail)
+{
+    FIXME("(%p,%p): stub\n", iface, ppIThumbnail);
+    return E_NOTIMPL;
+}
+
+static const IWICBitmapFrameDecodeVtbl BmpFrameDecode_Vtbl = {
+    BmpFrameDecode_QueryInterface,
+    BmpFrameDecode_AddRef,
+    BmpFrameDecode_Release,
+    BmpFrameDecode_GetSize,
+    BmpFrameDecode_GetPixelFormat,
+    BmpFrameDecode_GetResolution,
+    BmpFrameDecode_CopyPalette,
+    BmpFrameDecode_CopyPixels,
+    BmpFrameDecode_GetMetadataQueryReader,
+    BmpFrameDecode_GetColorContexts,
+    BmpFrameDecode_GetThumbnail
+};
+
+typedef struct {
     const IWICBitmapDecoderVtbl *lpVtbl;
     LONG ref;
     BOOL initialized;
     IStream *stream;
     BITMAPFILEHEADER bfh;
     BITMAPV5HEADER bih;
+    BmpFrameDecode *framedecode;
 } BmpDecoder;
 
 static HRESULT BmpDecoder_ReadHeaders(BmpDecoder* This, IStream *stream)
@@ -140,6 +269,7 @@ static ULONG WINAPI BmpDecoder_Release(IWICBitmapDecoder *iface)
     if (ref == 0)
     {
         if (This->stream) IStream_Release(This->stream);
+        if (This->framedecode) IUnknown_Release((IUnknown*)This->framedecode);
         HeapFree(GetProcessHeap(), 0, This);
     }
 
@@ -229,8 +359,29 @@ static HRESULT WINAPI BmpDecoder_GetFrameCount(IWICBitmapDecoder *iface,
 static HRESULT WINAPI BmpDecoder_GetFrame(IWICBitmapDecoder *iface,
     UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
 {
-    FIXME("(%p,%u,%p): stub\n", iface, index, ppIBitmapFrame);
-    return E_NOTIMPL;
+    BmpDecoder *This = (BmpDecoder*)iface;
+
+    if (index != 0) return E_INVALIDARG;
+
+    if (!This->stream) return WINCODEC_ERR_WRONGSTATE;
+
+    if (!This->framedecode)
+    {
+        This->framedecode = HeapAlloc(GetProcessHeap(), 0, sizeof(BmpFrameDecode));
+        if (!This->framedecode) return E_OUTOFMEMORY;
+
+        This->framedecode->lpVtbl = &BmpFrameDecode_Vtbl;
+        This->framedecode->ref = 1;
+        This->framedecode->stream = This->stream;
+        IStream_AddRef(This->stream);
+        This->framedecode->bfh = This->bfh;
+        This->framedecode->bih = This->bih;
+    }
+
+    *ppIBitmapFrame = (IWICBitmapFrameDecode*)This->framedecode;
+    IWICBitmapFrameDecode_AddRef((IWICBitmapFrameDecode*)This->framedecode);
+
+    return S_OK;
 }
 
 static const IWICBitmapDecoderVtbl BmpDecoder_Vtbl = {
@@ -268,6 +419,7 @@ HRESULT BmpDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID iid, void** ppv)
     This->ref = 1;
     This->initialized = FALSE;
     This->stream = NULL;
+    This->framedecode = NULL;
 
     ret = IUnknown_QueryInterface((IUnknown*)This, iid, ppv);
     IUnknown_Release((IUnknown*)This);




More information about the wine-cvs mailing list