Rebase against ae5e029d2227b3a8024f597591f76fe0f37d52e3.

This commit is contained in:
Zebediah Figura 2018-12-07 19:39:19 -06:00
parent 7a69c317fc
commit 4912f27424
10 changed files with 632 additions and 407 deletions

View File

@ -52,7 +52,7 @@ usage()
# Get the upstream commit sha
upstream_commit()
{
echo "5cc5b102c1b0a66aa63b66f43f2da9a1a9d15ab6"
echo "ae5e029d2227b3a8024f597591f76fe0f37d52e3"
}
# Show version information
@ -314,6 +314,7 @@ patch_enable_all ()
enable_user32_Refresh_MDI_Menus="$1"
enable_user32_ScrollWindowEx="$1"
enable_user32_ShowWindow="$1"
enable_user32_dialog_focus="$1"
enable_user32_msgbox_Support_WM_COPY_mesg="$1"
enable_uxtheme_CloseThemeClass="$1"
enable_uxtheme_GTK_Theming="$1"
@ -1095,6 +1096,9 @@ patch_enable ()
user32-ShowWindow)
enable_user32_ShowWindow="$2"
;;
user32-dialog_focus)
enable_user32_dialog_focus="$2"
;;
user32-msgbox-Support-WM_COPY-mesg)
enable_user32_msgbox_Support_WM_COPY_mesg="$2"
;;
@ -6436,6 +6440,21 @@ if test "$enable_user32_ShowWindow" -eq 1; then
) >> "$patchlist"
fi
# Patchset user32-dialog_focus
# |
# | This patchset fixes the following Wine bugs:
# | * [#46215] File Open Dialog fails to set focus to Filename text box
# |
# | Modified files:
# | * dlls/user32/dialog.c
# |
if test "$enable_user32_dialog_focus" -eq 1; then
patch_apply user32-dialog_focus/0001-user32-Dont-reset-focus-if-current-control-is-a-chil.patch
(
printf '%s\n' '+ { "Alistair Leslie-Hughes", "user32: Dont reset focus if current control is a child of our parent.", 1 },';
) >> "$patchlist"
fi
# Patchset user32-msgbox-Support-WM_COPY-mesg
# |
# | This patchset fixes the following Wine bugs:
@ -6544,7 +6563,7 @@ fi
# |
# | Modified files:
# | * dlls/gdiplus/tests/image.c, dlls/windowscodecs/clsfactory.c, dlls/windowscodecs/converter.c,
# | dlls/windowscodecs/gifformat.c, dlls/windowscodecs/info.c, dlls/windowscodecs/pngformat.c, dlls/windowscodecs/regsvr.c,
# | dlls/windowscodecs/gifformat.c, dlls/windowscodecs/info.c, dlls/windowscodecs/regsvr.c,
# | dlls/windowscodecs/tests/converter.c, dlls/windowscodecs/tiffformat.c, dlls/windowscodecs/wincodecs_private.h,
# | dlls/windowscodecs/windowscodecs_wincodec.idl
# |
@ -6552,35 +6571,33 @@ if test "$enable_windowscodecs_GIF_Encoder" -eq 1; then
patch_apply windowscodecs-GIF_Encoder/0007-windowscodecs-tests-Add-IWICBitmapEncoderInfo-test.patch
patch_apply windowscodecs-GIF_Encoder/0008-windowscodecs-Add-initial-implementation-of-the-GIF-.patch
patch_apply windowscodecs-GIF_Encoder/0010-windowscodecs-Initialize-empty-property-bag-in-GIF-e.patch
patch_apply windowscodecs-GIF_Encoder/0011-windowscodecs-Add-registration-for-GUID_WICPixelForm.patch
patch_apply windowscodecs-GIF_Encoder/0012-windowscodecs-Implement-IWICBitmapDecoder-GetMetadat.patch
patch_apply windowscodecs-GIF_Encoder/0014-windowscodecs-Fix-the-buffer-size-check-in-the-TIFF-.patch
patch_apply windowscodecs-GIF_Encoder/0015-windowscodecs-Add-support-for-converting-to-8bppInde.patch
patch_apply windowscodecs-GIF_Encoder/0016-windowscodecs-WICConvertBitmapSource-should-ask-IWIC.patch
patch_apply windowscodecs-GIF_Encoder/0019-windowscodecs-Improve-stub-for-IWICBitmapDecoder-Get.patch
patch_apply windowscodecs-GIF_Encoder/0020-windowscodecs-Add-registration-of-the-GIF-encoder.patch
patch_apply windowscodecs-GIF_Encoder/0021-windowscodecs-Fix-IWICBitmapDecoder-CopyPalette-for-.patch
patch_apply windowscodecs-GIF_Encoder/0022-windowscodecs-Better-follow-the-GIF-spec-and-don-t-s.patch
patch_apply windowscodecs-GIF_Encoder/0023-windowscodecs-Fix-behaviour-of-format-converter-for-.patch
patch_apply windowscodecs-GIF_Encoder/0024-windowscodecs-tests-Add-a-bunch-of-new-tests-for-ind.patch
patch_apply windowscodecs-GIF_Encoder/0025-windowscodecs-tests-Add-some-tests-for-converting-24.patch
patch_apply windowscodecs-GIF_Encoder/0026-windowscodecs-tests-Add-the-tests-for-GIF-encoder-an.patch
patch_apply windowscodecs-GIF_Encoder/0027-windowscodecs-tests-Add-a-missing-check-for-IWICBitm.patch
patch_apply windowscodecs-GIF_Encoder/0028-windowscodecs-Correctly-indicate-that-the-global-inf.patch
(
printf '%s\n' '+ { "Alistair Leslie-Hughes", "windowscodecs/tests: Add IWICBitmapEncoderInfo test.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Add initial implementation of the GIF encoder.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Initialize empty property bag in GIF encoder'\''s CreateNewFrame implementation.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Add registration for GUID_WICPixelFormat32bppGrayFloat pixel format.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICBitmapDecoder::GetMetadataQueryReader in the TIFF decoder.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Fix the buffer size check in the TIFF decoder'\''s IWICBitmapFrameDecode::CopyPixels implementation.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Add support for converting to 8bppIndexed format to IWICFormatConverter.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: WICConvertBitmapSource should ask IWICFormatConverter::Initialize to use an optimized palette.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Improve stub for IWICBitmapDecoder::GetMetadataQueryReader in the PNG decoder.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Add registration of the GIF encoder.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Fix IWICBitmapDecoder::CopyPalette for a not initialized case in the GIF decoder.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Better follow the GIF spec and don'\''t specify the local color table size if there is no local palette.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Fix behaviour of format converter for indexed formats when NULL or empty palette has been provided.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add a bunch of new tests for indexed format conversions.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add some tests for converting 24bppBGR to 8bppIndexed format.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add the tests for GIF encoder and decoder.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add a missing check for IWICBitmapFrameDecode::GetPixelFormat return value.", 1 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Correctly indicate that the global info was written even without the global palette.", 1 },';
) >> "$patchlist"
fi
@ -6595,12 +6612,10 @@ fi
# | dlls/windowscodecs/tests/palette.c, include/gdiplusflat.h
# |
if test "$enable_windowscodecs_IWICPalette_InitializeFromBitmap" -eq 1; then
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0001-windowscodecs-tests-Add-some-tests-for-IWICPalette-I.patch
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0002-windowscodecs-Implement-IWICPalette-InitializeFromBi.patch
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0003-gdiplus-Implement-GdipInitializePalette.-v2.patch
patch_apply windowscodecs-IWICPalette_InitializeFromBitmap/0004-gdiplus-tests-Add-some-tests-for-GdipInitializePalet.patch
(
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs/tests: Add some tests for IWICPalette::InitializeFromBitmap.", 2 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "windowscodecs: Implement IWICPalette::InitializeFromBitmap.", 5 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "gdiplus: Implement GdipInitializePalette.", 2 },';
printf '%s\n' '+ { "Dmitry Timoshkov", "gdiplus/tests: Add some tests for GdipInitializePalette.", 2 },';

View File

@ -1,4 +1,4 @@
From e30f36cd750f0016cfd219e27c44bbaa90b78104 Mon Sep 17 00:00:00 2001
From 1f72ae3bb68ea11fab39e3b30205ea613f77876e Mon Sep 17 00:00:00 2001
From: Louis Lenders <xerox.xerox2000x@gmail.com>
Date: Thu, 7 Jun 2018 11:51:01 +0200
Subject: [PATCH] uianimation: add stub dll
@ -11,7 +11,7 @@ Signed-off-by: Louis Lenders <xerox.xerox2000x@gmail.com>
configure | 2 +
configure.ac | 1 +
dlls/uianimation/Makefile.in | 7 +
dlls/uianimation/main.c | 1393 ++++++++++++++++++++++++++++++
dlls/uianimation/main.c | 1393 ++++++++++++++++++++++
dlls/uianimation/uianimation.spec | 4 +
dlls/uianimation/uianimation_typelib.idl | 23 +
6 files changed, 1430 insertions(+)
@ -21,19 +21,19 @@ Signed-off-by: Louis Lenders <xerox.xerox2000x@gmail.com>
create mode 100644 dlls/uianimation/uianimation_typelib.idl
diff --git a/configure b/configure
index 12679bf..2f9434e 100755
index 4807d0a2..6f73764c 100755
--- a/configure
+++ b/configure
@@ -1534,6 +1534,7 @@ enable_tdi_sys
enable_traffic
@@ -1547,6 +1547,7 @@ enable_traffic
enable_twain_32
enable_tzres
enable_ucrtbase
+enable_uianimation
enable_uiautomationcore
enable_uiribbon
enable_unicows
@@ -19182,6 +19183,7 @@ wine_fn_config_makefile dlls/twain_32/tests enable_tests
wine_fn_config_makefile dlls/typelib.dll16 enable_win16
@@ -19876,6 +19877,7 @@ wine_fn_config_makefile dlls/typelib.dll16 enable_win16
wine_fn_config_makefile dlls/tzres enable_tzres
wine_fn_config_makefile dlls/ucrtbase enable_ucrtbase
wine_fn_config_makefile dlls/ucrtbase/tests enable_tests
+wine_fn_config_makefile dlls/uianimation enable_uianimation
@ -41,11 +41,11 @@ index 12679bf..2f9434e 100755
wine_fn_config_makefile dlls/uiribbon enable_uiribbon
wine_fn_config_makefile dlls/unicows enable_unicows
diff --git a/configure.ac b/configure.ac
index 6d7f5ac..f4c944b 100644
index 08fbc3c1..9d98005c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3681,6 +3681,7 @@ WINE_CONFIG_MAKEFILE(dlls/twain_32/tests)
WINE_CONFIG_MAKEFILE(dlls/typelib.dll16,enable_win16)
@@ -3714,6 +3714,7 @@ WINE_CONFIG_MAKEFILE(dlls/typelib.dll16,enable_win16)
WINE_CONFIG_MAKEFILE(dlls/tzres)
WINE_CONFIG_MAKEFILE(dlls/ucrtbase)
WINE_CONFIG_MAKEFILE(dlls/ucrtbase/tests)
+WINE_CONFIG_MAKEFILE(dlls/uianimation)
@ -54,7 +54,7 @@ index 6d7f5ac..f4c944b 100644
WINE_CONFIG_MAKEFILE(dlls/unicows)
diff --git a/dlls/uianimation/Makefile.in b/dlls/uianimation/Makefile.in
new file mode 100644
index 0000000..bc303b3
index 00000000..bc303b30
--- /dev/null
+++ b/dlls/uianimation/Makefile.in
@@ -0,0 +1,7 @@
@ -67,7 +67,7 @@ index 0000000..bc303b3
+ uianimation_typelib.idl
diff --git a/dlls/uianimation/main.c b/dlls/uianimation/main.c
new file mode 100644
index 0000000..28687b6
index 00000000..28687b63
--- /dev/null
+++ b/dlls/uianimation/main.c
@@ -0,0 +1,1393 @@
@ -1466,7 +1466,7 @@ index 0000000..28687b6
+}
diff --git a/dlls/uianimation/uianimation.spec b/dlls/uianimation/uianimation.spec
new file mode 100644
index 0000000..b16365d
index 00000000..b16365d0
--- /dev/null
+++ b/dlls/uianimation/uianimation.spec
@@ -0,0 +1,4 @@
@ -1476,7 +1476,7 @@ index 0000000..b16365d
+@ stdcall -private DllUnregisterServer()
diff --git a/dlls/uianimation/uianimation_typelib.idl b/dlls/uianimation/uianimation_typelib.idl
new file mode 100644
index 0000000..9066c09
index 00000000..9066c09a
--- /dev/null
+++ b/dlls/uianimation/uianimation_typelib.idl
@@ -0,0 +1,23 @@
@ -1504,5 +1504,5 @@ index 0000000..9066c09
+
+#include "uianimation.idl"
--
1.9.1
2.19.1

View File

@ -1,15 +1,15 @@
From 39d690bf0ea117214e76419876188c7277ae1749 Mon Sep 17 00:00:00 2001
From ff6282f297e67822ee0def394a677a4fdc0fa609 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 26 Jan 2017 19:01:21 +0800
Subject: [PATCH] windowscodecs: Fix 32bppRGB to 32bppRGBA conversion.
Subject: windowscodecs: Fix 32bppRGB to 32bppRGBA conversion.
---
dlls/windowscodecs/converter.c | 2 ++
dlls/windowscodecs/tests/converter.c | 43 ++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
dlls/windowscodecs/tests/converter.c | 45 +++++++++++++++++++++++++++++++++++-
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c
index 47de603..d23c262 100644
index 519860d9065..1378c85bc2d 100644
--- a/dlls/windowscodecs/converter.c
+++ b/dlls/windowscodecs/converter.c
@@ -868,7 +868,9 @@ static HRESULT copypixels_to_32bppRGBA(struct FormatConverter *This, const WICRe
@ -23,10 +23,10 @@ index 47de603..d23c262 100644
return IWICBitmapSource_CopyPixels(This->source, prc, cbStride, cbBufferSize, pbBuffer);
return S_OK;
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index 5480584..77db7e8 100644
index 1cafe90c734..17724d9ed01 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -258,6 +258,21 @@ static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, cons
@@ -291,6 +291,21 @@ static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, cons
if (!equal && expect->alt_data)
equal = compare_bits(expect->alt_data, buffersize, converted_bits);
@ -48,20 +48,21 @@ index 5480584..77db7e8 100644
return equal;
}
@@ -353,12 +368,34 @@ static const BYTE bits_32bppBGR[] = {
0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80};
@@ -438,6 +453,10 @@ static const BYTE bits_32bppBGR[] = {
0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80};
static const struct bitmap_data testdata_32bppBGR = {
&GUID_WICPixelFormat32bppBGR, 32, bits_32bppBGR, 4, 2, 96.0, 96.0};
&GUID_WICPixelFormat32bppBGR, 32, bits_32bppBGR, 32, 2, 96.0, 96.0};
+static const struct bitmap_data testdata_32bppBGRA80 = {
+ &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGR, 32, 2, 96.0, 96.0};
+static const struct bitmap_data testdata_32bppRGBA80 = {
+ &GUID_WICPixelFormat32bppRGBA, 32, bits_32bppBGR, 32, 2, 96.0, 96.0};
static const BYTE bits_32bppBGRA[] = {
255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255};
255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
@@ -450,6 +469,24 @@ static const BYTE bits_32bppBGRA[] = {
0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255};
static const struct bitmap_data testdata_32bppBGRA = {
&GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA, 4, 2, 96.0, 96.0};
&GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA, 32, 2, 96.0, 96.0};
+static const struct bitmap_data testdata_32bppRGBA = {
+ &GUID_WICPixelFormat32bppRGBA, 32, bits_32bppBGRA, 32, 2, 96.0, 96.0};
+static const struct bitmap_data testdata_32bppRGB = {
@ -83,7 +84,16 @@ index 5480584..77db7e8 100644
/* XP and 2003 use linear color conversion, later versions use sRGB gamma */
static const float bits_32bppGrayFloat_xp[] = {
@@ -1684,6 +1721,12 @@ START_TEST(converter)
@@ -515,7 +552,7 @@ static void test_conversion(const struct bitmap_data *src, const struct bitmap_d
hr = WICConvertBitmapSource(dst->format, &src_obj->IWICBitmapSource_iface, &dst_bitmap);
todo_wine_if (todo)
ok(hr == S_OK ||
- broken(hr == E_INVALIDARG) /* XP */, "WICConvertBitmapSource(%s) failed, hr=%x\n", name, hr);
+ broken(hr == E_INVALIDARG || hr == WINCODEC_ERR_COMPONENTNOTFOUND) /* XP */, "WICConvertBitmapSource(%s) failed, hr=%x\n", name, hr);
if (hr == S_OK)
{
@@ -1752,6 +1789,12 @@ START_TEST(converter)
test_conversion(&testdata_32bppBGRA, &testdata_32bppBGR, "BGRA -> BGR", FALSE);
test_conversion(&testdata_32bppBGR, &testdata_32bppBGRA, "BGR -> BGRA", FALSE);
test_conversion(&testdata_32bppBGRA, &testdata_32bppBGRA, "BGRA -> BGRA", FALSE);
@ -97,5 +107,5 @@ index 5480584..77db7e8 100644
test_conversion(&testdata_24bppBGR, &testdata_24bppBGR, "24bppBGR -> 24bppBGR", FALSE);
test_conversion(&testdata_24bppBGR, &testdata_24bppRGB, "24bppBGR -> 24bppRGB", FALSE);
--
1.9.1
2.11.0

View File

@ -1,53 +0,0 @@
From 6d21d949439cb6e519029aee6bc55693f4cafc6c Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 20 Oct 2016 19:02:39 +0800
Subject: windowscodecs: Add registration for GUID_WICPixelFormat32bppGrayFloat
pixel format.
---
dlls/windowscodecs/regsvr.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c
index 74637f5..4516d3f 100644
--- a/dlls/windowscodecs/regsvr.c
+++ b/dlls/windowscodecs/regsvr.c
@@ -1748,6 +1748,8 @@ static BYTE const channel_mask_16bit2[] = { 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
static BYTE const channel_mask_16bit3[] = { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00 };
static BYTE const channel_mask_16bit4[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff };
+static BYTE const channel_mask_32bit[] = { 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00 };
+
static BYTE const channel_mask_5bit[] = { 0x1f, 0x00 };
static BYTE const channel_mask_5bit2[] = { 0xe0, 0x03 };
static BYTE const channel_mask_5bit3[] = { 0x00, 0x7c };
@@ -1764,6 +1766,8 @@ static BYTE const * const channel_masks_8bit[] = { channel_mask_8bit,
static BYTE const * const channel_masks_16bit[] = { channel_mask_16bit,
channel_mask_16bit2, channel_mask_16bit3, channel_mask_16bit4};
+static BYTE const * const channel_masks_32bit[] = { channel_mask_32bit };
+
static BYTE const * const channel_masks_BGRA5551[] = { channel_mask_5bit,
channel_mask_5bit2, channel_mask_5bit3, channel_mask_5bit4 };
@@ -1958,6 +1962,17 @@ static struct regsvr_pixelformat const pixelformat_list[] = {
WICPixelFormatNumericRepresentationUnsignedInteger,
1
},
+ { &GUID_WICPixelFormat32bppGrayFloat,
+ "The Wine Project",
+ "32bpp GrayFloat",
+ NULL, /* no version */
+ &GUID_VendorMicrosoft,
+ 32, /* bitsperpixel */
+ 1, /* channel count */
+ channel_masks_32bit,
+ WICPixelFormatNumericRepresentationFloat,
+ 1
+ },
{ &GUID_WICPixelFormat48bppRGB,
"The Wine Project",
"48bpp RGB",
--
2.9.0

View File

@ -1,32 +0,0 @@
From 2297b261c195840bcff9a3db40b25fcaaa747a7b Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 20 Oct 2016 16:49:08 +0800
Subject: windowscodecs: Implement IWICBitmapDecoder::GetMetadataQueryReader in
the TIFF decoder.
---
dlls/windowscodecs/tiffformat.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/dlls/windowscodecs/tiffformat.c b/dlls/windowscodecs/tiffformat.c
index 037277b..19aa5d5 100644
--- a/dlls/windowscodecs/tiffformat.c
+++ b/dlls/windowscodecs/tiffformat.c
@@ -699,8 +699,12 @@ static HRESULT WINAPI TiffDecoder_CopyPalette(IWICBitmapDecoder *iface,
static HRESULT WINAPI TiffDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
IWICMetadataQueryReader **ppIMetadataQueryReader)
{
- FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
- return E_NOTIMPL;
+ TRACE("(%p,%p)\n", iface, ppIMetadataQueryReader);
+
+ if (!ppIMetadataQueryReader) return E_INVALIDARG;
+
+ *ppIMetadataQueryReader = NULL;
+ return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI TiffDecoder_GetPreview(IWICBitmapDecoder *iface,
--
2.9.0

View File

@ -1,35 +0,0 @@
From 3204ee4de19693fd9e451a62216b68fe51ea2ca5 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Fri, 21 Oct 2016 14:38:43 +0800
Subject: windowscodecs: Improve stub for
IWICBitmapDecoder::GetMetadataQueryReader in the PNG decoder.
---
dlls/windowscodecs/pngformat.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/dlls/windowscodecs/pngformat.c b/dlls/windowscodecs/pngformat.c
index 94253d3..41d9099 100644
--- a/dlls/windowscodecs/pngformat.c
+++ b/dlls/windowscodecs/pngformat.c
@@ -853,10 +853,14 @@ static HRESULT WINAPI PngDecoder_CopyPalette(IWICBitmapDecoder *iface,
}
static HRESULT WINAPI PngDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface,
- IWICMetadataQueryReader **ppIMetadataQueryReader)
+ IWICMetadataQueryReader **reader)
{
- FIXME("(%p,%p): stub\n", iface, ppIMetadataQueryReader);
- return E_NOTIMPL;
+ FIXME("(%p,%p): stub\n", iface, reader);
+
+ if (!reader) return E_INVALIDARG;
+
+ *reader = NULL;
+ return WINCODEC_ERR_UNSUPPORTEDOPERATION;
}
static HRESULT WINAPI PngDecoder_GetPreview(IWICBitmapDecoder *iface,
--
2.9.0

View File

@ -0,0 +1,529 @@
From e80477c69984c1f188de779fbf7559dd17d61416 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 27 Oct 2016 15:10:09 +0800
Subject: [PATCH] windowscodecs/tests: Add a bunch of new tests for indexed
format conversions.
---
dlls/windowscodecs/tests/converter.c | 269 ++++++++++++++++++++-------
1 file changed, 201 insertions(+), 68 deletions(-)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index 4eea13b8..925d97ea 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -118,9 +118,30 @@ static HRESULT WINAPI BitmapTestSrc_GetResolution(IWICBitmapSource *iface,
}
static HRESULT WINAPI BitmapTestSrc_CopyPalette(IWICBitmapSource *iface,
- IWICPalette *pIPalette)
+ IWICPalette *palette)
{
- return E_NOTIMPL;
+ BitmapTestSrc *This = impl_from_IWICBitmapSource(iface);
+
+ if (IsEqualGUID(This->data->format, &GUID_WICPixelFormat1bppIndexed) ||
+ IsEqualGUID(This->data->format, &GUID_WICPixelFormat2bppIndexed) ||
+ IsEqualGUID(This->data->format, &GUID_WICPixelFormat4bppIndexed) ||
+ IsEqualGUID(This->data->format, &GUID_WICPixelFormat8bppIndexed))
+ {
+ WICColor colors[8];
+
+ colors[0] = 0xff0000ff;
+ colors[1] = 0xff00ff00;
+ colors[2] = 0xffff0000;
+ colors[3] = 0xff000000;
+ colors[4] = 0xffffff00;
+ colors[5] = 0xffff00ff;
+ colors[6] = 0xff00ffff;
+ colors[7] = 0xffffffff;
+ return IWICPalette_InitializeCustom(palette, colors, 8);
+ }
+
+ /* unique error marker */
+ return 0xdeadbeef;
}
static HRESULT WINAPI BitmapTestSrc_CopyPixels(IWICBitmapSource *iface,
@@ -252,6 +273,21 @@ static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, cons
break;
}
}
+ else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat2bppIndexed) ||
+ IsEqualGUID(expect->format, &GUID_WICPixelFormat4bppIndexed) ||
+ IsEqualGUID(expect->format, &GUID_WICPixelFormat8bppIndexed))
+ {
+ UINT i;
+ const BYTE *a=(const BYTE*)expect->bits, *b=(const BYTE*)converted_bits;
+ equal=TRUE;
+
+ for (i=0; i<buffersize; i++)
+ if (a[i] != b[i])
+ {
+ equal = FALSE;
+ break;
+ }
+ }
else
equal = (memcmp(expect->bits, converted_bits, buffersize) == 0);
@@ -261,7 +297,19 @@ static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, cons
return equal;
}
-static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSource *source, const char *name)
+static BOOL is_indexed_format(const GUID *format)
+{
+ if (IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed) ||
+ IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed) ||
+ IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed) ||
+ IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
+ return TRUE;
+
+ return FALSE;
+}
+
+static void compare_bitmap_data(const struct bitmap_data *src, const struct bitmap_data *expect,
+ IWICBitmapSource *source, const char *name)
{
BYTE *converted_bits;
UINT width, height;
@@ -294,15 +342,24 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour
buffersize = stride * expect->height;
converted_bits = HeapAlloc(GetProcessHeap(), 0, buffersize);
+ memset(converted_bits, 0xaa, buffersize);
hr = IWICBitmapSource_CopyPixels(source, &prc, stride, buffersize, converted_bits);
ok(SUCCEEDED(hr), "CopyPixels(%s) failed, hr=%x\n", name, hr);
- ok(compare_bits(expect, buffersize, converted_bits), "unexpected pixel data (%s)\n", name);
+
+ /* The result of conversion of color to indexed formats depends on
+ * optimized palette generation implementation. We either need to
+ * assign our own palette, or just skip the comparison.
+ */
+ if (!(!is_indexed_format(src->format) && is_indexed_format(expect->format)))
+ ok(compare_bits(expect, buffersize, converted_bits), "unexpected pixel data (%s)\n", name);
/* Test with NULL rectangle - should copy the whole bitmap */
memset(converted_bits, 0xaa, buffersize);
hr = IWICBitmapSource_CopyPixels(source, NULL, stride, buffersize, converted_bits);
ok(SUCCEEDED(hr), "CopyPixels(%s,rc=NULL) failed, hr=%x\n", name, hr);
- ok(compare_bits(expect, buffersize, converted_bits), "unexpected pixel data (%s)\n", name);
+ /* see comment above */
+ if (!(!is_indexed_format(src->format) && is_indexed_format(expect->format)))
+ ok(compare_bits(expect, buffersize, converted_bits), "unexpected pixel data (%s)\n", name);
HeapFree(GetProcessHeap(), 0, converted_bits);
}
@@ -318,78 +375,137 @@ static const struct bitmap_data testdata_1bppIndexed = {
/* some encoders (like BMP) require data to be 4-bytes aligned */
static const BYTE bits_2bpp[] = {
- 0x55,0x55,0x55,0x55,
- 0xaa,0xaa,0xaa,0xaa};
+ 0xdb,0xdb,0xdb,0xdb,0xdb,0xdb,0xdb,0xdb,
+ 0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24};
static const struct bitmap_data testdata_2bppIndexed = {
- &GUID_WICPixelFormat2bppIndexed, 2, bits_2bpp, 16, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat2bppIndexed, 2, bits_2bpp, 32, 2, 96.0, 96.0};
/* some encoders (like BMP) require data to be 4-bytes aligned */
static const BYTE bits_4bpp[] = {
- 0x55,0x55,0x55,0x55,
- 0xaa,0xaa,0xaa,0xaa};
+ 0x01,0x23,0x01,0x23,0x01,0x23,0x01,0x23,0x01,0x23,0x01,0x23,0x01,0x23,0x01,0x23,
+ 0x45,0x67,0x45,0x67,0x45,0x67,0x45,0x67,0x45,0x67,0x45,0x67,0x45,0x67,0x45,0x67};
+
static const struct bitmap_data testdata_4bppIndexed = {
- &GUID_WICPixelFormat4bppIndexed, 4, bits_4bpp, 8, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat4bppIndexed, 4, bits_4bpp, 32, 2, 96.0, 96.0};
+
+static const BYTE bits_8bpp_BW[] = {
+ 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,
+ 1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0};
+static const struct bitmap_data testdata_8bppIndexed_BW = {
+ &GUID_WICPixelFormat8bppIndexed, 8, bits_8bpp_BW, 32, 2, 96.0, 96.0};
+
+static const BYTE bits_8bpp_4colors[] = {
+ 0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,0,1,2,0,
+ 3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3,3,2,1,3};
+static const struct bitmap_data testdata_8bppIndexed_4colors = {
+ &GUID_WICPixelFormat8bppIndexed, 8, bits_8bpp_4colors, 32, 2, 96.0, 96.0};
static const BYTE bits_8bpp[] = {
- 0,1,2,3,
- 4,5,6,7};
+ 0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,0,1,2,3,
+ 4,5,6,7,4,5,6,7,4,5,6,7,4,5,6,7,4,5,6,7,4,5,6,7,4,5,6,7,4,5,6,7};
static const struct bitmap_data testdata_8bppIndexed = {
- &GUID_WICPixelFormat8bppIndexed, 8, bits_8bpp, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat8bppIndexed, 8, bits_8bpp, 32, 2, 96.0, 96.0};
static const BYTE bits_24bppBGR[] = {
- 255,0,0, 0,255,0, 0,0,255, 0,0,0,
- 0,255,255, 255,0,255, 255,255,0, 255,255,255};
+ 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
+ 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
+ 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
+ 255,0,0, 0,255,0, 0,0,255, 0,0,0, 255,0,0, 0,255,0, 0,0,255, 0,0,0,
+ 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255,
+ 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255,
+ 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255,
+ 0,255,255, 255,0,255, 255,255,0, 255,255,255, 0,255,255, 255,0,255, 255,255,0, 255,255,255};
static const struct bitmap_data testdata_24bppBGR = {
- &GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR, 32, 2, 96.0, 96.0};
static const BYTE bits_24bppRGB[] = {
- 0,0,255, 0,255,0, 255,0,0, 0,0,0,
- 255,255,0, 255,0,255, 0,255,255, 255,255,255};
+ 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
+ 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
+ 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
+ 0,0,255, 0,255,0, 255,0,0, 0,0,0, 0,0,255, 0,255,0, 255,0,0, 0,0,0,
+ 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255,
+ 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255,
+ 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255,
+ 255,255,0, 255,0,255, 0,255,255, 255,255,255, 255,255,0, 255,0,255, 0,255,255, 255,255,255 };
static const struct bitmap_data testdata_24bppRGB = {
- &GUID_WICPixelFormat24bppRGB, 24, bits_24bppRGB, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat24bppRGB, 24, bits_24bppRGB, 32, 2, 96.0, 96.0};
static const BYTE bits_32bppBGR[] = {
- 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
- 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80};
+ 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
+ 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
+ 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
+ 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80, 255,0,0,80, 0,255,0,80, 0,0,255,80, 0,0,0,80,
+ 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80,
+ 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80,
+ 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80,
+ 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80, 0,255,255,80, 255,0,255,80, 255,255,0,80, 255,255,255,80};
static const struct bitmap_data testdata_32bppBGR = {
- &GUID_WICPixelFormat32bppBGR, 32, bits_32bppBGR, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat32bppBGR, 32, bits_32bppBGR, 32, 2, 96.0, 96.0};
static const BYTE bits_32bppBGRA[] = {
- 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
- 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255};
+ 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
+ 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
+ 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
+ 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255, 255,0,0,255, 0,255,0,255, 0,0,255,255, 0,0,0,255,
+ 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255,
+ 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255,
+ 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255,
+ 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255, 0,255,255,255, 255,0,255,255, 255,255,0,255, 255,255,255,255};
static const struct bitmap_data testdata_32bppBGRA = {
- &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA, 32, 2, 96.0, 96.0};
/* XP and 2003 use linear color conversion, later versions use sRGB gamma */
static const float bits_32bppGrayFloat_xp[] = {
- 0.114000f,0.587000f,0.299000f,0.000000f,
- 0.886000f,0.413000f,0.701000f,1.000000f};
+ 0.114000f,0.587000f,0.299000f,0.000000f,0.114000f,0.587000f,0.299000f,0.000000f,
+ 0.114000f,0.587000f,0.299000f,0.000000f,0.114000f,0.587000f,0.299000f,0.000000f,
+ 0.114000f,0.587000f,0.299000f,0.000000f,0.114000f,0.587000f,0.299000f,0.000000f,
+ 0.114000f,0.587000f,0.299000f,0.000000f,0.114000f,0.587000f,0.299000f,0.000000f,
+ 0.886000f,0.413000f,0.701000f,1.000000f,0.886000f,0.413000f,0.701000f,1.000000f,
+ 0.886000f,0.413000f,0.701000f,1.000000f,0.886000f,0.413000f,0.701000f,1.000000f,
+ 0.886000f,0.413000f,0.701000f,1.000000f,0.886000f,0.413000f,0.701000f,1.000000f,
+ 0.886000f,0.413000f,0.701000f,1.000000f,0.886000f,0.413000f,0.701000f,1.000000f};
static const struct bitmap_data testdata_32bppGrayFloat_xp = {
- &GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat_xp, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat_xp, 32, 2, 96.0, 96.0};
static const float bits_32bppGrayFloat[] = {
- 0.072200f,0.715200f,0.212600f,0.000000f,
- 0.927800f,0.284800f,0.787400f,1.000000f};
+ 0.072200f,0.715200f,0.212600f,0.000000f,0.072200f,0.715200f,0.212600f,0.000000f,
+ 0.072200f,0.715200f,0.212600f,0.000000f,0.072200f,0.715200f,0.212600f,0.000000f,
+ 0.072200f,0.715200f,0.212600f,0.000000f,0.072200f,0.715200f,0.212600f,0.000000f,
+ 0.072200f,0.715200f,0.212600f,0.000000f,0.072200f,0.715200f,0.212600f,0.000000f,
+ 0.927800f,0.284800f,0.787400f,1.000000f,0.927800f,0.284800f,0.787400f,1.000000f,
+ 0.927800f,0.284800f,0.787400f,1.000000f,0.927800f,0.284800f,0.787400f,1.000000f,
+ 0.927800f,0.284800f,0.787400f,1.000000f,0.927800f,0.284800f,0.787400f,1.000000f,
+ 0.927800f,0.284800f,0.787400f,1.000000f,0.927800f,0.284800f,0.787400f,1.000000f};
static const struct bitmap_data testdata_32bppGrayFloat = {
- &GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat, 4, 2, 96.0, 96.0, &testdata_32bppGrayFloat_xp};
+ &GUID_WICPixelFormat32bppGrayFloat, 32, (const BYTE *)bits_32bppGrayFloat, 32, 2, 96.0, 96.0, &testdata_32bppGrayFloat_xp};
static const BYTE bits_8bppGray_xp[] = {
- 29,150,76,0,
- 226,105,179,255};
+ 29,150,76,0,29,150,76,0,29,150,76,0,29,150,76,0,
+ 29,150,76,0,29,150,76,0,29,150,76,0,29,150,76,0,
+ 226,105,179,255,226,105,179,255,226,105,179,255,226,105,179,255,
+ 226,105,179,255,226,105,179,255,226,105,179,255,226,105,179,255};
static const struct bitmap_data testdata_8bppGray_xp = {
- &GUID_WICPixelFormat8bppGray, 8, bits_8bppGray_xp, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat8bppGray, 8, bits_8bppGray_xp, 32, 2, 96.0, 96.0};
static const BYTE bits_8bppGray[] = {
- 76,220,127,0,
- 247,145,230,255};
+ 76,220,127,0,76,220,127,0,76,220,127,0,76,220,127,0,
+ 76,220,127,0,76,220,127,0,76,220,127,0,76,220,127,0,
+ 247,145,230,255,247,145,230,255,247,145,230,255,247,145,230,255,
+ 247,145,230,255,247,145,230,255,247,145,230,255,247,145,230,255};
static const struct bitmap_data testdata_8bppGray = {
- &GUID_WICPixelFormat8bppGray, 8, bits_8bppGray, 4, 2, 96.0, 96.0, &testdata_8bppGray_xp};
+ &GUID_WICPixelFormat8bppGray, 8, bits_8bppGray, 32, 2, 96.0, 96.0, &testdata_8bppGray_xp};
static const BYTE bits_24bppBGR_gray[] = {
- 76,76,76, 220,220,220, 127,127,127, 0,0,0,
- 247,247,247, 145,145,145, 230,230,230, 255,255,255};
+ 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
+ 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
+ 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
+ 76,76,76, 220,220,220, 127,127,127, 0,0,0, 76,76,76, 220,220,220, 127,127,127, 0,0,0,
+ 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255,
+ 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255,
+ 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255,
+ 247,247,247, 145,145,145, 230,230,230, 255,255,255, 247,247,247, 145,145,145, 230,230,230, 255,255,255};
static const struct bitmap_data testdata_24bppBGR_gray = {
- &GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR_gray, 4, 2, 96.0, 96.0};
+ &GUID_WICPixelFormat24bppBGR, 24, bits_24bppBGR_gray, 32, 2, 96.0, 96.0};
static void test_conversion(const struct bitmap_data *src, const struct bitmap_data *dst, const char *name, BOOL todo)
{
@@ -401,11 +517,12 @@ static void test_conversion(const struct bitmap_data *src, const struct bitmap_d
hr = WICConvertBitmapSource(dst->format, &src_obj->IWICBitmapSource_iface, &dst_bitmap);
todo_wine_if (todo)
- ok(SUCCEEDED(hr), "WICConvertBitmapSource(%s) failed, hr=%x\n", name, hr);
+ ok(hr == S_OK ||
+ broken(hr == E_INVALIDARG) /* XP */, "WICConvertBitmapSource(%s) failed, hr=%x\n", name, hr);
- if (SUCCEEDED(hr))
+ if (hr == S_OK)
{
- compare_bitmap_data(dst, dst_bitmap, name);
+ compare_bitmap_data(src, dst, dst_bitmap, name);
IWICBitmapSource_Release(dst_bitmap);
}
@@ -453,7 +570,7 @@ static void test_default_converter(void)
ok(SUCCEEDED(hr), "Initialize returned %x\n", hr);
if (SUCCEEDED(hr))
- compare_bitmap_data(&testdata_32bppBGR, (IWICBitmapSource*)converter, "default converter");
+ compare_bitmap_data(&testdata_32bppBGRA, &testdata_32bppBGR, (IWICBitmapSource*)converter, "default converter");
IWICFormatConverter_Release(converter);
}
@@ -752,7 +869,7 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed))
{
- ok(width == 8, "wrong width %u\n", width);
+ ok(width == 32, "wrong width %u\n", width);
ok(height == 2, "wrong height %u\n", height);
ok(bps == 4, "wrong bps %d\n", bps);
@@ -762,7 +879,7 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
{
- ok(width == 4, "wrong width %u\n", width);
+ ok(width == 32, "wrong width %u\n", width);
ok(height == 2, "wrong height %u\n", height);
ok(bps == 8, "wrong bps %d\n", bps);
@@ -772,7 +889,7 @@ static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat24bppBGR))
{
- ok(width == 4, "wrong width %u\n", width);
+ ok(width == 32, "wrong width %u\n", width);
ok(height == 2, "wrong height %u\n", height);
ok(bps == 3, "wrong bps %d\n", bps);
@@ -790,7 +907,6 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
BITMAPFILEHEADER bfh;
BITMAPV5HEADER bih;
- memset(&bfh, 0, sizeof(bfh));
hr = IStream_Read(stream, &bfh, sizeof(bfh), NULL);
ok(hr == S_OK, "IStream_Read error %#x\n", hr);
@@ -798,13 +914,12 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
ok(bfh.bfReserved1 == 0, "wrong bfReserved1 %02x\n", bfh.bfReserved1);
ok(bfh.bfReserved2 == 0, "wrong bfReserved2 %02x\n", bfh.bfReserved2);
- memset(&bih, 0, sizeof(bih));
hr = IStream_Read(stream, &bih, sizeof(bih), NULL);
ok(hr == S_OK, "IStream_Read error %#x\n", hr);
if (IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed))
{
- ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %02x\n", bfh.bfOffBits);
+ ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %08x\n", bfh.bfOffBits);
ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
@@ -816,9 +931,9 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed))
{
- ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %02x\n", bfh.bfOffBits);
+ ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %08x\n", bfh.bfOffBits);
- ok(bih.bV5Width == 8, "wrong width %u\n", bih.bV5Width);
+ ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes);
@@ -828,9 +943,9 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
{
- ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %02x\n", bfh.bfOffBits);
+ ok(bfh.bfOffBits == 0x0436, "wrong bfOffBits %08x\n", bfh.bfOffBits);
- ok(bih.bV5Width == 4, "wrong width %u\n", bih.bV5Width);
+ ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes);
@@ -840,9 +955,9 @@ static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat32bppBGR))
{
- ok(bfh.bfOffBits == 0x0036, "wrong bfOffBits %02x\n", bfh.bfOffBits);
+ ok(bfh.bfOffBits == 0x0036, "wrong bfOffBits %08x\n", bfh.bfOffBits);
- ok(bih.bV5Width == 4, "wrong width %u\n", bih.bV5Width);
+ ok(bih.bV5Width == 32, "wrong width %u\n", bih.bV5Width);
ok(bih.bV5Height == 2, "wrong height %u\n", bih.bV5Height);
ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes);
@@ -910,7 +1025,7 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed))
{
- ok(be_uint(png.width) == 16, "wrong width %u\n", be_uint(png.width));
+ ok(be_uint(png.width) == 32, "wrong width %u\n", be_uint(png.width));
ok(be_uint(png.height) == 2, "wrong height %u\n", be_uint(png.height));
ok(png.bit_depth == 2, "wrong bit_depth %d\n", png.bit_depth);
@@ -921,7 +1036,7 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed))
{
- ok(be_uint(png.width) == 8, "wrong width %u\n", be_uint(png.width));
+ ok(be_uint(png.width) == 32, "wrong width %u\n", be_uint(png.width));
ok(be_uint(png.height) == 2, "wrong height %u\n", be_uint(png.height));
ok(png.bit_depth == 4, "wrong bit_depth %d\n", png.bit_depth);
@@ -932,7 +1047,7 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed))
{
- ok(be_uint(png.width) == 4, "wrong width %u\n", be_uint(png.width));
+ ok(be_uint(png.width) == 32, "wrong width %u\n", be_uint(png.width));
ok(be_uint(png.height) == 2, "wrong height %u\n", be_uint(png.height));
ok(png.bit_depth == 8, "wrong bit_depth %d\n", png.bit_depth);
@@ -943,7 +1058,7 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
}
else if (IsEqualGUID(format, &GUID_WICPixelFormat24bppBGR))
{
- ok(be_uint(png.width) == 4, "wrong width %u\n", be_uint(png.width));
+ ok(be_uint(png.width) == 32, "wrong width %u\n", be_uint(png.width));
ok(be_uint(png.height) == 2, "wrong height %u\n", be_uint(png.height));
ok(png.bit_depth == 8, "wrong bit_depth %d\n", png.bit_depth);
@@ -1250,7 +1365,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
hr = IWICBitmapEncoder_Commit(encoder);
ok(SUCCEEDED(hr), "Commit failed, hr=%x\n", hr);
- check_bitmap_format(stream, clsid_encoder, dsts[0]->format);
+ if (IsEqualGUID(&pixelformat, dsts[0]->format))
+ check_bitmap_format(stream, clsid_encoder, dsts[0]->format);
}
if (SUCCEEDED(hr))
@@ -1285,7 +1401,9 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
if (SUCCEEDED(hr))
{
- compare_bitmap_data(dsts[i], (IWICBitmapSource*)framedecode, name);
+ hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &pixelformat);
+ if (IsEqualGUID(&pixelformat, dsts[i]->format))
+ compare_bitmap_data(srcs[i], dsts[i], (IWICBitmapSource*)framedecode, name);
hr = IWICBitmapFrameDecode_CopyPalette(framedecode, frame_palette);
if (winetest_debug > 1)
@@ -1333,8 +1451,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
else if (IsEqualGUID(clsid_decoder, &CLSID_WICBmpDecoder) ||
IsEqualGUID(clsid_decoder, &CLSID_WICTiffDecoder))
{
- if (IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormatBlackWhite) ||
- IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormat8bppIndexed))
+ if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormatBlackWhite) ||
+ IsEqualGUID(&pixelformat, &GUID_WICPixelFormat8bppIndexed))
{
ok(count == 256, "expected 256, got %u (%s)\n", count, name);
@@ -1345,7 +1463,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
ok(colors[4] == 0xff555555, "got %08x (%s)\n", colors[4], name);
ok(colors[5] == 0xff000000, "got %08x (%s)\n", colors[5], name);
}
- else if (IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormat4bppIndexed))
+ else if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed))
{
ok(count == 16, "expected 16, got %u (%s)\n", count, name);
@@ -1435,7 +1553,7 @@ static void test_encoder_rects(void)
rc.X = 0;
rc.Y = 0;
- rc.Width = 4;
+ rc.Width = 32;
rc.Height = 2;
test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects full", NULL);
@@ -1446,7 +1564,7 @@ static void test_encoder_rects(void)
rc.Width = -1;
test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects width=-1", NULL);
- rc.Width = 4;
+ rc.Width = 32;
rc.Height = 0;
test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects height=0", NULL);
@@ -1478,6 +1596,16 @@ START_TEST(converter)
&IID_IWICImagingFactory, (void **)&factory);
ok(hr == S_OK, "failed to create factory: %#x\n", hr);
+ test_conversion(&testdata_24bppRGB, &testdata_1bppIndexed, "24bppRGB -> 1bppIndexed", TRUE);
+ test_conversion(&testdata_24bppRGB, &testdata_2bppIndexed, "24bppRGB -> 2bppIndexed", TRUE);
+ test_conversion(&testdata_24bppRGB, &testdata_4bppIndexed, "24bppRGB -> 4bppIndexed", TRUE);
+ test_conversion(&testdata_24bppRGB, &testdata_8bppIndexed, "24bppRGB -> 8bppIndexed", FALSE);
+
+ test_conversion(&testdata_BlackWhite, &testdata_8bppIndexed_BW, "BlackWhite -> 8bppIndexed", TRUE);
+ test_conversion(&testdata_1bppIndexed, &testdata_8bppIndexed_BW, "1bppIndexed -> 8bppIndexed", TRUE);
+ test_conversion(&testdata_2bppIndexed, &testdata_8bppIndexed_4colors, "2bppIndexed -> 8bppIndexed", TRUE);
+ test_conversion(&testdata_4bppIndexed, &testdata_8bppIndexed, "4bppIndexed -> 8bppIndexed", TRUE);
+
test_conversion(&testdata_32bppBGRA, &testdata_32bppBGR, "BGRA -> BGR", FALSE);
test_conversion(&testdata_32bppBGR, &testdata_32bppBGRA, "BGR -> BGRA", FALSE);
test_conversion(&testdata_32bppBGRA, &testdata_32bppBGRA, "BGRA -> BGRA", FALSE);
@@ -1515,6 +1643,11 @@ START_TEST(converter)
&testdata_8bppIndexed, &CLSID_WICPngDecoder, "PNG encoder 8bppIndexed");
test_encoder(&testdata_24bppBGR, &CLSID_WICPngEncoder,
&testdata_24bppBGR, &CLSID_WICPngDecoder, "PNG encoder 24bppBGR");
+if (!strcmp(winetest_platform, "windows")) /* FIXME: enable once implemented in Wine */
+{
+ test_encoder(&testdata_32bppBGR, &CLSID_WICPngEncoder,
+ &testdata_24bppBGR, &CLSID_WICPngDecoder, "PNG encoder 32bppBGR");
+}
test_encoder(&testdata_BlackWhite, &CLSID_WICBmpEncoder,
&testdata_1bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder BlackWhite");
--
2.19.1

View File

@ -1,18 +1,18 @@
From d9cd3ba23fa27fcffbe3d5dff9754c0520b3f92e Mon Sep 17 00:00:00 2001
From 59176c773e3e710418c79641ca3c11d81ce98849 Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Thu, 27 Oct 2016 15:17:19 +0800
Subject: [PATCH] windowscodecs/tests: Add the tests for GIF encoder and
decoder.
---
dlls/windowscodecs/tests/converter.c | 59 +++++++++++++++++++++++++++++++++---
dlls/windowscodecs/tests/converter.c | 59 +++++++++++++++++++++++++---
1 file changed, 54 insertions(+), 5 deletions(-)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index 089926b..5480584 100644
index 7d956a69..09125603 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -956,6 +956,40 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
@@ -1071,6 +1071,40 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format)
ok(0, "unknown PNG pixel format %s\n", wine_dbgstr_guid(format));
}
@ -53,7 +53,7 @@ index 089926b..5480584 100644
static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WICPixelFormatGUID *format)
{
HRESULT hr;
@@ -971,6 +1005,8 @@ static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WIC
@@ -1086,6 +1120,8 @@ static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WIC
check_bmp_format(stream, format);
else if (IsEqualGUID(encoder, &CLSID_WICTiffEncoder))
check_tiff_format(stream, format);
@ -62,7 +62,7 @@ index 089926b..5480584 100644
else
ok(0, "unknown encoder %s\n", wine_dbgstr_guid(encoder));
@@ -1089,7 +1125,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1204,7 +1240,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
hr = CoCreateInstance(clsid_encoder, NULL, CLSCTX_INPROC_SERVER,
&IID_IWICBitmapEncoder, (void**)&encoder);
@ -71,7 +71,7 @@ index 089926b..5480584 100644
if (SUCCEEDED(hr))
{
hglobal = GlobalAlloc(GMEM_MOVEABLE, 0);
@@ -1116,7 +1152,10 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1231,7 +1267,10 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
if (palette)
{
hr = IWICBitmapEncoder_SetPalette(encoder, palette);
@ -83,7 +83,7 @@ index 089926b..5480584 100644
hr = S_OK;
}
@@ -1268,13 +1307,19 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1384,13 +1423,19 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
ok(hr == S_OK, "CreatePalette error %#x\n", hr);
hr = IWICBitmapDecoder_CopyPalette(decoder, frame_palette);
@ -105,7 +105,7 @@ index 089926b..5480584 100644
hr = S_OK;
i=0;
@@ -1331,7 +1376,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
@@ -1449,7 +1494,8 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
}
}
else if (IsEqualGUID(clsid_decoder, &CLSID_WICBmpDecoder) ||
@ -113,9 +113,9 @@ index 089926b..5480584 100644
+ IsEqualGUID(clsid_decoder, &CLSID_WICTiffDecoder) ||
+ IsEqualGUID(clsid_decoder, &CLSID_WICGifDecoder))
{
if (IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormatBlackWhite) ||
IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormat8bppIndexed))
@@ -1661,6 +1707,9 @@ START_TEST(converter)
if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormatBlackWhite) ||
IsEqualGUID(&pixelformat, &GUID_WICPixelFormat8bppIndexed))
@@ -1789,6 +1835,9 @@ START_TEST(converter)
test_default_converter();
test_converter_8bppIndexed();
@ -126,5 +126,5 @@ index 089926b..5480584 100644
&testdata_BlackWhite, &CLSID_WICPngDecoder, "PNG encoder BlackWhite");
test_encoder(&testdata_1bppIndexed, &CLSID_WICPngEncoder,
--
1.9.1
2.19.1

View File

@ -0,0 +1,25 @@
From 18eb6add9eac40d84a809d75d340600e44cc1dae Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Sun, 6 Nov 2016 16:25:12 +0800
Subject: windowscodecs/tests: Add a missing check for
IWICBitmapFrameDecode::GetPixelFormat return value.
---
dlls/windowscodecs/tests/converter.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index 430c0ed..6d782f3 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -1311,6 +1311,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls
if (SUCCEEDED(hr))
{
hr = IWICBitmapFrameDecode_GetPixelFormat(framedecode, &pixelformat);
+ ok(hr == S_OK, "GetPixelFormat) failed, hr=%x (%s)\n", hr, name);
if (IsEqualGUID(&pixelformat, dsts[i]->format))
compare_bitmap_data(srcs[i], dsts[i], (IWICBitmapSource*)framedecode, name);
--
2.9.0

View File

@ -1,234 +0,0 @@
From 65360656ee18c1bdcc50d8a81b41a691958903ab Mon Sep 17 00:00:00 2001
From: Dmitry Timoshkov <dmitry@baikal.ru>
Date: Wed, 20 Jul 2016 11:43:19 +0800
Subject: windowscodecs/tests: Add some tests for
IWICPalette::InitializeFromBitmap. (v2)
---
dlls/windowscodecs/tests/palette.c | 158 +++++++++++++++++++++++++++++++++----
1 file changed, 143 insertions(+), 15 deletions(-)
diff --git a/dlls/windowscodecs/tests/palette.c b/dlls/windowscodecs/tests/palette.c
index e3b9a31..193e621 100644
--- a/dlls/windowscodecs/tests/palette.c
+++ b/dlls/windowscodecs/tests/palette.c
@@ -1,6 +1,6 @@
/*
* Copyright 2009 Vincent Povirk for CodeWeavers
- * Copyright 2012 Dmitry Timoshkov
+ * Copyright 2012,2016 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -27,9 +27,10 @@
#include "wincodec.h"
#include "wine/test.h"
+static IWICImagingFactory *factory;
+
static void test_custom_palette(void)
{
- IWICImagingFactory *factory;
IWICPalette *palette, *palette2;
HRESULT hr;
WICBitmapPaletteType type=0xffffffff;
@@ -38,11 +39,6 @@ static void test_custom_palette(void)
WICColor colors[4];
BOOL boolresult;
- hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
- &IID_IWICImagingFactory, (void**)&factory);
- ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr);
- if (FAILED(hr)) return;
-
hr = IWICImagingFactory_CreatePalette(factory, &palette);
ok(SUCCEEDED(hr), "CreatePalette failed, hr=%x\n", hr);
if (SUCCEEDED(hr))
@@ -207,8 +203,6 @@ static void test_custom_palette(void)
IWICPalette_Release(palette2);
IWICPalette_Release(palette);
}
-
- IWICImagingFactory_Release(factory);
}
static void generate_gray16_palette(DWORD *entries, UINT count)
@@ -451,7 +445,6 @@ static void test_predefined_palette(void)
{ WICBitmapPaletteTypeFixedHalftone256, 0, 0, 256, { 0 } },
{ WICBitmapPaletteTypeFixedHalftone256, 0, 0, 256, { 0 }, 1 }
};
- IWICImagingFactory *factory;
IWICPalette *palette;
HRESULT hr;
WICBitmapPaletteType type;
@@ -459,10 +452,6 @@ static void test_predefined_palette(void)
BOOL bret;
WICColor color[256];
- hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
- &IID_IWICImagingFactory, (void **)&factory);
- ok(hr == S_OK, "CoCreateInstance error %#x\n", hr);
-
hr = IWICImagingFactory_CreatePalette(factory, &palette);
ok(hr == S_OK, "CreatePalette error %#x\n", hr);
hr = IWICPalette_InitializePredefined(palette, WICBitmapPaletteTypeCustom, FALSE);
@@ -538,16 +527,155 @@ static void test_predefined_palette(void)
IWICPalette_Release(palette);
}
+}
- IWICImagingFactory_Release(factory);
+static BYTE *init_bitmap(UINT *width, UINT *height, UINT *stride)
+{
+ BYTE *src;
+ UINT i, j, scale;
+
+ *width = 256;
+ *height = 256;
+ *stride = (*width * 3 + 3) & ~3;
+ trace("width %d, height %d, stride %d\n", *width, *height, *stride);
+
+ src = HeapAlloc(GetProcessHeap(), 0, *stride * *height);
+
+ scale = 256 / *width;
+ if (!scale) scale = 1;
+
+ for (i = 0; i < *height; i++)
+ {
+ for (j = 0; j < *width; j++)
+ {
+ src[i * *stride + j*3 + 0] = scale * i;
+ src[i * *stride + j*3 + 1] = scale * (255 - (i+j)/2);
+ src[i * *stride + j*3 + 2] = scale * j;
+ }
+ }
+
+ return src;
+}
+
+static void test_palette_from_bitmap(void)
+{
+ HRESULT hr;
+ BYTE *data;
+ IWICBitmap *bitmap;
+ IWICPalette *palette;
+ WICBitmapPaletteType type;
+ UINT width, height, stride, count, ret;
+ WICColor color[257];
+
+ data = init_bitmap(&width, &height, &stride);
+
+ hr = IWICImagingFactory_CreateBitmapFromMemory(factory, width, height, &GUID_WICPixelFormat24bppRGB,
+ stride, stride * height, data, &bitmap);
+ ok(hr == S_OK, "CreateBitmapFromMemory error %#x\n", hr);
+
+ hr = IWICImagingFactory_CreatePalette(factory, &palette);
+ ok(hr == S_OK, "CreatePalette error %#x\n", hr);
+
+ hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 0, FALSE);
+todo_wine
+ ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
+
+ hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 1, FALSE);
+todo_wine
+ ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
+
+ hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 257, FALSE);
+todo_wine
+ ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
+
+ hr = IWICPalette_InitializeFromBitmap(palette, NULL, 16, FALSE);
+todo_wine
+ ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
+
+ hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 2, FALSE);
+todo_wine
+ ok(hr == S_OK, "InitializeFromBitmap error %#x\n", hr);
+if (hr == S_OK)
+{
+ hr = IWICPalette_GetColorCount(palette, &count);
+ ok(hr == S_OK, "GetColorCount error %#x\n", hr);
+ ok(count == 2, "expected 2, got %u\n", count);
+}
+
+ hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 2, TRUE);
+todo_wine
+ ok(hr == S_OK, "InitializeFromBitmap error %#x\n", hr);
+if (hr == S_OK)
+{
+ count = 0;
+ hr = IWICPalette_GetColorCount(palette, &count);
+ ok(hr == S_OK, "GetColorCount error %#x\n", hr);
+ ok(count == 2, "expected 2, got %u\n", count);
+}
+
+ /* without trasparent color */
+ hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 16, FALSE);
+todo_wine
+ ok(hr == S_OK, "InitializeFromBitmap error %#x\n", hr);
+if (hr == S_OK)
+{
+ type = -1;
+ hr = IWICPalette_GetType(palette, &type);
+ ok(hr == S_OK, "GetType error %#x\n", hr);
+ ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %#x\n", type);
+ count = 0;
+ hr = IWICPalette_GetColorCount(palette, &count);
+ ok(hr == S_OK, "GetColorCount error %#x\n", hr);
+ ok(count == 16, "expected 16, got %u\n", count);
+ memset(color, 0, sizeof(color));
+ hr = IWICPalette_GetColors(palette, count, color, &ret);
+ ok(hr == S_OK, "GetColors error %#x\n", hr);
+ ok(ret == count, "expected %u, got %u\n", count, ret);
+ ok(color[count - 1] != 0, "expected !0, got %08x\n", color[count - 1]);
+}
+
+ /* with trasparent color */
+ hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 16, TRUE);
+todo_wine
+ ok(hr == S_OK, "InitializeFromBitmap error %#x\n", hr);
+if (hr == S_OK)
+{
+ type = -1;
+ hr = IWICPalette_GetType(palette, &type);
+ ok(hr == S_OK, "GetType error %#x\n", hr);
+ ok(type == WICBitmapPaletteTypeCustom, "expected WICBitmapPaletteTypeCustom, got %#x\n", type);
+ count = 0;
+ hr = IWICPalette_GetColorCount(palette, &count);
+ ok(hr == S_OK, "GetColorCount error %#x\n", hr);
+ ok(count == 16, "expected 16, got %u\n", count);
+ memset(color, 0xff, sizeof(color));
+ hr = IWICPalette_GetColors(palette, count, color, &ret);
+ ok(hr == S_OK, "GetColors error %#x\n", hr);
+ ok(ret == count, "expected %u, got %u\n", count, ret);
+ ok(color[count - 1] == 0, "expected 0, got %08x\n", color[count - 1]);
+}
+
+ IWICPalette_Release(palette);
+ IWICBitmap_Release(bitmap);
+
+ HeapFree(GetProcessHeap(), 0, data);
}
START_TEST(palette)
{
+ HRESULT hr;
+
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IWICImagingFactory, (void **)&factory);
+ ok(hr == S_OK, "CoCreateInstance error %#x\n", hr);
+
test_custom_palette();
test_predefined_palette();
+ test_palette_from_bitmap();
+
+ IWICImagingFactory_Release(factory);
CoUninitialize();
}
--
2.9.0