[PATCH 03/12] windowscodecs: Support reading from memory streams in IWICStream
Tony Wasserka
tony.wasserka at freenet.de
Tue Aug 18 08:18:08 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 5e0c40b..26c72b8 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,
@@ -70,8 +74,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,
@@ -384,6 +398,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
--------------060504050304090101010608--
More information about the wine-patches
mailing list