windowscodecs: Implement SetPixelFormat for BMP frame encoder.

This commit is contained in:
Vincent Povirk 2009-08-11 16:35:20 -05:00 committed by Alexandre Julliard
parent 07fd33d1fa
commit db040535f5
1 changed files with 35 additions and 2 deletions

View File

@ -35,6 +35,21 @@
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs); WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
struct bmp_pixelformat {
const WICPixelFormatGUID *guid;
UINT bpp;
DWORD compression;
DWORD redmask;
DWORD greenmask;
DWORD bluemask;
DWORD alphamask;
};
static const struct bmp_pixelformat formats[] = {
{&GUID_WICPixelFormat24bppBGR, 24, BI_RGB},
{NULL}
};
typedef struct BmpFrameEncode { typedef struct BmpFrameEncode {
const IWICBitmapFrameEncodeVtbl *lpVtbl; const IWICBitmapFrameEncodeVtbl *lpVtbl;
LONG ref; LONG ref;
@ -42,6 +57,7 @@ typedef struct BmpFrameEncode {
BOOL initialized; BOOL initialized;
UINT width, height; UINT width, height;
BYTE *bits; BYTE *bits;
const struct bmp_pixelformat *format;
} BmpFrameEncode; } BmpFrameEncode;
static HRESULT WINAPI BmpFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface, REFIID iid, static HRESULT WINAPI BmpFrameEncode_QueryInterface(IWICBitmapFrameEncode *iface, REFIID iid,
@ -130,8 +146,24 @@ static HRESULT WINAPI BmpFrameEncode_SetResolution(IWICBitmapFrameEncode *iface,
static HRESULT WINAPI BmpFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface, static HRESULT WINAPI BmpFrameEncode_SetPixelFormat(IWICBitmapFrameEncode *iface,
WICPixelFormatGUID *pPixelFormat) WICPixelFormatGUID *pPixelFormat)
{ {
FIXME("(%p,%s): stub\n", iface, debugstr_guid(pPixelFormat)); BmpFrameEncode *This = (BmpFrameEncode*)iface;
return E_NOTIMPL; int i;
TRACE("(%p,%s)\n", iface, debugstr_guid(pPixelFormat));
if (!This->initialized || This->bits) return WINCODEC_ERR_WRONGSTATE;
for (i=0; formats[i].guid; i++)
{
if (memcmp(formats[i].guid, pPixelFormat, sizeof(GUID)) == 0)
break;
}
if (!formats[i].guid) i = 0;
This->format = &formats[i];
memcpy(pPixelFormat, This->format->guid, sizeof(GUID));
return S_OK;
} }
static HRESULT WINAPI BmpFrameEncode_SetColorContexts(IWICBitmapFrameEncode *iface, static HRESULT WINAPI BmpFrameEncode_SetColorContexts(IWICBitmapFrameEncode *iface,
@ -339,6 +371,7 @@ static HRESULT WINAPI BmpEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
encode->width = 0; encode->width = 0;
encode->height = 0; encode->height = 0;
encode->bits = NULL; encode->bits = NULL;
encode->format = NULL;
*ppIFrameEncode = (IWICBitmapFrameEncode*)encode; *ppIFrameEncode = (IWICBitmapFrameEncode*)encode;
This->frame = (IWICBitmapFrameEncode*)encode; This->frame = (IWICBitmapFrameEncode*)encode;