Commit 45e9804a authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

windowscodecs: Implement GetFrameCount and GetFrame for the GIF decoder.

parent e6eb982c
...@@ -42,6 +42,134 @@ typedef struct { ...@@ -42,6 +42,134 @@ typedef struct {
GifFileType *gif; GifFileType *gif;
} GifDecoder; } GifDecoder;
typedef struct {
const IWICBitmapFrameDecodeVtbl *lpVtbl;
LONG ref;
SavedImage *frame;
GifDecoder *parent;
} GifFrameDecode;
static HRESULT WINAPI GifFrameDecode_QueryInterface(IWICBitmapFrameDecode *iface, REFIID iid,
void **ppv)
{
GifFrameDecode *This = (GifFrameDecode*)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 GifFrameDecode_AddRef(IWICBitmapFrameDecode *iface)
{
GifFrameDecode *This = (GifFrameDecode*)iface;
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
return ref;
}
static ULONG WINAPI GifFrameDecode_Release(IWICBitmapFrameDecode *iface)
{
GifFrameDecode *This = (GifFrameDecode*)iface;
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p) refcount=%u\n", iface, ref);
if (ref == 0)
{
IUnknown_Release((IUnknown*)This->parent);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
static HRESULT WINAPI GifFrameDecode_GetSize(IWICBitmapFrameDecode *iface,
UINT *puiWidth, UINT *puiHeight)
{
FIXME("(%p,%p,%p): stub\n", iface, puiWidth, puiHeight);
return E_NOTIMPL;
}
static HRESULT WINAPI GifFrameDecode_GetPixelFormat(IWICBitmapFrameDecode *iface,
WICPixelFormatGUID *pPixelFormat)
{
memcpy(pPixelFormat, &GUID_WICPixelFormat8bppIndexed, sizeof(GUID));
return S_OK;
}
static HRESULT WINAPI GifFrameDecode_GetResolution(IWICBitmapFrameDecode *iface,
double *pDpiX, double *pDpiY)
{
FIXME("(%p,%p,%p): stub\n", iface, pDpiX, pDpiY);
return E_NOTIMPL;
}
static HRESULT WINAPI GifFrameDecode_CopyPalette(IWICBitmapFrameDecode *iface,
IWICPalette *pIPalette)
{
FIXME("(%p,%p): stub\n", iface, pIPalette);
return E_NOTIMPL;
}
static HRESULT WINAPI GifFrameDecode_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 GifFrameDecode_GetMetadataQueryReader(IWICBitmapFrameDecode *iface,
IWICMetadataQueryReader **ppIMetadataQueryReader)
{
TRACE("(%p,%p)\n", iface, ppIMetadataQueryReader);
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI GifFrameDecode_GetColorContexts(IWICBitmapFrameDecode *iface,
UINT cCount, IWICColorContext **ppIColorContexts, UINT *pcActualCount)
{
TRACE("(%p,%u,%p,%p)\n", iface, cCount, ppIColorContexts, pcActualCount);
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI GifFrameDecode_GetThumbnail(IWICBitmapFrameDecode *iface,
IWICBitmapSource **ppIThumbnail)
{
TRACE("(%p,%p)\n", iface, ppIThumbnail);
return WINCODEC_ERR_CODECNOTHUMBNAIL;
}
static const IWICBitmapFrameDecodeVtbl GifFrameDecode_Vtbl = {
GifFrameDecode_QueryInterface,
GifFrameDecode_AddRef,
GifFrameDecode_Release,
GifFrameDecode_GetSize,
GifFrameDecode_GetPixelFormat,
GifFrameDecode_GetResolution,
GifFrameDecode_CopyPalette,
GifFrameDecode_CopyPixels,
GifFrameDecode_GetMetadataQueryReader,
GifFrameDecode_GetColorContexts,
GifFrameDecode_GetThumbnail
};
static HRESULT WINAPI GifDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid, static HRESULT WINAPI GifDecoder_QueryInterface(IWICBitmapDecoder *iface, REFIID iid,
void **ppv) void **ppv)
{ {
...@@ -199,15 +327,41 @@ static HRESULT WINAPI GifDecoder_GetThumbnail(IWICBitmapDecoder *iface, ...@@ -199,15 +327,41 @@ static HRESULT WINAPI GifDecoder_GetThumbnail(IWICBitmapDecoder *iface,
static HRESULT WINAPI GifDecoder_GetFrameCount(IWICBitmapDecoder *iface, static HRESULT WINAPI GifDecoder_GetFrameCount(IWICBitmapDecoder *iface,
UINT *pCount) UINT *pCount)
{ {
FIXME("(%p,%p): stub\n", iface, pCount); GifDecoder *This = (GifDecoder*)iface;
return E_NOTIMPL; TRACE("(%p,%p)\n", iface, pCount);
if (!This->initialized) return WINCODEC_ERR_NOTINITIALIZED;
*pCount = This->gif->ImageCount;
TRACE("<- %u\n", *pCount);
return S_OK;
} }
static HRESULT WINAPI GifDecoder_GetFrame(IWICBitmapDecoder *iface, static HRESULT WINAPI GifDecoder_GetFrame(IWICBitmapDecoder *iface,
UINT index, IWICBitmapFrameDecode **ppIBitmapFrame) UINT index, IWICBitmapFrameDecode **ppIBitmapFrame)
{ {
FIXME("(%p,%u,%p): stub\n", iface, index, ppIBitmapFrame); GifDecoder *This = (GifDecoder*)iface;
return E_NOTIMPL; GifFrameDecode *result;
TRACE("(%p,%u,%p)\n", iface, index, ppIBitmapFrame);
if (!This->initialized) return WINCODEC_ERR_NOTINITIALIZED;
if (index >= This->gif->ImageCount) return E_INVALIDARG;
result = HeapAlloc(GetProcessHeap(), 0, sizeof(GifFrameDecode));
if (!result) return E_OUTOFMEMORY;
result->lpVtbl = &GifFrameDecode_Vtbl;
result->ref = 1;
result->frame = &This->gif->SavedImages[index];
IWICBitmapDecoder_AddRef(iface);
result->parent = This;
*ppIBitmapFrame = (IWICBitmapFrameDecode*)result;
return S_OK;
} }
static const IWICBitmapDecoderVtbl GifDecoder_Vtbl = { static const IWICBitmapDecoderVtbl GifDecoder_Vtbl = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment