Ziqing Hui : windowscodecs: Correctly set output frame size for WriteSource().
Module: wine Branch: master Commit: e8a45561c8da94f0d626f30b77ba4b994b70a3f2 URL: https://source.winehq.org/git/wine.git/?a=commit;h=e8a45561c8da94f0d626f30b7... Author: Ziqing Hui <zhui(a)codeweavers.com> Date: Wed Sep 9 14:14:31 2020 +0800 windowscodecs: Correctly set output frame size for WriteSource(). Signed-off-by: Ziqing Hui <zhui(a)codeweavers.com> Signed-off-by: Esme Povirk <esme(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/windowscodecs/main.c | 23 +++++++++++++++++++++-- dlls/windowscodecs/tests/converter.c | 4 ++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/dlls/windowscodecs/main.c b/dlls/windowscodecs/main.c index 94d6640782..7e03112a63 100644 --- a/dlls/windowscodecs/main.c +++ b/dlls/windowscodecs/main.c @@ -125,10 +125,29 @@ HRESULT configure_write_source(IWICBitmapFrameEncode *iface, const WICPixelFormatGUID *format, INT width, INT height, double xres, double yres) { + UINT src_width, src_height; HRESULT hr = S_OK; - if (width == 0 || height == 0) - return WINCODEC_ERR_WRONGSTATE; + if (width == 0 && height == 0) + { + if (prc) + { + if (prc->Width <= 0 || prc->Height <= 0) return E_INVALIDARG; + width = prc->Width; + height = prc->Height; + } + else + { + hr = IWICBitmapSource_GetSize(source, &src_width, &src_height); + if (FAILED(hr)) return hr; + if (src_width == 0 || src_height == 0) return E_INVALIDARG; + width = src_width; + height = src_height; + } + hr = IWICBitmapFrameEncode_SetSize(iface, (UINT)width, (UINT)height); + if (FAILED(hr)) return hr; + } + if (width == 0 || height == 0) return E_INVALIDARG; if (!format) { diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 852f677482..87f68207c6 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -1401,13 +1401,13 @@ static void test_multi_encoder_impl(const struct bitmap_data **srcs, const CLSID } hr = IWICBitmapFrameEncode_WriteSource(frameencode, &src_obj->IWICBitmapSource_iface, rc); - todo_wine_if(!set_size) { if (rc && (rc->Width <= 0 || rc->Height <= 0)) { /* WriteSource fails but WriteSource_Proxy succeeds. */ ok(hr == E_INVALIDARG, "WriteSource should fail, hr=%x (%s)\n", hr, name); hr = IWICBitmapFrameEncode_WriteSource_Proxy(frameencode, &src_obj->IWICBitmapSource_iface, rc); if (!set_size && rc->Width < 0) + todo_wine ok(hr == WINCODEC_ERR_SOURCERECTDOESNOTMATCHDIMENSIONS, "WriteSource_Proxy(%dx%d) got unexpected hr %x (%s)\n", rc->Width, rc->Height, hr, name); else @@ -1423,12 +1423,12 @@ static void test_multi_encoder_impl(const struct bitmap_data **srcs, const CLSID ok(hr == S_OK, "WriteSource(NULL) failed, hr=%x (%s)\n", hr, name); } - } if (SUCCEEDED(hr)) { hr = IWICBitmapFrameEncode_Commit(frameencode); if (!set_size && rc && rc->Height < 0) + todo_wine ok(hr == WINCODEC_ERR_UNEXPECTEDSIZE, "Commit got unexpected hr %x (%s)\n", hr, name); else ok(hr == S_OK, "Commit failed, hr=%x (%s)\n", hr, name);
participants (1)
-
Alexandre Julliard