Commit e8a45561 authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

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

parent 0ceb07b7
......@@ -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)
{
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment