Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/scaler.c | 3 + dlls/windowscodecs/tests/bitmap.c | 101 ++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+)
diff --git a/dlls/windowscodecs/scaler.c b/dlls/windowscodecs/scaler.c index ebcc790f75..f576ad51fd 100644 --- a/dlls/windowscodecs/scaler.c +++ b/dlls/windowscodecs/scaler.c @@ -309,6 +309,9 @@ static HRESULT WINAPI BitmapScaler_Initialize(IWICBitmapScaler *iface,
TRACE("(%p,%p,%u,%u,%u)\n", iface, pISource, uiWidth, uiHeight, mode);
+ if (!pISource || !uiWidth || !uiHeight) + return E_INVALIDARG; + EnterCriticalSection(&This->lock);
if (This->source) diff --git a/dlls/windowscodecs/tests/bitmap.c b/dlls/windowscodecs/tests/bitmap.c index 5c225d2abb..34da3b2083 100644 --- a/dlls/windowscodecs/tests/bitmap.c +++ b/dlls/windowscodecs/tests/bitmap.c @@ -1080,6 +1080,106 @@ static void test_WICCreateBitmapFromSectionEx(void) CloseHandle(hsection); }
+static void test_bitmap_scaler(void) +{ + IWICBitmapScaler *scaler; + IWICBitmap *bitmap; + UINT width, height; + HRESULT hr; + + hr = IWICImagingFactory_CreateBitmap(factory, 4, 2, &GUID_WICPixelFormat24bppBGR, WICBitmapCacheOnLoad, &bitmap); + ok(hr == S_OK, "Failed to create a bitmap, hr %#x.\n", hr); + + hr = IWICBitmap_GetSize(bitmap, &width, &height); + ok(hr == S_OK, "Failed to get bitmap size, hr %#x.\n", hr); + ok(width == 4, "Unexpected width %u.\n", width); + ok(height == 2, "Unexpected height %u.\n", height); + + hr = IWICImagingFactory_CreateBitmapScaler(factory, &scaler); + ok(hr == S_OK, "Failed to create bitmap scaler, hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, NULL, 0, 0, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 0, 0, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, NULL, &height); +todo_wine + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, &width, NULL); +todo_wine + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + width = 123; + height = 321; + hr = IWICBitmapScaler_GetSize(scaler, &width, &height); +todo_wine + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + ok(width == 123, "Unexpected width %u.\n", width); + ok(height == 321, "Unexpected height %u.\n", height); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 4, 0, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, &width, &height); +todo_wine + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 0, 2, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, &width, &height); +todo_wine + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, NULL, 8, 4, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Failed to initialize bitmap scaler, hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 8, 4, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == S_OK, "Failed to initialize bitmap scaler, hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 0, 4, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 8, 0, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, NULL, 8, 4, WICBitmapInterpolationModeNearestNeighbor); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 8, 4, + WICBitmapInterpolationModeNearestNeighbor); + ok(hr == WINCODEC_ERR_WRONGSTATE, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, &width, &height); + ok(hr == S_OK, "Failed to get scaler size, hr %#x.\n", hr); + ok(width == 8, "Unexpected width %u.\n", width); + ok(height == 4, "Unexpected height %u.\n", height); + + hr = IWICBitmapScaler_GetSize(scaler, NULL, &height); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, &width, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IWICBitmapScaler_GetSize(scaler, NULL, NULL); + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + IWICBitmapScaler_Release(scaler); + + IWICBitmap_Release(bitmap); +} + START_TEST(bitmap) { HRESULT hr; @@ -1096,6 +1196,7 @@ START_TEST(bitmap) test_CreateBitmapFromHICON(); test_CreateBitmapFromHBITMAP(); test_clipper(); + test_bitmap_scaler();
IWICImagingFactory_Release(factory);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/scaler.c | 6 +++--- dlls/windowscodecs/tests/bitmap.c | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/dlls/windowscodecs/scaler.c b/dlls/windowscodecs/scaler.c index f576ad51fd..46f1dbfb81 100644 --- a/dlls/windowscodecs/scaler.c +++ b/dlls/windowscodecs/scaler.c @@ -108,12 +108,12 @@ static HRESULT WINAPI BitmapScaler_GetSize(IWICBitmapScaler *iface, BitmapScaler *This = impl_from_IWICBitmapScaler(iface); TRACE("(%p,%p,%p)\n", iface, puiWidth, puiHeight);
+ if (!This->source) + return WINCODEC_ERR_NOTINITIALIZED; + if (!puiWidth || !puiHeight) return E_INVALIDARG;
- if (!This->source) - return WINCODEC_ERR_WRONGSTATE; - *puiWidth = This->width; *puiHeight = This->height;
diff --git a/dlls/windowscodecs/tests/bitmap.c b/dlls/windowscodecs/tests/bitmap.c index 34da3b2083..e4cb8637f4 100644 --- a/dlls/windowscodecs/tests/bitmap.c +++ b/dlls/windowscodecs/tests/bitmap.c @@ -1107,17 +1107,14 @@ static void test_bitmap_scaler(void) ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IWICBitmapScaler_GetSize(scaler, NULL, &height); -todo_wine ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
hr = IWICBitmapScaler_GetSize(scaler, &width, NULL); -todo_wine ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
width = 123; height = 321; hr = IWICBitmapScaler_GetSize(scaler, &width, &height); -todo_wine ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr); ok(width == 123, "Unexpected width %u.\n", width); ok(height == 321, "Unexpected height %u.\n", height); @@ -1127,7 +1124,6 @@ todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IWICBitmapScaler_GetSize(scaler, &width, &height); -todo_wine ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
hr = IWICBitmapScaler_Initialize(scaler, (IWICBitmapSource *)bitmap, 0, 2, @@ -1135,7 +1131,6 @@ todo_wine ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
hr = IWICBitmapScaler_GetSize(scaler, &width, &height); -todo_wine ok(hr == WINCODEC_ERR_NOTINITIALIZED, "Unexpected hr %#x.\n", hr);
hr = IWICBitmapScaler_Initialize(scaler, NULL, 8, 4,
Signed-off-by: Vincent Povirk vincent@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/bitmap.c | 4 ++-- dlls/windowscodecs/bmpdecode.c | 2 +- dlls/windowscodecs/bmpencode.c | 2 +- dlls/windowscodecs/clipper.c | 4 ++-- dlls/windowscodecs/colortransform.c | 2 +- dlls/windowscodecs/converter.c | 2 +- dlls/windowscodecs/fliprotate.c | 2 +- dlls/windowscodecs/gifformat.c | 2 +- dlls/windowscodecs/icnsformat.c | 2 +- dlls/windowscodecs/icoformat.c | 2 +- dlls/windowscodecs/jpegformat.c | 4 ++-- dlls/windowscodecs/pngformat.c | 4 ++-- dlls/windowscodecs/scaler.c | 2 +- dlls/windowscodecs/tgaformat.c | 2 +- dlls/windowscodecs/tiffformat.c | 4 ++-- dlls/windowscodecs/wincodecs_private.h | 8 ++++++++ 16 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/dlls/windowscodecs/bitmap.c b/dlls/windowscodecs/bitmap.c index 116fd3134a..e8fe822e84 100644 --- a/dlls/windowscodecs/bitmap.c +++ b/dlls/windowscodecs/bitmap.c @@ -358,7 +358,7 @@ static HRESULT WINAPI BitmapImpl_CopyPixels(IWICBitmap *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { BitmapImpl *This = impl_from_IWICBitmap(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
return copy_pixels(This->bpp, This->data, This->width, This->height, This->stride, prc, cbStride, cbBufferSize, pbBuffer); @@ -371,7 +371,7 @@ static HRESULT WINAPI BitmapImpl_Lock(IWICBitmap *iface, const WICRect *prcLock, BitmapLockImpl *result; WICRect rc;
- TRACE("(%p,%p,%x,%p)\n", iface, prcLock, flags, ppILock); + TRACE("(%p,%s,%x,%p)\n", iface, debug_wic_rect(prcLock), flags, ppILock);
if (!(flags & (WICBitmapLockRead|WICBitmapLockWrite)) || !ppILock) return E_INVALIDARG; diff --git a/dlls/windowscodecs/bmpdecode.c b/dlls/windowscodecs/bmpdecode.c index 4109bad4b3..6254b150ca 100644 --- a/dlls/windowscodecs/bmpdecode.c +++ b/dlls/windowscodecs/bmpdecode.c @@ -321,7 +321,7 @@ static HRESULT WINAPI BmpFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, BmpDecoder *This = impl_from_IWICBitmapFrameDecode(iface); HRESULT hr=S_OK; UINT width, height; - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
EnterCriticalSection(&This->lock); if (!This->imagedata) diff --git a/dlls/windowscodecs/bmpencode.c b/dlls/windowscodecs/bmpencode.c index aa65675a98..fb04f9ddb2 100644 --- a/dlls/windowscodecs/bmpencode.c +++ b/dlls/windowscodecs/bmpencode.c @@ -284,7 +284,7 @@ static HRESULT WINAPI BmpFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, { BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr; - TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); + TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
if (!This->initialized) return WINCODEC_ERR_WRONGSTATE; diff --git a/dlls/windowscodecs/clipper.c b/dlls/windowscodecs/clipper.c index 94127f3df1..02e0d967f5 100644 --- a/dlls/windowscodecs/clipper.c +++ b/dlls/windowscodecs/clipper.c @@ -167,7 +167,7 @@ static HRESULT WINAPI BitmapClipper_CopyPixels(IWICBitmapClipper *iface, BitmapClipper *This = impl_from_IWICBitmapClipper(iface); WICRect rect;
- TRACE("(%p,%p,%u,%u,%p)\n", iface, rc, stride, buffer_size, buffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(rc), stride, buffer_size, buffer);
if (!This->source) return WINCODEC_ERR_WRONGSTATE; @@ -199,7 +199,7 @@ static HRESULT WINAPI BitmapClipper_Initialize(IWICBitmapClipper *iface, UINT width, height; HRESULT hr = S_OK;
- TRACE("(%p,%p,%p)\n", iface, source, rc); + TRACE("(%p,%p,%s)\n", iface, source, debug_wic_rect(rc));
EnterCriticalSection(&This->lock);
diff --git a/dlls/windowscodecs/colortransform.c b/dlls/windowscodecs/colortransform.c index 5b1c7e8b70..af66c67443 100644 --- a/dlls/windowscodecs/colortransform.c +++ b/dlls/windowscodecs/colortransform.c @@ -133,7 +133,7 @@ static HRESULT WINAPI ColorTransform_CopyPixels(IWICColorTransform *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { ColorTransform *This = impl_from_IWICColorTransform(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
return IWICBitmapSource_CopyPixels(This->dst, prc, cbStride, cbBufferSize, pbBuffer); } diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index 42ba260223..6e7bb8e781 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -1360,7 +1360,7 @@ static HRESULT WINAPI FormatConverter_CopyPixels(IWICFormatConverter *iface, FormatConverter *This = impl_from_IWICFormatConverter(iface); WICRect rc; HRESULT hr; - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
if (This->source) { diff --git a/dlls/windowscodecs/fliprotate.c b/dlls/windowscodecs/fliprotate.c index 72d1e8a287..46402237ee 100644 --- a/dlls/windowscodecs/fliprotate.c +++ b/dlls/windowscodecs/fliprotate.c @@ -161,7 +161,7 @@ static HRESULT WINAPI FlipRotator_CopyPixels(IWICBitmapFlipRotator *iface, WICRect rc; WICRect rect;
- TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
if (!This->source) return WINCODEC_ERR_WRONGSTATE;
diff --git a/dlls/windowscodecs/gifformat.c b/dlls/windowscodecs/gifformat.c index 0eb1d804ec..df202ba45a 100644 --- a/dlls/windowscodecs/gifformat.c +++ b/dlls/windowscodecs/gifformat.c @@ -795,7 +795,7 @@ static HRESULT WINAPI GifFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { GifFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
if (This->frame->ImageDesc.Interlace) { diff --git a/dlls/windowscodecs/icnsformat.c b/dlls/windowscodecs/icnsformat.c index aa9640417f..02e8ee97e6 100644 --- a/dlls/windowscodecs/icnsformat.c +++ b/dlls/windowscodecs/icnsformat.c @@ -390,7 +390,7 @@ static HRESULT WINAPI IcnsFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, IcnsFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr;
- TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); + TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
if (!This->initialized) return WINCODEC_ERR_WRONGSTATE; diff --git a/dlls/windowscodecs/icoformat.c b/dlls/windowscodecs/icoformat.c index dc08fd5576..d2a6196cd0 100644 --- a/dlls/windowscodecs/icoformat.c +++ b/dlls/windowscodecs/icoformat.c @@ -176,7 +176,7 @@ static HRESULT WINAPI IcoFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { IcoFrameDecode *This = impl_from_IWICBitmapFrameDecode(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
return copy_pixels(32, This->bits, This->width, This->height, This->width * 4, prc, cbStride, cbBufferSize, pbBuffer); diff --git a/dlls/windowscodecs/jpegformat.c b/dlls/windowscodecs/jpegformat.c index d24af6dc9e..bb3d418667 100644 --- a/dlls/windowscodecs/jpegformat.c +++ b/dlls/windowscodecs/jpegformat.c @@ -592,7 +592,7 @@ static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, UINT max_row_needed; jmp_buf jmpbuf; WICRect rect; - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
if (!prc) { @@ -1204,7 +1204,7 @@ static HRESULT WINAPI JpegEncoder_Frame_WriteSource(IWICBitmapFrameEncode *iface { JpegEncoder *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr; - TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); + TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
if (!This->frame_initialized) return WINCODEC_ERR_WRONGSTATE; diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c index 3f0ab39bd2..3ac7dee896 100644 --- a/dlls/windowscodecs/pngformat.c +++ b/dlls/windowscodecs/pngformat.c @@ -1094,7 +1094,7 @@ static HRESULT WINAPI PngDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) { PngDecoder *This = impl_from_IWICBitmapFrameDecode(iface); - TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
return copy_pixels(This->bpp, This->image_bits, This->width, This->height, This->stride, @@ -1745,7 +1745,7 @@ static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, { PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr; - TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); + TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
if (!This->frame_initialized) return WINCODEC_ERR_WRONGSTATE; diff --git a/dlls/windowscodecs/scaler.c b/dlls/windowscodecs/scaler.c index 46f1dbfb81..b02f19253a 100644 --- a/dlls/windowscodecs/scaler.c +++ b/dlls/windowscodecs/scaler.c @@ -204,7 +204,7 @@ static HRESULT WINAPI BitmapScaler_CopyPixels(IWICBitmapScaler *iface, ULONG buffer_size; UINT y;
- TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
EnterCriticalSection(&This->lock);
diff --git a/dlls/windowscodecs/tgaformat.c b/dlls/windowscodecs/tgaformat.c index b3d9aeae26..72c9baa016 100644 --- a/dlls/windowscodecs/tgaformat.c +++ b/dlls/windowscodecs/tgaformat.c @@ -890,7 +890,7 @@ static HRESULT WINAPI TgaDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, TgaDecoder *This = impl_from_IWICBitmapFrameDecode(iface); HRESULT hr;
- TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
hr = TgaDecoder_ReadImage(This);
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c index 966ab3eb4b..5585718a9e 100644 --- a/dlls/windowscodecs/tiffformat.c +++ b/dlls/windowscodecs/tiffformat.c @@ -1070,7 +1070,7 @@ static HRESULT WINAPI TiffFrameDecode_CopyPixels(IWICBitmapFrameDecode *iface, UINT bytesperrow; WICRect rect;
- TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); + TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer);
if (!prc) { @@ -1726,7 +1726,7 @@ static HRESULT WINAPI TiffFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, TiffFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface); HRESULT hr;
- TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); + TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc));
if (!This->initialized) return WINCODEC_ERR_WRONGSTATE; diff --git a/dlls/windowscodecs/wincodecs_private.h b/dlls/windowscodecs/wincodecs_private.h index f7950c4105..2221cc7dce 100644 --- a/dlls/windowscodecs/wincodecs_private.h +++ b/dlls/windowscodecs/wincodecs_private.h @@ -21,6 +21,8 @@
#include "wincodec.h" #include "wincodecsdk.h" + +#include "wine/debug.h" #include "wine/unicode.h"
DEFINE_GUID(CLSID_WineTgaDecoder, 0xb11fc79a,0x67cc,0x43e6,0xa9,0xce,0xe3,0xd5,0x49,0x45,0xd3,0x04); @@ -178,4 +180,10 @@ static inline WCHAR *heap_strdupW(const WCHAR *src) return dst; }
+static inline const char *debug_wic_rect(const WICRect *rect) +{ + if (!rect) return "(null)"; + return wine_dbg_sprintf("(%u,%u)-(%u,%u)", rect->X, rect->Y, rect->Width, rect->Height); +} + #endif /* WINCODECS_PRIVATE_H */
Signed-off-by: Vincent Povirk vincent@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- 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 b02f19253a..564b4ada43 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 e4cb8637f4..486533247d 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);
Signed-off-by: Vincent Povirk vincent@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@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);
Signed-off-by: Vincent Povirk vincent@codeweavers.com