wincodecs: Fix return value for scaler GetResolution().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2018-11-09 14:26:47 +03:00 committed by Alexandre Julliard
parent 85d6be3e9e
commit f92cfb31d2
2 changed files with 38 additions and 3 deletions

View File

@ -144,12 +144,12 @@ static HRESULT WINAPI BitmapScaler_GetResolution(IWICBitmapScaler *iface,
BitmapScaler *This = impl_from_IWICBitmapScaler(iface);
TRACE("(%p,%p,%p)\n", iface, pDpiX, pDpiY);
if (!This->source)
return WINCODEC_ERR_NOTINITIALIZED;
if (!pDpiX || !pDpiY)
return E_INVALIDARG;
if (!This->source)
return WINCODEC_ERR_WRONGSTATE;
return IWICBitmapSource_GetResolution(This->source, pDpiX, pDpiY);
}

View File

@ -1084,6 +1084,7 @@ static void test_bitmap_scaler(void)
{
WICPixelFormatGUID pixel_format;
IWICBitmapScaler *scaler;
double res_x, res_y;
IWICBitmap *bitmap;
UINT width, height;
HRESULT hr;
@ -1096,6 +1097,10 @@ static void test_bitmap_scaler(void)
ok(width == 4, "Unexpected width %u.\n", width);
ok(height == 2, "Unexpected height %u.\n", height);
hr = IWICBitmap_GetResolution(bitmap, &res_x, &res_y);
ok(hr == S_OK, "Failed to get bitmap resolution, hr %#x.\n", hr);
ok(res_x == 0.0 && res_y == 0.0, "Unexpected resolution %f x %f.\n", res_x, res_y);
hr = IWICImagingFactory_CreateBitmapScaler(factory, &scaler);
ok(hr == S_OK, "Failed to create bitmap scaler, hr %#x.\n", hr);
@ -1113,6 +1118,20 @@ static void test_bitmap_scaler(void)
hr = IWICBitmapScaler_GetSize(scaler, &width, NULL);
ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
hr = IWICBitmapScaler_GetResolution(scaler, NULL, NULL);
ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
res_x = 0.1;
hr = IWICBitmapScaler_GetResolution(scaler, &res_x, NULL);
ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
ok(res_x == 0.1, "Unexpected resolution %f.\n", res_x);
hr = IWICBitmapScaler_GetResolution(scaler, NULL, &res_y);
ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
hr = IWICBitmapScaler_GetResolution(scaler, &res_x, &res_y);
ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
hr = IWICBitmapScaler_GetPixelFormat(scaler, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
@ -1189,6 +1208,22 @@ static void test_bitmap_scaler(void)
ok(IsEqualGUID(&pixel_format, &GUID_WICPixelFormat24bppBGR), "Unexpected pixel format %s.\n",
wine_dbgstr_guid(&pixel_format));
hr = IWICBitmapScaler_GetResolution(scaler, NULL, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
res_x = 0.1;
hr = IWICBitmapScaler_GetResolution(scaler, &res_x, NULL);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
ok(res_x == 0.1, "Unexpected resolution %f.\n", res_x);
hr = IWICBitmapScaler_GetResolution(scaler, NULL, &res_y);
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
res_x = res_y = 1.0;
hr = IWICBitmapScaler_GetResolution(scaler, &res_x, &res_y);
ok(hr == S_OK, "Failed to get scaler resolution, hr %#x.\n", hr);
ok(res_x == 0.0 && res_y == 0.0, "Unexpected resolution %f x %f.\n", res_x, res_y);
IWICBitmapScaler_Release(scaler);
IWICBitmap_Release(bitmap);