[PATCH 5/5] wincodecs: Fix return value for scaler GetResolution().

Nikolay Sivov nsivov at codeweavers.com
Fri Nov 9 05:26:47 CST 2018


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 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 564b4ada43..3789831a97 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 486533247d..2b5c373bf9 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);
-- 
2.19.1




More information about the wine-devel mailing list