windowscodecs: Correctly set output frame size for WriteSource().

Signed-off-by: Ziqing Hui <zhui@codeweavers.com>
Signed-off-by: Esme Povirk <esme@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ziqing Hui 2020-09-09 14:14:31 +08:00 committed by Alexandre Julliard
parent 0ceb07b75b
commit e8a45561c8
2 changed files with 23 additions and 4 deletions

View file

@ -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)
{

View file

@ -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);