[PATCH 2/5] windowscodecs: Support reading from memory streams in IWICStream

Tony Wasserka tony.wasserka at freenet.de
Fri Aug 21 04:07:37 CDT 2009


---
 dlls/windowscodecs/stream.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/dlls/windowscodecs/stream.c b/dlls/windowscodecs/stream.c
index 2b3f5d9..f8359be 100644
--- a/dlls/windowscodecs/stream.c
+++ b/dlls/windowscodecs/stream.c
@@ -39,6 +39,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
 typedef struct StreamOnMemory {
     const IStreamVtbl *lpVtbl;
     LONG ref;
+
+    BYTE *pbMemory;
+    DWORD dwMemsize;
+    DWORD dwCurPos;
 } StreamOnMemory;
 
 static HRESULT WINAPI StreamOnMemory_QueryInterface(IStream *iface,
@@ -89,8 +93,18 @@ static ULONG WINAPI StreamOnMemory_Release(IStream *iface)
 static HRESULT WINAPI StreamOnMemory_Read(IStream *iface,
     void *pv, ULONG cb, ULONG *pcbRead)
 {
-    FIXME("(%p): stub\n", iface);
-    return E_NOTIMPL;
+    StreamOnMemory *This = (StreamOnMemory*)iface;
+    ULONG uBytesRead;
+    TRACE("(%p)\n", This);
+
+    if (!pv) return E_INVALIDARG;
+
+    uBytesRead = min(cb, This->dwMemsize - This->dwCurPos);
+    memcpy(pv, This->pbMemory + This->dwCurPos, uBytesRead);
+    This->dwCurPos += uBytesRead;
+    if (pcbRead) *pcbRead = uBytesRead;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI StreamOnMemory_Write(IStream *iface,
@@ -403,6 +417,9 @@ static HRESULT WINAPI IWICStreamImpl_InitializeFromMemory(IWICStream *iface,
 
     pObject->lpVtbl = &StreamOnMemory_Vtbl;
     pObject->ref = 1;
+    pObject->pbMemory = pbBuffer;
+    pObject->dwMemsize = cbBufferSize;
+    pObject->dwCurPos = 0;
 
     This->pStream = (IStream*)pObject;
     return S_OK;
-- 
1.6.3.3


--------------090008070605060704010507--



More information about the wine-patches mailing list