From a901fa9dc39b02049db9cebdfbae03369f08d5db Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Mon, 11 Sep 2017 11:40:27 -0500 Subject: [PATCH] windowscodecs: Implement IWICBitmapFrameEncode::SetPalette in JPEG encoder. Signed-off-by: Vincent Povirk Signed-off-by: Alexandre Julliard --- dlls/windowscodecs/jpegformat.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/dlls/windowscodecs/jpegformat.c b/dlls/windowscodecs/jpegformat.c index 014620fa414..69d1187ba7c 100644 --- a/dlls/windowscodecs/jpegformat.c +++ b/dlls/windowscodecs/jpegformat.c @@ -868,6 +868,8 @@ typedef struct JpegEncoder { double xres, yres; const jpeg_compress_format *format; IStream *stream; + WICColor palette[256]; + UINT colors; CRITICAL_SECTION lock; BYTE dest_buffer[1024]; } JpegEncoder; @@ -1070,10 +1072,24 @@ static HRESULT WINAPI JpegEncoder_Frame_SetColorContexts(IWICBitmapFrameEncode * } static HRESULT WINAPI JpegEncoder_Frame_SetPalette(IWICBitmapFrameEncode *iface, - IWICPalette *pIPalette) + IWICPalette *palette) { - FIXME("(%p,%p): stub\n", iface, pIPalette); - return WINCODEC_ERR_UNSUPPORTEDOPERATION; + JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface); + HRESULT hr; + + TRACE("(%p,%p)\n", iface, palette); + + if (!palette) return E_INVALIDARG; + + EnterCriticalSection(&This->lock); + + if (This->frame_initialized) + hr = IWICPalette_GetColors(palette, 256, This->palette, &This->colors); + else + hr = WINCODEC_ERR_NOTINITIALIZED; + + LeaveCriticalSection(&This->lock); + return hr; } static HRESULT WINAPI JpegEncoder_Frame_SetThumbnail(IWICBitmapFrameEncode *iface, @@ -1543,6 +1559,7 @@ HRESULT JpegEncoder_CreateInstance(REFIID iid, void** ppv) This->xres = This->yres = 0.0; This->format = NULL; This->stream = NULL; + This->colors = 0; InitializeCriticalSection(&This->lock); This->lock.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JpegEncoder.lock");