From f92cfb31d23fa21b5616616b66955df808d13144 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 9 Nov 2018 14:26:47 +0300 Subject: [PATCH] wincodecs: Fix return value for scaler GetResolution(). Signed-off-by: Nikolay Sivov Signed-off-by: Vincent Povirk Signed-off-by: Alexandre Julliard --- 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 564b4ada436..3789831a975 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 486533247d8..2b5c373bf91 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);