Vincent Povirk : windowscodecs: Support InterlaceOption in PNG encoder.
Alexandre Julliard
julliard at winehq.org
Mon Jun 16 12:37:50 CDT 2014
Module: wine
Branch: master
Commit: 3ccaad8b41fe9514b95aa7610a1b33bb745b3c7d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=3ccaad8b41fe9514b95aa7610a1b33bb745b3c7d
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Wed May 28 15:04:00 2014 -0500
windowscodecs: Support InterlaceOption in PNG encoder.
---
dlls/windowscodecs/pngformat.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
index bd5cd3d..6950c07 100644
--- a/dlls/windowscodecs/pngformat.c
+++ b/dlls/windowscodecs/pngformat.c
@@ -41,6 +41,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
+static const WCHAR wszPngInterlaceOption[] = {'I','n','t','e','r','l','a','c','e','O','p','t','i','o','n',0};
+
static HRESULT read_png_chunk(IStream *stream, BYTE *type, BYTE **data, ULONG *data_size)
{
BYTE header[8];
@@ -1060,6 +1062,7 @@ typedef struct PngEncoder {
BOOL frame_committed;
BOOL committed;
CRITICAL_SECTION lock;
+ BOOL interlace;
} PngEncoder;
static inline PngEncoder *impl_from_IWICBitmapEncoder(IWICBitmapEncoder *iface)
@@ -1111,8 +1114,32 @@ static HRESULT WINAPI PngFrameEncode_Initialize(IWICBitmapFrameEncode *iface,
IPropertyBag2 *pIEncoderOptions)
{
PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface);
+ BOOL interlace;
+ PROPBAG2 opts[1]= {{0}};
+ VARIANT opt_values[1];
+ HRESULT opt_hres[1];
+ HRESULT hr;
+
TRACE("(%p,%p)\n", iface, pIEncoderOptions);
+ opts[0].pstrName = (LPOLESTR)wszPngInterlaceOption;
+ opts[0].vt = VT_BOOL;
+
+ if (pIEncoderOptions)
+ {
+ hr = IPropertyBag2_Read(pIEncoderOptions, 1, opts, NULL, opt_values, opt_hres);
+
+ if (FAILED(hr))
+ return hr;
+ }
+ else
+ memset(opt_values, sizeof(opt_values), 0);
+
+ if (V_VT(&opt_values[0]) == VT_EMPTY)
+ interlace = FALSE;
+ else
+ interlace = (V_BOOL(&opt_values[0]) != 0);
+
EnterCriticalSection(&This->lock);
if (This->frame_initialized)
@@ -1121,6 +1148,8 @@ static HRESULT WINAPI PngFrameEncode_Initialize(IWICBitmapFrameEncode *iface,
return WINCODEC_ERR_WRONGSTATE;
}
+ This->interlace = interlace;
+
This->frame_initialized = TRUE;
LeaveCriticalSection(&This->lock);
@@ -1259,7 +1288,8 @@ static HRESULT WINAPI PngFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
if (!This->info_written)
{
ppng_set_IHDR(This->png_ptr, This->info_ptr, This->width, This->height,
- This->format->bit_depth, This->format->color_type, PNG_INTERLACE_NONE,
+ This->format->bit_depth, This->format->color_type,
+ This->interlace ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
if (This->xres != 0.0 && This->yres != 0.0)
@@ -1548,6 +1578,8 @@ static HRESULT WINAPI PngEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
{
PngEncoder *This = impl_from_IWICBitmapEncoder(iface);
HRESULT hr;
+ PROPBAG2 opts[1]= {{0}};
+
TRACE("(%p,%p,%p)\n", iface, ppIFrameEncode, ppIEncoderOptions);
EnterCriticalSection(&This->lock);
@@ -1564,7 +1596,11 @@ static HRESULT WINAPI PngEncoder_CreateNewFrame(IWICBitmapEncoder *iface,
return WINCODEC_ERR_NOTINITIALIZED;
}
- hr = CreatePropertyBag2(NULL, 0, ppIEncoderOptions);
+ opts[0].pstrName = (LPOLESTR)wszPngInterlaceOption;
+ opts[0].vt = VT_BOOL;
+ opts[0].dwType = PROPBAG2_TYPE_DATA;
+
+ hr = CreatePropertyBag2(opts, 1, ppIEncoderOptions);
if (FAILED(hr))
{
LeaveCriticalSection(&This->lock);
More information about the wine-cvs
mailing list