windowscodecs: Support reading from memory streams in IWICStream.

This commit is contained in:
Tony Wasserka 2009-08-21 11:07:37 +02:00 committed by Alexandre Julliard
parent af6ece97b1
commit bb83fb264b
1 changed files with 19 additions and 2 deletions

View File

@ -37,6 +37,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,
@ -86,8 +90,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,
@ -400,6 +414,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;