This speeds up the encoding process, sometimes at the cost of increased PNG file sizes. PNGs created using gdiplus on Windows 10 have filters disabled, too, according to pngcheck.
The application "ZusiDisplay" encodes finished frames in PNG format and sends them through a named pipe for "Zusi 3" to use as an in-game texture, so performance matters for that use case to improve "embedded display" FPS.
Signed-off-by: Florian Will florian.will@gmail.com --- I noticed that a 1840x3052 mostly text-based website screenshot I used for testing actually shrunk from 402kB to 349kB after disabling filters. Maybe this is common for basic "draw some lines and shapes in gdiplus" images? On win10, the same screenshot is 371kB because the zlib compression level appears to be "fast" instead of "default", and win10 gdiplus stores an alpha channel, while wine stores the fully opaque screenshot loaded from a BMP file as 24bit RGB without alpha (all according to pngcheck). --- dlls/gdiplus/Makefile.in | 2 +- dlls/gdiplus/image.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/Makefile.in b/dlls/gdiplus/Makefile.in index ac12bd1c613..c87ec5ba827 100644 --- a/dlls/gdiplus/Makefile.in +++ b/dlls/gdiplus/Makefile.in @@ -1,6 +1,6 @@ MODULE = gdiplus.dll IMPORTLIB = gdiplus -IMPORTS = uuid shlwapi ole32 user32 gdi32 +IMPORTS = uuid shlwapi ole32 oleaut32 user32 gdi32 DELAYIMPORTS = windowscodecs
C_SRCS = \ diff --git a/dlls/gdiplus/image.c b/dlls/gdiplus/image.c index 518a9bf8689..56eb62392ec 100644 --- a/dlls/gdiplus/image.c +++ b/dlls/gdiplus/image.c @@ -4544,6 +4544,7 @@ static GpStatus encode_frame_wic(IWICBitmapEncoder *encoder, GpImage *image) GpBitmap *bitmap; IWICBitmapFrameEncode *frameencode; IPropertyBag2 *encoderoptions; + GUID container_format; HRESULT hr; UINT width, height; PixelFormat gdipformat=0; @@ -4570,7 +4571,20 @@ static GpStatus encode_frame_wic(IWICBitmapEncoder *encoder, GpImage *image)
if (SUCCEEDED(hr)) /* created frame */ { - hr = IWICBitmapFrameEncode_Initialize(frameencode, encoderoptions); + hr = IWICBitmapEncoder_GetContainerFormat(encoder, &container_format); + if (SUCCEEDED(hr) && IsEqualGUID(&container_format, &GUID_ContainerFormatPng)) + { + /* disable PNG filters for faster encoding */ + PROPBAG2 filter_option = { .pstrName = (LPOLESTR) L"FilterOption" }; + VARIANT filter_value; + VariantInit(&filter_value); + V_VT(&filter_value) = VT_UI1; + V_UI1(&filter_value) = WICPngFilterNone; + hr = IPropertyBag2_Write(encoderoptions, 1, &filter_option, &filter_value); + } + + if (SUCCEEDED(hr)) + hr = IWICBitmapFrameEncode_Initialize(frameencode, encoderoptions);
if (SUCCEEDED(hr)) hr = IWICBitmapFrameEncode_SetSize(frameencode, width, height);
There is a Testbot failure for "32 bit Chinese:China" for my patch, but it seems unrelated to my change? The failing test is in font.c, line 888:
status = GdipCreateFontFamilyFromName(L"MS Shell Dlg", NULL, &family); expect(Ok, status);
where status is 14, FontFamilyNotFound. Hopefully this is not some hidden issue with my code, like corrupting some memory?
Am Montag, 24. Jänner 2022, 14:06:12 EAT schrieb Florian Will:
There is a Testbot failure for "32 bit Chinese:China" for my patch, but it seems unrelated to my change? The failing test is in font.c, line 888:
status = GdipCreateFontFamilyFromName(L"MS Shell Dlg", NULL, &family); expect(Ok, status);
This is a preexisting failure, see e.g. http://test.winehq.org/data/ c09a5da157585d171ad896e9862db00d505e4363/linux_newtb-debian11-win32-zh-CN/ gdiplus:font.html . The patch is marked as "success" in source.winehq.org/ patches. If there are new failures, or you are unlucky enough to stumble across a preexisting random failure, the testbot will send a mail to the mailing list.
I can't comment on the merits of your patch though...
Signed-off-by: Esme Povirk esme@codeweavers.com
Native probably sets it based on EncoderParameters, but I think this is good enough for now.
Thank you, Stefan and Esme! (And sorry about the other mail, Esme - I thought gmail would reply to all by default)
Native probably sets it based on EncoderParameters, but I think this is good enough for now.
I used the "Determining the Parameters Supported by an Encoder" example code to query image/png encoder parameters on win10, and if I understand that output correctly, the PNG encoder only supports the "EncoderImageItems" parameter (for image metadata). Or maybe the "EncoderQuality" parameter is supported implicitly without being listed in GetEncoderParameterList? I haven't tried it, but Google found a forum thread where people basically complain that gdiplus can't use prefiltering when encoding PNG files.