windowscodecs: Add support for IMILBitmapSource interface.

This commit is contained in:
Dmitry Timoshkov 2013-10-14 12:07:06 +09:00 committed by Alexandre Julliard
parent 0d40cdc779
commit 5e78e0b695
2 changed files with 292 additions and 1 deletions

View File

@ -33,9 +33,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
/* WARNING: .NET Media Integration Layer (MIL) directly dereferences
* BitmapImpl members and depends on its exact layout.
*/
typedef struct BitmapImpl {
IWICBitmap IWICBitmap_iface;
IMILUnknown1 IMILUnknown1_iface;
LONG ref;
IMILBitmapSource IMILBitmapSource_iface;
IWICBitmap IWICBitmap_iface;
IMILUnknown2 IMILUnknown2_iface;
IWICPalette *palette;
int palette_set;
LONG lock; /* 0 if not locked, -1 if locked for writing, count if locked for reading */
@ -61,6 +67,21 @@ static inline BitmapImpl *impl_from_IWICBitmap(IWICBitmap *iface)
return CONTAINING_RECORD(iface, BitmapImpl, IWICBitmap_iface);
}
static inline BitmapImpl *impl_from_IMILBitmapSource(IMILBitmapSource *iface)
{
return CONTAINING_RECORD(iface, BitmapImpl, IMILBitmapSource_iface);
}
static inline BitmapImpl *impl_from_IMILUnknown1(IMILUnknown1 *iface)
{
return CONTAINING_RECORD(iface, BitmapImpl, IMILUnknown1_iface);
}
static inline BitmapImpl *impl_from_IMILUnknown2(IMILUnknown2 *iface)
{
return CONTAINING_RECORD(iface, BitmapImpl, IMILUnknown2_iface);
}
static inline BitmapLockImpl *impl_from_IWICBitmapLock(IWICBitmapLock *iface)
{
return CONTAINING_RECORD(iface, BitmapLockImpl, IWICBitmapLock_iface);
@ -228,6 +249,10 @@ static HRESULT WINAPI BitmapImpl_QueryInterface(IWICBitmap *iface, REFIID iid,
{
*ppv = &This->IWICBitmap_iface;
}
else if (IsEqualIID(&IID_IMILBitmapSource, iid))
{
*ppv = &This->IMILBitmapSource_iface;
}
else
{
*ppv = NULL;
@ -446,6 +471,229 @@ static const IWICBitmapVtbl BitmapImpl_Vtbl = {
BitmapImpl_SetResolution
};
static HRESULT WINAPI IMILBitmapImpl_QueryInterface(IMILBitmapSource *iface, REFIID iid,
void **ppv)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid) ||
IsEqualIID(&IID_IMILBitmapSource, iid))
{
IUnknown_AddRef(&This->IMILBitmapSource_iface);
*ppv = &This->IMILBitmapSource_iface;
return S_OK;
}
*ppv = NULL;
return E_NOINTERFACE;
}
static ULONG WINAPI IMILBitmapImpl_AddRef(IMILBitmapSource *iface)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
return IWICBitmap_AddRef(&This->IWICBitmap_iface);
}
static ULONG WINAPI IMILBitmapImpl_Release(IMILBitmapSource *iface)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
return IWICBitmap_Release(&This->IWICBitmap_iface);
}
static HRESULT WINAPI IMILBitmapImpl_GetSize(IMILBitmapSource *iface,
UINT *width, UINT *height)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
return IWICBitmap_GetSize(&This->IWICBitmap_iface, width, height);
}
static const struct
{
const GUID *WIC_format;
int enum_format;
} pixel_fmt_map[] =
{
{ &GUID_WICPixelFormatDontCare, 0 },
{ &GUID_WICPixelFormat1bppIndexed, 1 },
{ &GUID_WICPixelFormat2bppIndexed, 2 },
{ &GUID_WICPixelFormat4bppIndexed, 3 },
{ &GUID_WICPixelFormat8bppIndexed, 4 },
{ &GUID_WICPixelFormatBlackWhite, 5 },
{ &GUID_WICPixelFormat2bppGray, 6 },
{ &GUID_WICPixelFormat4bppGray, 7 },
{ &GUID_WICPixelFormat8bppGray, 8 },
{ &GUID_WICPixelFormat16bppBGR555, 9 },
{ &GUID_WICPixelFormat16bppBGR565, 0x0a },
{ &GUID_WICPixelFormat16bppGray, 0x0b },
{ &GUID_WICPixelFormat24bppBGR, 0x0c },
{ &GUID_WICPixelFormat24bppRGB, 0x0d },
{ &GUID_WICPixelFormat32bppBGR, 0x0e },
{ &GUID_WICPixelFormat32bppBGRA, 0x0f },
{ &GUID_WICPixelFormat32bppPBGRA, 0x10 },
{ &GUID_WICPixelFormat48bppRGB, 0x15 },
{ &GUID_WICPixelFormat64bppRGBA, 0x16 },
{ &GUID_WICPixelFormat64bppPRGBA, 0x17 },
{ &GUID_WICPixelFormat32bppCMYK, 0x1c }
};
static HRESULT WINAPI IMILBitmapImpl_GetPixelFormat(IMILBitmapSource *iface,
int *format)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
int i;
TRACE("(%p,%p)\n", iface, format);
if (!format) return E_INVALIDARG;
*format = 0;
for (i = 0; i < sizeof(pixel_fmt_map)/sizeof(pixel_fmt_map[0]); i++)
{
if (IsEqualGUID(pixel_fmt_map[i].WIC_format, &This->pixelformat))
{
*format = pixel_fmt_map[i].enum_format;
break;
}
}
return S_OK;
}
static HRESULT WINAPI IMILBitmapImpl_GetResolution(IMILBitmapSource *iface,
double *dpix, double *dpiy)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
return IWICBitmap_GetResolution(&This->IWICBitmap_iface, dpix, dpiy);
}
static HRESULT WINAPI IMILBitmapImpl_CopyPalette(IMILBitmapSource *iface,
IWICPalette *palette)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
return IWICBitmap_CopyPalette(&This->IWICBitmap_iface, palette);
}
static HRESULT WINAPI IMILBitmapImpl_CopyPixels(IMILBitmapSource *iface,
const WICRect *rc, UINT stride, UINT size, BYTE *buffer)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
return IWICBitmap_CopyPixels(&This->IWICBitmap_iface, rc, stride, size, buffer);
}
static HRESULT WINAPI IMILBitmapImpl_UnknownMethod1(IMILBitmapSource *iface, void **ppv)
{
BitmapImpl *This = impl_from_IMILBitmapSource(iface);
TRACE("(%p,%p)\n", iface, ppv);
if (!ppv) return E_INVALIDARG;
IUnknown_AddRef(&This->IMILUnknown1_iface);
*ppv = &This->IMILUnknown1_iface;
return S_OK;
}
static const IMILBitmapSourceVtbl IMILBitmapImpl_Vtbl =
{
IMILBitmapImpl_QueryInterface,
IMILBitmapImpl_AddRef,
IMILBitmapImpl_Release,
IMILBitmapImpl_GetSize,
IMILBitmapImpl_GetPixelFormat,
IMILBitmapImpl_GetResolution,
IMILBitmapImpl_CopyPalette,
IMILBitmapImpl_CopyPixels,
IMILBitmapImpl_UnknownMethod1,
};
static HRESULT WINAPI IMILUnknown1Impl_QueryInterface(IMILUnknown1 *iface, REFIID iid,
void **ppv)
{
BitmapImpl *This = impl_from_IMILUnknown1(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid))
{
IUnknown_AddRef(&This->IMILUnknown1_iface);
*ppv = iface;
return S_OK;
}
return IWICBitmap_QueryInterface(&This->IWICBitmap_iface, iid, ppv);
}
static ULONG WINAPI IMILUnknown1Impl_AddRef(IMILUnknown1 *iface)
{
BitmapImpl *This = impl_from_IMILUnknown1(iface);
return IWICBitmap_AddRef(&This->IWICBitmap_iface);
}
static ULONG WINAPI IMILUnknown1Impl_Release(IMILUnknown1 *iface)
{
BitmapImpl *This = impl_from_IMILUnknown1(iface);
return IWICBitmap_Release(&This->IWICBitmap_iface);
}
static const IMILUnknown1Vtbl IMILUnknown1Impl_Vtbl =
{
IMILUnknown1Impl_QueryInterface,
IMILUnknown1Impl_AddRef,
IMILUnknown1Impl_Release,
};
static HRESULT WINAPI IMILUnknown2Impl_QueryInterface(IMILUnknown2 *iface, REFIID iid,
void **ppv)
{
BitmapImpl *This = impl_from_IMILUnknown2(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(iid), ppv);
if (!ppv) return E_INVALIDARG;
if (IsEqualIID(&IID_IUnknown, iid))
{
IUnknown_AddRef(&This->IMILUnknown2_iface);
*ppv = iface;
return S_OK;
}
return IWICBitmap_QueryInterface(&This->IWICBitmap_iface, iid, ppv);
}
static ULONG WINAPI IMILUnknown2Impl_AddRef(IMILUnknown2 *iface)
{
BitmapImpl *This = impl_from_IMILUnknown2(iface);
return IWICBitmap_AddRef(&This->IWICBitmap_iface);
}
static ULONG WINAPI IMILUnknown2Impl_Release(IMILUnknown2 *iface)
{
BitmapImpl *This = impl_from_IMILUnknown2(iface);
return IWICBitmap_Release(&This->IWICBitmap_iface);
}
static HRESULT WINAPI IMILUnknown2Impl_UnknownMethod1(IMILUnknown2 *iface, void *arg1, void *arg2)
{
FIXME("(%p,%p,%p): stub\n", iface, arg1, arg2);
return E_NOTIMPL;
}
static const IMILUnknown2Vtbl IMILUnknown2Impl_Vtbl =
{
IMILUnknown2Impl_QueryInterface,
IMILUnknown2Impl_AddRef,
IMILUnknown2Impl_Release,
IMILUnknown2Impl_UnknownMethod1,
};
HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
UINT stride, UINT datasize, BYTE *bits,
REFWICPixelFormatGUID pixelFormat, WICBitmapCreateCacheOption option,
@ -476,6 +724,9 @@ HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
if (bits) memcpy(data, bits, datasize);
This->IWICBitmap_iface.lpVtbl = &BitmapImpl_Vtbl;
This->IMILBitmapSource_iface.lpVtbl = &IMILBitmapImpl_Vtbl;
This->IMILUnknown1_iface.lpVtbl = &IMILUnknown1Impl_Vtbl;
This->IMILUnknown2_iface.lpVtbl = &IMILUnknown2Impl_Vtbl;
This->ref = 1;
This->palette = NULL;
This->palette_set = 0;

View File

@ -27,6 +27,46 @@ DEFINE_GUID(GUID_WineContainerFormatTga, 0x0c44fda1,0xa5c5,0x4298,0x96,0x85,0x47
DEFINE_GUID(GUID_VendorWine, 0xddf46da1,0x7dc1,0x404e,0x98,0xf2,0xef,0xa4,0x8d,0xfc,0x95,0x0a);
DEFINE_GUID(IID_IMILBitmapSource,0x7543696a,0xbc8d,0x46b0,0x5f,0x81,0x8d,0x95,0x72,0x89,0x72,0xbe);
#define INTERFACE IMILBitmapSource
DECLARE_INTERFACE_(IMILBitmapSource,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** IMILBitmapSource methods ***/
STDMETHOD_(HRESULT,GetSize)(THIS_ UINT *,UINT *);
STDMETHOD_(HRESULT,GetPixelFormat)(THIS_ int *);
STDMETHOD_(HRESULT,GetResolution)(THIS_ double *,double *);
STDMETHOD_(HRESULT,CopyPalette)(THIS_ IWICPalette *);
STDMETHOD_(HRESULT,CopyPixels)(THIS_ const WICRect *,UINT,UINT,BYTE *);
STDMETHOD_(HRESULT,UnknownMethod1)(THIS_ void **);
};
#undef INTERFACE
#define INTERFACE IMILUnknown1
DECLARE_INTERFACE_(IMILUnknown1,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
};
#undef INTERFACE
#define INTERFACE IMILUnknown2
DECLARE_INTERFACE_(IMILUnknown2,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD_(HRESULT,QueryInterface)(THIS_ REFIID,void **) PURE;
STDMETHOD_(ULONG,AddRef)(THIS) PURE;
STDMETHOD_(ULONG,Release)(THIS) PURE;
/*** unknown methods ***/
STDMETHOD_(HRESULT,UnknownMethod1)(THIS_ void *, void *) PURE;
};
#undef INTERFACE
extern HRESULT FormatConverter_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv) DECLSPEC_HIDDEN;
extern HRESULT ComponentFactory_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv) DECLSPEC_HIDDEN;
extern HRESULT BmpDecoder_CreateInstance(IUnknown *pUnkOuter, REFIID riid, void** ppv) DECLSPEC_HIDDEN;