Nikolay Sivov : wincodecs: Fix return value for scaler GetResolution().
Alexandre Julliard
julliard at winehq.org
Tue Nov 13 15:01:58 CST 2018
Module: wine
Branch: master
Commit: f92cfb31d23fa21b5616616b66955df808d13144
URL: https://source.winehq.org/git/wine.git/?a=commit;h=f92cfb31d23fa21b5616616b66955df808d13144
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Fri Nov 9 14:26:47 2018 +0300
wincodecs: Fix return value for scaler GetResolution().
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/windowscodecs/scaler.c | 6 +++---
dlls/windowscodecs/tests/bitmap.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/dlls/windowscodecs/scaler.c b/dlls/windowscodecs/scaler.c
index 564b4ad..3789831 100644
--- a/dlls/windowscodecs/scaler.c
+++ b/dlls/windowscodecs/scaler.c
@@ -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);
}
diff --git a/dlls/windowscodecs/tests/bitmap.c b/dlls/windowscodecs/tests/bitmap.c
index 4865332..2b5c373 100644
--- a/dlls/windowscodecs/tests/bitmap.c
+++ b/dlls/windowscodecs/tests/bitmap.c
@@ -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);
More information about the wine-cvs
mailing list