mirror of
https://github.com/reactos/wine.git
synced 2024-12-02 00:36:43 +00:00
windowscodecs: Implement GetFrame for BMP decoder.
This commit is contained in:
parent
0caec83215
commit
eca8ef6924
@ -58,6 +58,134 @@ typedef struct {
|
||||
DWORD bc2AppData;
|
||||
} 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;
|
||||
@ -65,6 +193,7 @@ typedef struct {
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user