The png_set_swap() explicitly checks for 16 bit depth, and bit_depth field is set by png_write_info().
From: Nikolay Sivov nsivov@codeweavers.com
The png_set_swap() explicitly checks for 16 bit depth, and bit_depth field is set by png_write_info(). --- dlls/windowscodecs/libpng.c | 7 +++---- dlls/windowscodecs/tests/converter.c | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/dlls/windowscodecs/libpng.c b/dlls/windowscodecs/libpng.c index e4ef74f185b..e2cf6c3d4c0 100644 --- a/dlls/windowscodecs/libpng.c +++ b/dlls/windowscodecs/libpng.c @@ -645,10 +645,6 @@ static HRESULT CDECL png_encoder_create_frame(struct encoder *encoder, const str return E_OUTOFMEMORY; }
- /* Tell PNG we need to byte swap if writing a >8-bpp image */ - if (This->format->bit_depth > 8) - png_set_swap(This->png_ptr); - png_set_IHDR(This->png_ptr, This->info_ptr, encoder_frame->width, encoder_frame->height, This->format->bit_depth, This->format->color_type, encoder_frame->interlace ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE, @@ -689,6 +685,9 @@ static HRESULT CDECL png_encoder_create_frame(struct encoder *encoder, const str
png_write_info(This->png_ptr, This->info_ptr);
+ if (This->format->bit_depth > 8) + png_set_swap(This->png_ptr); + if (This->format->remove_filler) png_set_filler(This->png_ptr, 0, PNG_FILLER_AFTER);
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 3e12326f68e..df7ba816637 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -2333,9 +2333,9 @@ if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in { test_encoder(&testdata_32bppBGR, &CLSID_WICPngEncoder, &testdata_24bppBGR, &CLSID_WICPngDecoder, "PNG encoder 32bppBGR"); +} test_encoder(&testdata_64bppRGBA, &CLSID_WICPngEncoder, &testdata_64bppRGBA, &CLSID_WICPngDecoder, "PNG encoder 64bppRGBA"); -}
test_encoder(&testdata_BlackWhite, &CLSID_WICBmpEncoder, &testdata_1bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder BlackWhite");
This merge request was approved by Esme Povirk.