Nikolay Sivov : wincodecs: Fix scaler return pixel format for uninitialized case.
Module: wine Branch: master Commit: 85d6be3e9ee358ae99ac5328f9f400d1a8573579 URL: https://source.winehq.org/git/wine.git/?a=commit;h=85d6be3e9ee358ae99ac5328f... Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Fri Nov 9 14:26:46 2018 +0300 wincodecs: Fix scaler return pixel format for uninitialized case. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Vincent Povirk <vincent(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/windowscodecs/scaler.c | 5 ++++- dlls/windowscodecs/tests/bitmap.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/dlls/windowscodecs/scaler.c b/dlls/windowscodecs/scaler.c index b02f192..564b4ad 100644 --- a/dlls/windowscodecs/scaler.c +++ b/dlls/windowscodecs/scaler.c @@ -130,7 +130,10 @@ static HRESULT WINAPI BitmapScaler_GetPixelFormat(IWICBitmapScaler *iface, return E_INVALIDARG; if (!This->source) - return WINCODEC_ERR_WRONGSTATE; + { + memcpy(pPixelFormat, &GUID_WICPixelFormatDontCare, sizeof(*pPixelFormat)); + return S_OK; + } return IWICBitmapSource_GetPixelFormat(This->source, pPixelFormat); } diff --git a/dlls/windowscodecs/tests/bitmap.c b/dlls/windowscodecs/tests/bitmap.c index e4cb863..4865332 100644 --- a/dlls/windowscodecs/tests/bitmap.c +++ b/dlls/windowscodecs/tests/bitmap.c @@ -1082,6 +1082,7 @@ static void test_WICCreateBitmapFromSectionEx(void) static void test_bitmap_scaler(void) { + WICPixelFormatGUID pixel_format; IWICBitmapScaler *scaler; IWICBitmap *bitmap; UINT width, height; @@ -1112,6 +1113,15 @@ static void test_bitmap_scaler(void) hr = IWICBitmapScaler_GetSize(scaler, &width, NULL); ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + hr = IWICBitmapScaler_GetPixelFormat(scaler, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + memset(&pixel_format, 0, sizeof(pixel_format)); + hr = IWICBitmapScaler_GetPixelFormat(scaler, &pixel_format); + ok(hr == S_OK, "Failed to get pixel format, hr %#x.\n", hr); + ok(IsEqualGUID(&pixel_format, &GUID_WICPixelFormatDontCare), "Unexpected pixel format %s.\n", + wine_dbgstr_guid(&pixel_format)); + width = 123; height = 321; hr = IWICBitmapScaler_GetSize(scaler, &width, &height); @@ -1170,6 +1180,15 @@ static void test_bitmap_scaler(void) hr = IWICBitmapScaler_GetSize(scaler, NULL, NULL); ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + hr = IWICBitmapScaler_GetPixelFormat(scaler, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + memset(&pixel_format, 0, sizeof(pixel_format)); + hr = IWICBitmapScaler_GetPixelFormat(scaler, &pixel_format); + ok(hr == S_OK, "Failed to get pixel format, hr %#x.\n", hr); + ok(IsEqualGUID(&pixel_format, &GUID_WICPixelFormat24bppBGR), "Unexpected pixel format %s.\n", + wine_dbgstr_guid(&pixel_format)); + IWICBitmapScaler_Release(scaler); IWICBitmap_Release(bitmap);
participants (1)
-
Alexandre Julliard