ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 2016
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
15 participants
317 discussions
Start a n
N
ew thread
[akhaldi] 73310: [XINPUT1_3_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 23:29:18 2016 New Revision: 73310 URL:
http://svn.reactos.org/svn/reactos?rev=73310&view=rev
Log: [XINPUT1_3_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/rostests/winetests/xinput1_3/xinput.c Modified: trunk/rostests/winetests/xinput1_3/xinput.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/xinput1_3/xinpu…
============================================================================== --- trunk/rostests/winetests/xinput1_3/xinput.c [iso-8859-1] (original) +++ trunk/rostests/winetests/xinput1_3/xinput.c [iso-8859-1] Thu Nov 17 23:29:18 2016 @@ -24,6 +24,7 @@ #include "wine/test.h" static DWORD (WINAPI *pXInputGetState)(DWORD, XINPUT_STATE*); +static DWORD (WINAPI *pXInputGetStateEx)(DWORD, XINPUT_STATE_EX*); static DWORD (WINAPI *pXInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*); static DWORD (WINAPI *pXInputSetState)(DWORD, XINPUT_VIBRATION*); static void (WINAPI *pXInputEnable)(BOOL); @@ -46,14 +47,14 @@ result = pXInputSetState(controllerNum, &vibrator); ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, "XInputSetState failed with (%d)\n", result); - pXInputEnable(0); + if (pXInputEnable) pXInputEnable(0); vibrator.wLeftMotorSpeed = 65535; vibrator.wRightMotorSpeed = 65535; result = pXInputSetState(controllerNum, &vibrator); ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, "XInputSetState failed with (%d)\n", result); - pXInputEnable(1); + if (pXInputEnable) pXInputEnable(1); } result = pXInputSetState(XUSER_MAX_COUNT+1, &vibrator); @@ -62,41 +63,63 @@ static void test_get_state(void) { - - XINPUT_STATE controllerState; - DWORD controllerNum; - DWORD result; - - for(controllerNum=0; controllerNum < XUSER_MAX_COUNT; controllerNum++) - { - ZeroMemory(&controllerState, sizeof(XINPUT_STATE)); - - result = pXInputGetState(controllerNum, &controllerState); - ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, "XInputGetState failed with (%d)\n", result); - - if (ERROR_DEVICE_NOT_CONNECTED == result) - { - skip("Controller %d is not connected\n", controllerNum); - } - else - { + union + { + XINPUT_STATE state; + XINPUT_STATE_EX state_ex; + } xinput; + DWORD controllerNum, i; + DWORD result; + + for (i = 0; i < (pXInputGetStateEx ? 2 : 1); i++) + { + for (controllerNum = 0; controllerNum < XUSER_MAX_COUNT; controllerNum++) + { + ZeroMemory(&xinput, sizeof(xinput)); + + if (i == 0) + result = pXInputGetState(controllerNum, &xinput.state); + else + result = pXInputGetStateEx(controllerNum, &xinput.state_ex); + ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, + "%s failed with (%d)\n", i == 0 ? "XInputGetState" : "XInputGetStateEx", result); + + if (ERROR_DEVICE_NOT_CONNECTED == result) + { + skip("Controller %d is not connected\n", controllerNum); + continue; + } + trace("-- Results for controller %d --\n", controllerNum); - trace("XInputGetState: %d\n", result); - trace("State->dwPacketNumber: %d\n", controllerState.dwPacketNumber); + if (i == 0) + trace("XInputGetState: %d\n", result); + else + trace("XInputGetStateEx: %d\n", result); + trace("State->dwPacketNumber: %d\n", xinput.state.dwPacketNumber); trace("Gamepad Variables --\n"); - trace("Gamepad.wButtons: %#x\n", controllerState.Gamepad.wButtons); - trace("Gamepad.bLeftTrigger: 0x%08x\n", controllerState.Gamepad.bLeftTrigger); - trace("Gamepad.bRightTrigger: 0x%08x\n", controllerState.Gamepad.bRightTrigger); - trace("Gamepad.sThumbLX: %d\n", controllerState.Gamepad.sThumbLX); - trace("Gamepad.sThumbLY: %d\n", controllerState.Gamepad.sThumbLY); - trace("Gamepad.sThumbRX: %d\n", controllerState.Gamepad.sThumbRX); - trace("Gamepad.sThumbRY: %d\n", controllerState.Gamepad.sThumbRY); - } - } - - ZeroMemory(&controllerState, sizeof(XINPUT_STATE)); - result = pXInputGetState(XUSER_MAX_COUNT+1, &controllerState); + trace("Gamepad.wButtons: %#x\n", xinput.state.Gamepad.wButtons); + trace("Gamepad.bLeftTrigger: 0x%08x\n", xinput.state.Gamepad.bLeftTrigger); + trace("Gamepad.bRightTrigger: 0x%08x\n", xinput.state.Gamepad.bRightTrigger); + trace("Gamepad.sThumbLX: %d\n", xinput.state.Gamepad.sThumbLX); + trace("Gamepad.sThumbLY: %d\n", xinput.state.Gamepad.sThumbLY); + trace("Gamepad.sThumbRX: %d\n", xinput.state.Gamepad.sThumbRX); + trace("Gamepad.sThumbRY: %d\n", xinput.state.Gamepad.sThumbRY); + } + } + + result = pXInputGetState(XUSER_MAX_COUNT, &xinput.state); ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result); + + result = pXInputGetState(XUSER_MAX_COUNT+1, &xinput.state); + ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result); + if (pXInputGetStateEx) + { + result = pXInputGetStateEx(XUSER_MAX_COUNT, &xinput.state_ex); + ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result); + + result = pXInputGetStateEx(XUSER_MAX_COUNT+1, &xinput.state_ex); + ok(result == ERROR_BAD_ARGUMENTS, "XInputGetState returned (%d)\n", result); + } } static void test_get_keystroke(void) @@ -110,7 +133,8 @@ ZeroMemory(&keystroke, sizeof(XINPUT_KEYSTROKE)); result = pXInputGetKeystroke(controllerNum, XINPUT_FLAG_GAMEPAD, &keystroke); - ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, "XInputGetKeystroke failed with (%d)\n", result); + ok(result == ERROR_EMPTY || result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, + "XInputGetKeystroke failed with (%d)\n", result); if (ERROR_DEVICE_NOT_CONNECTED == result) { @@ -195,29 +219,70 @@ START_TEST(xinput) { + struct + { + const char *name; + int version; + } libs[] = { + { "xinput1_1.dll", 1 }, + { "xinput1_2.dll", 2 }, + { "xinput1_3.dll", 3 }, + { "xinput1_4.dll", 4 }, + { "xinput9_1_0.dll", 0 } /* legacy for XP/Vista */ + }; HMODULE hXinput; - hXinput = LoadLibraryA( "xinput1_3.dll" ); - - if (!hXinput) - { - win_skip("Could not load xinput1_3.dll\n"); - return; - } - - pXInputEnable = (void*)GetProcAddress(hXinput, "XInputEnable"); - pXInputSetState = (void*)GetProcAddress(hXinput, "XInputSetState"); - pXInputGetState = (void*)GetProcAddress(hXinput, "XInputGetState"); - pXInputGetKeystroke = (void*)GetProcAddress(hXinput, "XInputGetKeystroke"); - pXInputGetCapabilities = (void*)GetProcAddress(hXinput, "XInputGetCapabilities"); - pXInputGetDSoundAudioDeviceGuids = (void*)GetProcAddress(hXinput, "XInputGetDSoundAudioDeviceGuids"); - pXInputGetBatteryInformation = (void*)GetProcAddress(hXinput, "XInputGetBatteryInformation"); - - test_set_state(); - test_get_state(); - test_get_keystroke(); - test_get_capabilities(); - test_get_dsoundaudiodevice(); - test_get_batteryinformation(); - - FreeLibrary(hXinput); -} + void *pXInputGetStateEx_Ordinal; + int i; + + for (i = 0; i < sizeof(libs) / sizeof(libs[0]); i++) + { + hXinput = LoadLibraryA( libs[i].name ); + + if (!hXinput) + { + win_skip("Could not load %s\n", libs[i].name); + continue; + } + trace("Testing %s\n", libs[i].name); + + pXInputEnable = (void*)GetProcAddress(hXinput, "XInputEnable"); + pXInputSetState = (void*)GetProcAddress(hXinput, "XInputSetState"); + pXInputGetState = (void*)GetProcAddress(hXinput, "XInputGetState"); + pXInputGetStateEx = (void*)GetProcAddress(hXinput, "XInputGetStateEx"); /* Win >= 8 */ + pXInputGetStateEx_Ordinal = (void*)GetProcAddress(hXinput, (LPCSTR) 100); + pXInputGetKeystroke = (void*)GetProcAddress(hXinput, "XInputGetKeystroke"); + pXInputGetCapabilities = (void*)GetProcAddress(hXinput, "XInputGetCapabilities"); + pXInputGetDSoundAudioDeviceGuids = (void*)GetProcAddress(hXinput, "XInputGetDSoundAudioDeviceGuids"); + pXInputGetBatteryInformation = (void*)GetProcAddress(hXinput, "XInputGetBatteryInformation"); + + /* XInputGetStateEx may not be present by name, use ordinal in this case */ + if (!pXInputGetStateEx) + pXInputGetStateEx = pXInputGetStateEx_Ordinal; + + test_set_state(); + test_get_state(); + test_get_capabilities(); + + if (libs[i].version != 4) + test_get_dsoundaudiodevice(); + else + ok(!pXInputGetDSoundAudioDeviceGuids, "XInputGetDSoundAudioDeviceGuids exists in %s\n", libs[i].name); + + if (libs[i].version > 2) + { + test_get_keystroke(); + test_get_batteryinformation(); + ok(pXInputGetStateEx != NULL, "XInputGetStateEx not found in %s\n", libs[i].name); + } + else + { + ok(!pXInputGetKeystroke, "XInputGetKeystroke exists in %s\n", libs[i].name); + ok(!pXInputGetStateEx, "XInputGetStateEx exists in %s\n", libs[i].name); + ok(!pXInputGetBatteryInformation, "XInputGetBatteryInformation exists in %s\n", libs[i].name); + if (libs[i].version == 0) + ok(!pXInputEnable, "XInputEnable exists in %s\n", libs[i].name); + } + + FreeLibrary(hXinput); + } +}
8 years, 1 month
1
0
0
0
[akhaldi] 73309: [XINPUT1_3] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 23:28:41 2016 New Revision: 73309 URL:
http://svn.reactos.org/svn/reactos?rev=73309&view=rev
Log: [XINPUT1_3] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/reactos/dll/win32/xinput1_3/xinput1_3.spec trunk/reactos/dll/win32/xinput1_3/xinput1_3_main.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/xinput1_3/xinput1_3.spec URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/xinput1_3/xinput…
============================================================================== --- trunk/reactos/dll/win32/xinput1_3/xinput1_3.spec [iso-8859-1] (original) +++ trunk/reactos/dll/win32/xinput1_3/xinput1_3.spec [iso-8859-1] Thu Nov 17 23:28:41 2016 @@ -1,4 +1,4 @@ -1 stdcall DllMain(long long ptr) +1 stdcall -private DllMain(long long ptr) 2 stdcall XInputGetState(long ptr) 3 stdcall XInputSetState(long ptr) 4 stdcall XInputGetCapabilities(long long ptr) @@ -6,3 +6,4 @@ 6 stdcall XInputGetDSoundAudioDeviceGuids(long ptr ptr) 7 stdcall XInputGetBatteryInformation(long long ptr) 8 stdcall XInputGetKeystroke(long long ptr) +100 stdcall XInputGetStateEx(long ptr) Modified: trunk/reactos/dll/win32/xinput1_3/xinput1_3_main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/xinput1_3/xinput…
============================================================================== --- trunk/reactos/dll/win32/xinput1_3/xinput1_3_main.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/xinput1_3/xinput1_3_main.c [iso-8859-1] Thu Nov 17 23:28:41 2016 @@ -29,14 +29,20 @@ #include <xinput.h> +/* Not defined in the headers, used only by XInputGetStateEx */ +#define XINPUT_GAMEPAD_GUIDE 0x0400 + WINE_DEFAULT_DEBUG_CHANNEL(xinput); + +struct +{ + BOOL connected; +} controllers[XUSER_MAX_COUNT]; BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) { switch(reason) { - case DLL_WINE_PREATTACH: - return FALSE; /* prefer native version */ case DLL_PROCESS_ATTACH: DisableThreadLibraryCalls(inst); break; @@ -50,83 +56,107 @@ to the controllers. Setting to true will send the last vibration value (sent to XInputSetState) to the controller and allow messages to be sent */ - FIXME("(%d) Stub!\n", enable); + FIXME("(enable %d) Stub!\n", enable); } -DWORD WINAPI XInputSetState(DWORD dwUserIndex, XINPUT_VIBRATION* pVibration) +DWORD WINAPI XInputSetState(DWORD index, XINPUT_VIBRATION* vibration) { - FIXME("(%d %p) Stub!\n", dwUserIndex, pVibration); + FIXME("(index %u, vibration %p) Stub!\n", index, vibration); - if (dwUserIndex < XUSER_MAX_COUNT) - { + if (index >= XUSER_MAX_COUNT) + return ERROR_BAD_ARGUMENTS; + if (!controllers[index].connected) return ERROR_DEVICE_NOT_CONNECTED; - /* If controller exists then return ERROR_SUCCESS */ - } - return ERROR_BAD_ARGUMENTS; + + return ERROR_NOT_SUPPORTED; } -DWORD WINAPI DECLSPEC_HOTPATCH XInputGetState(DWORD dwUserIndex, XINPUT_STATE* pState) +DWORD WINAPI DECLSPEC_HOTPATCH XInputGetState(DWORD index, XINPUT_STATE* state) +{ + union + { + XINPUT_STATE state; + XINPUT_STATE_EX state_ex; + } xinput; + DWORD ret; + static int warn_once; + + if (!warn_once++) + FIXME("(index %u, state %p) Stub!\n", index, state); + + ret = XInputGetStateEx(index, &xinput.state_ex); + if (ret != ERROR_SUCCESS) + return ret; + + /* The main difference between this and the Ex version is the media guide button */ + xinput.state.Gamepad.wButtons &= ~XINPUT_GAMEPAD_GUIDE; + *state = xinput.state; + + return ERROR_SUCCESS; +} + +DWORD WINAPI DECLSPEC_HOTPATCH XInputGetStateEx(DWORD index, XINPUT_STATE_EX* state_ex) { static int warn_once; if (!warn_once++) - FIXME("(%u %p)\n", dwUserIndex, pState); + FIXME("(index %u, state %p) Stub!\n", index, state_ex); - if (dwUserIndex < XUSER_MAX_COUNT) - { + if (index >= XUSER_MAX_COUNT) + return ERROR_BAD_ARGUMENTS; + if (!controllers[index].connected) return ERROR_DEVICE_NOT_CONNECTED; - /* If controller exists then return ERROR_SUCCESS */ - } - return ERROR_BAD_ARGUMENTS; + + return ERROR_NOT_SUPPORTED; } -DWORD WINAPI XInputGetKeystroke(DWORD dwUserIndex, DWORD dwReserve, PXINPUT_KEYSTROKE pKeystroke) +DWORD WINAPI XInputGetKeystroke(DWORD index, DWORD reserved, PXINPUT_KEYSTROKE keystroke) { - FIXME("(%d %d %p) Stub!\n", dwUserIndex, dwReserve, pKeystroke); + FIXME("(index %u, reserved %u, keystroke %p) Stub!\n", index, reserved, keystroke); - if (dwUserIndex < XUSER_MAX_COUNT) - { + if (index >= XUSER_MAX_COUNT) + return ERROR_BAD_ARGUMENTS; + if (!controllers[index].connected) return ERROR_DEVICE_NOT_CONNECTED; - /* If controller exists then return ERROR_SUCCESS */ - } - return ERROR_BAD_ARGUMENTS; + + return ERROR_NOT_SUPPORTED; } -DWORD WINAPI XInputGetCapabilities(DWORD dwUserIndex, DWORD dwFlags, XINPUT_CAPABILITIES* pCapabilities) +DWORD WINAPI XInputGetCapabilities(DWORD index, DWORD flags, XINPUT_CAPABILITIES* capabilities) { static int warn_once; if (!warn_once++) - FIXME("(%d %d %p)\n", dwUserIndex, dwFlags, pCapabilities); + FIXME("(index %u, flags 0x%x, capabilities %p) Stub!\n", index, flags, capabilities); - if (dwUserIndex < XUSER_MAX_COUNT) - { + if (index >= XUSER_MAX_COUNT) + return ERROR_BAD_ARGUMENTS; + if (!controllers[index].connected) return ERROR_DEVICE_NOT_CONNECTED; - /* If controller exists then return ERROR_SUCCESS */ - } - return ERROR_BAD_ARGUMENTS; + + return ERROR_NOT_SUPPORTED; } -DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD dwUserIndex, GUID* pDSoundRenderGuid, GUID* pDSoundCaptureGuid) +DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD index, GUID* render_guid, GUID* capture_guid) { - FIXME("(%d %p %p) Stub!\n", dwUserIndex, pDSoundRenderGuid, pDSoundCaptureGuid); + FIXME("(index %u, render guid %p, capture guid %p) Stub!\n", index, render_guid, capture_guid); - if (dwUserIndex < XUSER_MAX_COUNT) - { + if (index >= XUSER_MAX_COUNT) + return ERROR_BAD_ARGUMENTS; + if (!controllers[index].connected) return ERROR_DEVICE_NOT_CONNECTED; - /* If controller exists then return ERROR_SUCCESS */ - } - return ERROR_BAD_ARGUMENTS; + + return ERROR_NOT_SUPPORTED; } -DWORD WINAPI XInputGetBatteryInformation(DWORD dwUserIndex, BYTE deviceType, XINPUT_BATTERY_INFORMATION* pBatteryInfo) +DWORD WINAPI XInputGetBatteryInformation(DWORD index, BYTE type, XINPUT_BATTERY_INFORMATION* battery) { - FIXME("(%d %u %p) Stub!\n", dwUserIndex, deviceType, pBatteryInfo); + FIXME("(index %u, type %u, battery %p) Stub!\n", index, type, battery); - if (dwUserIndex < XUSER_MAX_COUNT) - { + if (index >= XUSER_MAX_COUNT) + return ERROR_BAD_ARGUMENTS; + if (!controllers[index].connected) return ERROR_DEVICE_NOT_CONNECTED; - /* If controller exists then return ERROR_SUCCESS */ - } - return ERROR_BAD_ARGUMENTS; + + return ERROR_NOT_SUPPORTED; } Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Nov 17 23:28:41 2016 @@ -216,7 +216,7 @@ reactos/dll/win32/wuapi # Synced to WineStaging-1.9.11 reactos/dll/win32/xinput1_1 # Synced to WineStaging-1.9.11 reactos/dll/win32/xinput1_2 # Synced to WineStaging-1.9.11 -reactos/dll/win32/xinput1_3 # Synced to WineStaging-1.9.16 +reactos/dll/win32/xinput1_3 # Synced to WineStaging-1.9.23 reactos/dll/win32/xinput9_1_0 # Synced to WineStaging-1.9.11 reactos/dll/win32/xmllite # Synced to WineStaging-1.9.16
8 years, 1 month
1
0
0
0
[akhaldi] 73308: [PSDK] Update xinput.h. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 23:27:31 2016 New Revision: 73308 URL:
http://svn.reactos.org/svn/reactos?rev=73308&view=rev
Log: [PSDK] Update xinput.h. CORE-12409 Modified: trunk/reactos/sdk/include/psdk/xinput.h Modified: trunk/reactos/sdk/include/psdk/xinput.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/xinput.h?…
============================================================================== --- trunk/reactos/sdk/include/psdk/xinput.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/xinput.h [iso-8859-1] Thu Nov 17 23:27:31 2016 @@ -170,10 +170,26 @@ SHORT sThumbRY; } XINPUT_GAMEPAD, *PXINPUT_GAMEPAD; +typedef struct _XINPUT_GAMEPAD_EX { + WORD wButtons; + BYTE bLeftTrigger; + BYTE bRightTrigger; + SHORT sThumbLX; + SHORT sThumbLY; + SHORT sThumbRX; + SHORT sThumbRY; + DWORD dwPaddingReserved; +} XINPUT_GAMEPAD_EX, *PXINPUT_GAMEPAD_EX; + typedef struct _XINPUT_STATE { DWORD dwPacketNumber; XINPUT_GAMEPAD Gamepad; } XINPUT_STATE, *PXINPUT_STATE; + +typedef struct _XINPUT_STATE_EX { + DWORD dwPacketNumber; + XINPUT_GAMEPAD_EX Gamepad; +} XINPUT_STATE_EX, *PXINPUT_STATE_EX; /* * Defines the structure of how much vibration is set on both the @@ -232,6 +248,8 @@ DWORD WINAPI XInputGetDSoundAudioDeviceGuids(DWORD, GUID*, GUID*); DWORD WINAPI XInputGetBatteryInformation(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*); +DWORD WINAPI XInputGetStateEx(DWORD, XINPUT_STATE_EX*); + #ifdef __cplusplus } #endif
8 years, 1 month
1
0
0
0
[akhaldi] 73307: [WINTRUST_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 23:26:31 2016 New Revision: 73307 URL:
http://svn.reactos.org/svn/reactos?rev=73307&view=rev
Log: [WINTRUST_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/rostests/winetests/wintrust/softpub.c Modified: trunk/rostests/winetests/wintrust/softpub.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wintrust/softpu…
============================================================================== --- trunk/rostests/winetests/wintrust/softpub.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wintrust/softpub.c [iso-8859-1] Thu Nov 17 23:26:31 2016 @@ -177,16 +177,15 @@ ok(data.csSigners == 2, "Expected 2 signers, got %d\n", data.csSigners); ok(!memcmp(&data.pasSigners[1], &sgnr, sizeof(sgnr)), "Unexpected data in signer\n"); - /* This also adds, but the data aren't copied */ + /* This also adds, but the index is ignored */ sgnr.cbStruct = sizeof(DWORD); ret = funcs->pfnAddSgnr2Chain(&data, FALSE, 0, &sgnr); ok(ret, "pfnAddSgnr2Chain failed: %08x\n", GetLastError()); ok(data.csSigners == 3, "Expected 3 signers, got %d\n", data.csSigners); - ok(data.pasSigners[0].cbStruct == 0, "Unexpected data size %d\n", - data.pasSigners[0].cbStruct); - ok(data.pasSigners[0].sftVerifyAsOf.dwLowDateTime == 0, - "Unexpected verify time %d\n", - data.pasSigners[0].sftVerifyAsOf.dwLowDateTime); + sgnr.sftVerifyAsOf.dwLowDateTime = 0; + todo_wine + ok(!memcmp(&data.pasSigners[2], &sgnr, sizeof(sgnr)), + "Unexpected data in signer\n"); /* But too large a thing isn't added */ sgnr.cbStruct = sizeof(sgnr) + sizeof(DWORD); SetLastError(0xdeadbeef);
8 years, 1 month
1
0
0
0
[akhaldi] 73306: [WINTRUST] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 23:25:53 2016 New Revision: 73306 URL:
http://svn.reactos.org/svn/reactos?rev=73306&view=rev
Log: [WINTRUST] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/reactos/dll/win32/wintrust/register.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/wintrust/register.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/wintrust/registe…
============================================================================== --- trunk/reactos/dll/win32/wintrust/register.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/wintrust/register.c [iso-8859-1] Thu Nov 17 23:25:53 2016 @@ -796,7 +796,7 @@ lstrcatW(ProvKey, GuidString); Res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, ProvKey, 0, KEY_READ, &Key); - if (Res != ERROR_SUCCESS) goto error_close_key; + if (Res != ERROR_SUCCESS) return NULL; /* Read the $DLL entry */ Size = sizeof(DllName); Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Nov 17 23:25:53 2016 @@ -206,7 +206,7 @@ reactos/dll/win32/winmm/midimap # Forked at Wine-20050628 reactos/dll/win32/winmm/wavemap # Forked at Wine-20050628 reactos/dll/win32/winscard # Synced to WineStaging-1.9.11 -reactos/dll/win32/wintrust # Synced to WineStaging-1.9.11 +reactos/dll/win32/wintrust # Synced to WineStaging-1.9.23 reactos/dll/win32/wldap32 # Synced to WineStaging-1.9.11 reactos/dll/win32/wmi # Synced to WineStaging-1.9.11 reactos/dll/win32/wmiutils # Synced to WineStaging-1.9.11
8 years, 1 month
1
0
0
0
[akhaldi] 73305: [WINEMP3.ACM] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 23:24:47 2016 New Revision: 73305 URL:
http://svn.reactos.org/svn/reactos?rev=73305&view=rev
Log: [WINEMP3.ACM] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/reactos/dll/win32/winemp3.acm/mpegl3.c trunk/reactos/media/doc/README.WINE Modified: trunk/reactos/dll/win32/winemp3.acm/mpegl3.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/winemp3.acm/mpeg…
============================================================================== --- trunk/reactos/dll/win32/winemp3.acm/mpegl3.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/winemp3.acm/mpegl3.c [iso-8859-1] Thu Nov 17 23:24:47 2016 @@ -215,6 +215,7 @@ */ static LRESULT MPEG3_StreamOpen(PACMDRVSTREAMINSTANCE adsi) { + LRESULT error = MMSYSERR_NOTSUPPORTED; AcmMpeg3Data* aad; int err; @@ -238,6 +239,18 @@ adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEG) && adsi->pwfxDst->wFormatTag == WAVE_FORMAT_PCM) { + if (adsi->pwfxSrc->wFormatTag == WAVE_FORMAT_MPEGLAYER3) + { + MPEGLAYER3WAVEFORMAT *formatmp3 = (MPEGLAYER3WAVEFORMAT *)adsi->pwfxSrc; + + if (adsi->pwfxSrc->cbSize < MPEGLAYER3_WFX_EXTRA_BYTES || + formatmp3->wID != MPEGLAYER3_ID_MPEG) + { + error = ACMERR_NOTPOSSIBLE; + goto theEnd; + } + } + /* resampling or mono <=> stereo not available * MPEG3 algo only define 16 bit per sample output */ @@ -261,7 +274,7 @@ theEnd: HeapFree(GetProcessHeap(), 0, aad); adsi->dwDriver = 0L; - return MMSYSERR_NOTSUPPORTED; + return error; } /*********************************************************************** Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Thu Nov 17 23:24:47 2016 @@ -198,7 +198,7 @@ reactos/dll/win32/wbemprox # Synced to WineStaging-1.9.23 reactos/dll/win32/windowscodecs # Synced to WineStaging-1.9.23 reactos/dll/win32/windowscodecsext # Synced to WineStaging-1.9.11 -reactos/dll/win32/winemp3.acm # Synced to WineStaging-1.9.11 +reactos/dll/win32/winemp3.acm # Synced to WineStaging-1.9.23 reactos/dll/win32/wing32 # Synced to WineStaging-1.9.11 reactos/dll/win32/winhttp # Synced to WineStaging-1.9.16 reactos/dll/win32/wininet # Synced to WineStaging-1.9.16
8 years, 1 month
1
0
0
0
[akhaldi] 73304: [WINDOWSCODECS_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 23:23:38 2016 New Revision: 73304 URL:
http://svn.reactos.org/svn/reactos?rev=73304&view=rev
Log: [WINDOWSCODECS_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/rostests/winetests/windowscodecs/converter.c trunk/rostests/winetests/windowscodecs/palette.c trunk/rostests/winetests/windowscodecs/pngformat.c Modified: trunk/rostests/winetests/windowscodecs/converter.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/c…
============================================================================== --- trunk/rostests/winetests/windowscodecs/converter.c [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/converter.c [iso-8859-1] Thu Nov 17 23:23:38 2016 @@ -1,5 +1,6 @@ /* * Copyright 2009 Vincent Povirk + * Copyright 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 @@ -17,6 +18,7 @@ */ #include <stdarg.h> +#include <stdio.h> #include <math.h> #define WIN32_NO_STATUS @@ -28,9 +30,12 @@ #include <windef.h> #include <winbase.h> +#include <wingdi.h> #include <ole2.h> -#include <wincodec.h> +#include <wincodecsdk.h> #include <wine/test.h> + +static IWICImagingFactory *factory; typedef struct bitmap_data { const WICPixelFormatGUID *format; @@ -40,6 +45,7 @@ UINT height; double xres; double yres; + const struct bitmap_data *alt_data; } bitmap_data; typedef struct BitmapTestSrc { @@ -114,9 +120,30 @@ } static HRESULT WINAPI BitmapTestSrc_CopyPalette(IWICBitmapSource *iface, - IWICPalette *pIPalette) -{ - return E_NOTIMPL; + IWICPalette *palette) +{ + 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, @@ -206,15 +233,85 @@ HeapFree(GetProcessHeap(), 0, This); } -/* 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}; -static const BYTE bits_8bppGray_xp[] = { - 29,150,76,0, - 226,105,179,255}; - -static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSource *source, const char *name) +static BOOL compare_bits(const struct bitmap_data *expect, UINT buffersize, const BYTE *converted_bits) +{ + BOOL equal; + + if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppBGR)) + { + /* ignore the padding byte when comparing data */ + UINT i; + const DWORD *a=(const DWORD*)expect->bits, *b=(const DWORD*)converted_bits; + equal=TRUE; + for (i=0; i<(buffersize/4); i++) + if ((a[i]&0xffffff) != (b[i]&0xffffff)) + { + equal = FALSE; + break; + } + } + else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppGrayFloat)) + { + UINT i; + const float *a=(const float*)expect->bits, *b=(const float*)converted_bits; + equal=TRUE; + for (i=0; i<(buffersize/4); i++) + if (!near_equal(a[i], b[i])) + { + equal = FALSE; + break; + } + } + else if (IsEqualGUID(expect->format, &GUID_WICPixelFormatBlackWhite) || + IsEqualGUID(expect->format, &GUID_WICPixelFormat1bppIndexed)) + { + 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] && b[i] != 0xff /* BMP encoder B&W */) + { + equal = FALSE; + 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); + + if (!equal && expect->alt_data) + equal = compare_bits(expect->alt_data, buffersize, converted_bits); + + return equal; +} + +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; @@ -236,7 +333,7 @@ hr = IWICBitmapSource_GetPixelFormat(source, &dst_pixelformat); ok(SUCCEEDED(hr), "GetPixelFormat(%s) failed, hr=%x\n", name, hr); - ok(IsEqualGUID(&dst_pixelformat, expect->format), "got unexpected pixel format (%s)\n", name); + ok(IsEqualGUID(&dst_pixelformat, expect->format), "got unexpected pixel format %s (%s)\n", wine_dbgstr_guid(&dst_pixelformat), name); prc.X = 0; prc.Y = 0; @@ -247,143 +344,170 @@ 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); - if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppBGR)) - { - /* ignore the padding byte when comparing data */ - UINT i; - BOOL equal=TRUE; - const DWORD *a=(const DWORD*)expect->bits, *b=(const DWORD*)converted_bits; - for (i=0; i<(buffersize/4); i++) - if ((a[i]&0xffffff) != (b[i]&0xffffff)) - { - equal = FALSE; - break; - } - ok(equal, "unexpected pixel data (%s)\n", name); - } - else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppGrayFloat)) - { - BOOL equal=TRUE; - UINT i; - const float *a=(const float*)expect->bits, *b=(const float*)converted_bits; - for (i=0; i<(buffersize/4); i++) - if (!near_equal(a[i], b[i]) && !near_equal(bits_32bppGrayFloat_xp[i], b[i])) - { - equal = FALSE; - break; - } - - ok(equal, "unexpected pixel data (%s)\n", name); - } - else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat8bppGray)) - { - UINT i; - BOOL equal=TRUE; - const BYTE *a=(const BYTE*)expect->bits, *b=(const BYTE*)converted_bits; - for (i=0; i<buffersize; i++) - if (a[i] != b[i] && bits_8bppGray_xp[i] != b[i]) - { - equal = FALSE; - break; - } - ok(equal, "unexpected pixel data (%s)\n", name); - } - else - ok(memcmp(expect->bits, converted_bits, buffersize) == 0, "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); - if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppBGR)) - { - /* ignore the padding byte when comparing data */ - UINT i; - BOOL equal=TRUE; - const DWORD *a=(const DWORD*)expect->bits, *b=(const DWORD*)converted_bits; - for (i=0; i<(buffersize/4); i++) - if ((a[i]&0xffffff) != (b[i]&0xffffff)) - { - equal = FALSE; - break; - } - ok(equal, "unexpected pixel data with rc=NULL (%s)\n", name); - } - else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppGrayFloat)) - { - BOOL equal=TRUE; - UINT i; - const float *a=(const float*)expect->bits, *b=(const float*)converted_bits; - for (i=0; i<(buffersize/4); i++) - if (!near_equal(a[i], b[i]) && !near_equal(bits_32bppGrayFloat_xp[i], b[i])) - { - equal = FALSE; - break; - } - - ok(equal, "unexpected pixel data (%s)\n", name); - } - else if (IsEqualGUID(expect->format, &GUID_WICPixelFormat8bppGray)) - { - UINT i; - BOOL equal=TRUE; - const BYTE *a=(const BYTE*)expect->bits, *b=(const BYTE*)converted_bits; - for (i=0; i<buffersize; i++) - if (a[i] != b[i] && bits_8bppGray_xp[i] != b[i]) - { - equal = FALSE; - break; - } - ok(equal, "unexpected pixel data (%s)\n", name); - } - else - ok(memcmp(expect->bits, converted_bits, buffersize) == 0, "unexpected pixel data with rc=NULL (%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); } +/* some encoders (like BMP) require data to be 4-bytes aligned */ +static const BYTE bits_1bpp[] = { + 0x55,0x55,0x55,0x55, /*01010101*/ + 0xaa,0xaa,0xaa,0xaa}; /*10101010*/ +static const struct bitmap_data testdata_BlackWhite = { + &GUID_WICPixelFormatBlackWhite, 1, bits_1bpp, 32, 2, 96.0, 96.0}; +static const struct bitmap_data testdata_1bppIndexed = { + &GUID_WICPixelFormat1bppIndexed, 1, bits_1bpp, 32, 2, 96.0, 96.0}; + +/* some encoders (like BMP) require data to be 4-bytes aligned */ +static const BYTE bits_2bpp[] = { + 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, 32, 2, 96.0, 96.0}; + +/* some encoders (like BMP) require data to be 4-bytes aligned */ +static const BYTE bits_4bpp[] = { + 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, 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,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, 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.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, 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}; + &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,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, 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}; + &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) { @@ -395,11 +519,12 @@ 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); - - if (SUCCEEDED(hr)) - { - compare_bitmap_data(dst, dst_bitmap, name); + ok(hr == S_OK || + broken(hr == E_INVALIDARG) /* XP */, "WICConvertBitmapSource(%s) failed, hr=%x\n", name, hr); + + if (hr == S_OK) + { + compare_bitmap_data(src, dst, dst_bitmap, name); IWICBitmapSource_Release(dst_bitmap); } @@ -447,7 +572,7 @@ 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); } @@ -597,6 +722,394 @@ } } +static void load_stream(IUnknown *reader, IStream *stream) +{ + HRESULT hr; + IWICPersistStream *persist; +#ifdef WORDS_BIGENDIAN + DWORD persist_options = WICPersistOptionsBigEndian; +#else + DWORD persist_options = WICPersistOptionsLittleEndian; +#endif + + hr = IUnknown_QueryInterface(reader, &IID_IWICPersistStream, (void **)&persist); + ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr); + + hr = IWICPersistStream_LoadEx(persist, stream, NULL, persist_options); + ok(hr == S_OK, "LoadEx failed, hr=%x\n", hr); + + IWICPersistStream_Release(persist); +} + +static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format) +{ + HRESULT hr; + IWICMetadataReader *reader; + PROPVARIANT id, value; + struct + { + USHORT byte_order; + USHORT version; + ULONG dir_offset; + } tiff; + LARGE_INTEGER pos; + UINT count, i; + int width, height, bps, photo, samples, colormap; + struct + { + int id, *value; + } tag[] = + { + { 0x100, &width }, { 0x101, &height }, { 0x102, &bps }, + { 0x106, &photo }, { 0x115, &samples }, { 0x140, &colormap } + }; + + memset(&tiff, 0, sizeof(tiff)); + hr = IStream_Read(stream, &tiff, sizeof(tiff), NULL); + ok(hr == S_OK, "IStream_Read error %#x\n", hr); + ok(tiff.byte_order == MAKEWORD('I','I') || tiff.byte_order == MAKEWORD('M','M'), + "wrong TIFF byte order mark %02x\n", tiff.byte_order); + ok(tiff.version == 42, "wrong TIFF version %u\n", tiff.version); + + pos.QuadPart = tiff.dir_offset; + hr = IStream_Seek(stream, pos, SEEK_SET, NULL); + ok(hr == S_OK, "IStream_Seek error %#x\n", hr); + + hr = CoCreateInstance(&CLSID_WICIfdMetadataReader, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICMetadataReader, (void **)&reader); + ok(hr == S_OK, "CoCreateInstance error %#x\n", hr); + + load_stream((IUnknown *)reader, stream); + + hr = IWICMetadataReader_GetCount(reader, &count); + ok(hr == S_OK, "GetCount error %#x\n", hr); + ok(count != 0, "wrong count %u\n", count); + + for (i = 0; i < sizeof(tag)/sizeof(tag[0]); i++) + { + PropVariantInit(&id); + PropVariantInit(&value); + + id.vt = VT_UI2; + U(id).uiVal = tag[i].id; + hr = IWICMetadataReader_GetValue(reader, NULL, &id, &value); + ok(hr == S_OK || (tag[i].id == 0x140 && hr == WINCODEC_ERR_PROPERTYNOTFOUND), + "GetValue(%04x) error %#x\n", tag[i].id, hr); + if (hr == S_OK) + { + ok(value.vt == VT_UI2 || value.vt == VT_UI4 || value.vt == (VT_UI2 | VT_VECTOR), "wrong vt: %d\n", value.vt); + tag[i].value[0] = U(value).uiVal; + } + else + tag[i].value[0] = -1; + } + + IWICMetadataReader_Release(reader); + + if (IsEqualGUID(format, &GUID_WICPixelFormatBlackWhite)) + { + ok(width == 32, "wrong width %u\n", width); + ok(height == 2, "wrong height %u\n", height); + + ok(bps == 1, "wrong bps %d\n", bps); + ok(photo == 1, "wrong photometric %d\n", photo); + ok(samples == 1, "wrong samples %d\n", samples); + ok(colormap == -1, "wrong colormap %d\n", colormap); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed)) + { + ok(width == 32, "wrong width %u\n", width); + ok(height == 2, "wrong height %u\n", height); + + ok(bps == 1, "wrong bps %d\n", bps); + ok(photo == 3, "wrong photometric %d\n", photo); + ok(samples == 1, "wrong samples %d\n", samples); + ok(colormap == 6, "wrong colormap %d\n", colormap); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed)) + { + ok(width == 32, "wrong width %u\n", width); + ok(height == 2, "wrong height %u\n", height); + + ok(bps == 2, "wrong bps %d\n", bps); + ok(photo == 3, "wrong photometric %d\n", photo); + ok(samples == 1, "wrong samples %d\n", samples); + ok(colormap == 12, "wrong colormap %d\n", colormap); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed)) + { + ok(width == 32, "wrong width %u\n", width); + ok(height == 2, "wrong height %u\n", height); + + ok(bps == 4, "wrong bps %d\n", bps); + ok(photo == 3, "wrong photometric %d\n", photo); + ok(samples == 1, "wrong samples %d\n", samples); + ok(colormap == 48, "wrong colormap %d\n", colormap); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed)) + { + ok(width == 32, "wrong width %u\n", width); + ok(height == 2, "wrong height %u\n", height); + + ok(bps == 8, "wrong bps %d\n", bps); + ok(photo == 3, "wrong photometric %d\n", photo); + ok(samples == 1, "wrong samples %d\n", samples); + ok(colormap == 768, "wrong colormap %d\n", colormap); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat24bppBGR)) + { + ok(width == 32, "wrong width %u\n", width); + ok(height == 2, "wrong height %u\n", height); + + ok(bps == 3, "wrong bps %d\n", bps); + ok(photo == 2, "wrong photometric %d\n", photo); + ok(samples == 3, "wrong samples %d\n", samples); + ok(colormap == -1, "wrong colormap %d\n", colormap); + } + else + ok(0, "unknown TIFF pixel format %s\n", wine_dbgstr_guid(format)); +} + +static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format) +{ + HRESULT hr; + BITMAPFILEHEADER bfh; + BITMAPV5HEADER bih; + + hr = IStream_Read(stream, &bfh, sizeof(bfh), NULL); + ok(hr == S_OK, "IStream_Read error %#x\n", hr); + + ok(bfh.bfType == 0x4d42, "wrong BMP signature %02x\n", bfh.bfType); + ok(bfh.bfReserved1 == 0, "wrong bfReserved1 %02x\n", bfh.bfReserved1); + ok(bfh.bfReserved2 == 0, "wrong bfReserved2 %02x\n", bfh.bfReserved2); + + 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 %08x\n", bfh.bfOffBits); + + 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); + ok(bih.bV5BitCount == 1, "wrong BitCount %d\n", bih.bV5BitCount); + ok(bih.bV5ClrUsed == 256, "wrong ClrUsed %d\n", bih.bV5ClrUsed); + ok(bih.bV5ClrImportant == 256, "wrong ClrImportant %d\n", bih.bV5ClrImportant); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed)) + { + 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); + + ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes); + ok(bih.bV5BitCount == 2, "wrong BitCount %d\n", bih.bV5BitCount); + ok(bih.bV5ClrUsed == 256, "wrong ClrUsed %d\n", bih.bV5ClrUsed); + ok(bih.bV5ClrImportant == 256, "wrong ClrImportant %d\n", bih.bV5ClrImportant); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed)) + { + 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); + + ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes); + ok(bih.bV5BitCount == 4, "wrong BitCount %d\n", bih.bV5BitCount); + ok(bih.bV5ClrUsed == 256, "wrong ClrUsed %d\n", bih.bV5ClrUsed); + ok(bih.bV5ClrImportant == 256, "wrong ClrImportant %d\n", bih.bV5ClrImportant); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed)) + { + 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); + + ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes); + ok(bih.bV5BitCount == 8, "wrong BitCount %d\n", bih.bV5BitCount); + ok(bih.bV5ClrUsed == 256, "wrong ClrUsed %d\n", bih.bV5ClrUsed); + ok(bih.bV5ClrImportant == 256, "wrong ClrImportant %d\n", bih.bV5ClrImportant); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat32bppBGR)) + { + ok(bfh.bfOffBits == 0x0036, "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); + + ok(bih.bV5Planes == 1, "wrong Planes %d\n", bih.bV5Planes); + ok(bih.bV5BitCount == 32, "wrong BitCount %d\n", bih.bV5BitCount); + ok(bih.bV5ClrUsed == 0, "wrong ClrUsed %d\n", bih.bV5ClrUsed); + ok(bih.bV5ClrImportant == 0, "wrong ClrImportant %d\n", bih.bV5ClrImportant); + } + else + ok(0, "unknown BMP pixel format %s\n", wine_dbgstr_guid(format)); +} + +static unsigned be_uint(unsigned val) +{ + union + { + unsigned val; + char c[4]; + } u; + + u.val = val; + return (u.c[0] << 24) | (u.c[1] << 16) | (u.c[2] << 8) | u.c[3]; +} + +static void check_png_format(IStream *stream, const WICPixelFormatGUID *format) +{ + static const char png_sig[8] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a}; + static const char png_IHDR[8] = {0,0,0,0x0d,'I','H','D','R'}; + HRESULT hr; + struct + { + char png_sig[8]; + char ihdr_sig[8]; + unsigned width, height; + char bit_depth, color_type, compression, filter, interlace; + } png; + + memset(&png, 0, sizeof(png)); + hr = IStream_Read(stream, &png, sizeof(png), NULL); + ok(hr == S_OK, "IStream_Read error %#x\n", hr); + + ok(!memcmp(png.png_sig, png_sig, sizeof(png_sig)), "expected PNG signature\n"); + ok(!memcmp(png.ihdr_sig, png_IHDR, sizeof(png_IHDR)), "expected PNG IHDR\n"); + + if (IsEqualGUID(format, &GUID_WICPixelFormatBlackWhite)) + { + 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 == 1, "wrong bit_depth %d\n", png.bit_depth); + ok(png.color_type == 0, "wrong color_type %d\n", png.color_type); + ok(png.compression == 0, "wrong compression %d\n", png.compression); + ok(png.filter == 0, "wrong filter %d\n", png.filter); + ok(png.interlace == 0, "wrong interlace %d\n", png.interlace); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat1bppIndexed)) + { + 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 == 1, "wrong bit_depth %d\n", png.bit_depth); + ok(png.color_type == 3, "wrong color_type %d\n", png.color_type); + ok(png.compression == 0, "wrong compression %d\n", png.compression); + ok(png.filter == 0, "wrong filter %d\n", png.filter); + ok(png.interlace == 0, "wrong interlace %d\n", png.interlace); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat2bppIndexed)) + { + 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); + ok(png.color_type == 3, "wrong color_type %d\n", png.color_type); + ok(png.compression == 0, "wrong compression %d\n", png.compression); + ok(png.filter == 0, "wrong filter %d\n", png.filter); + ok(png.interlace == 0, "wrong interlace %d\n", png.interlace); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat4bppIndexed)) + { + 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); + ok(png.color_type == 3, "wrong color_type %d\n", png.color_type); + ok(png.compression == 0, "wrong compression %d\n", png.compression); + ok(png.filter == 0, "wrong filter %d\n", png.filter); + ok(png.interlace == 0, "wrong interlace %d\n", png.interlace); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat8bppIndexed)) + { + 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); + ok(png.color_type == 3, "wrong color_type %d\n", png.color_type); + ok(png.compression == 0, "wrong compression %d\n", png.compression); + ok(png.filter == 0, "wrong filter %d\n", png.filter); + ok(png.interlace == 0, "wrong interlace %d\n", png.interlace); + } + else if (IsEqualGUID(format, &GUID_WICPixelFormat24bppBGR)) + { + 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); + ok(png.color_type == 2, "wrong color_type %d\n", png.color_type); + ok(png.compression == 0, "wrong compression %d\n", png.compression); + ok(png.filter == 0, "wrong filter %d\n", png.filter); + ok(png.interlace == 0 || png.interlace == 1, "wrong interlace %d\n", png.interlace); + } + else + ok(0, "unknown PNG pixel format %s\n", wine_dbgstr_guid(format)); +} + +static void check_gif_format(IStream *stream, const WICPixelFormatGUID *format) +{ +#include "pshpack1.h" + struct logical_screen_descriptor + { + char signature[6]; + USHORT width; + USHORT height; + BYTE packed; + /* global_color_table_flag : 1; + * color_resolution : 3; + * sort_flag : 1; + * global_color_table_size : 3; + */ + BYTE background_color_index; + BYTE pixel_aspect_ratio; + } lsd; +#include "poppack.h" + UINT color_resolution; + HRESULT hr; + + memset(&lsd, 0, sizeof(lsd)); + hr = IStream_Read(stream, &lsd, sizeof(lsd), NULL); + ok(hr == S_OK, "IStream_Read error %#x\n", hr); + + ok(!memcmp(lsd.signature, "GIF89a", 6), "wrong GIF signature %.6s\n", lsd.signature); + + ok(lsd.width == 32, "wrong width %u\n", lsd.width); + ok(lsd.height == 2, "wrong height %u\n", lsd.height); + color_resolution = 1 << (((lsd.packed >> 4) & 0x07) + 1); + ok(color_resolution == 256, "wrong color resolution %u\n", color_resolution); + ok(lsd.pixel_aspect_ratio == 0, "wrong pixel_aspect_ratio %u\n", lsd.pixel_aspect_ratio); +} + +static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WICPixelFormatGUID *format) +{ + HRESULT hr; + LARGE_INTEGER pos; + + pos.QuadPart = 0; + hr = IStream_Seek(stream, pos, SEEK_SET, (ULARGE_INTEGER *)&pos); + ok(hr == S_OK, "IStream_Seek error %#x\n", hr); + + if (IsEqualGUID(encoder, &CLSID_WICPngEncoder)) + check_png_format(stream, format); + else if (IsEqualGUID(encoder, &CLSID_WICBmpEncoder)) + check_bmp_format(stream, format); + else if (IsEqualGUID(encoder, &CLSID_WICTiffEncoder)) + check_tiff_format(stream, format); + else if (IsEqualGUID(encoder, &CLSID_WICGifEncoder)) + check_gif_format(stream, format); + else + ok(0, "unknown encoder %s\n", wine_dbgstr_guid(encoder)); + + hr = IStream_Seek(stream, pos, SEEK_SET, NULL); + ok(hr == S_OK, "IStream_Seek error %#x\n", hr); +} + struct setting { const WCHAR *name; PROPBAG2_TYPE type; @@ -606,7 +1119,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* clsid_encoder, const struct bitmap_data **dsts, const CLSID *clsid_decoder, WICRect *rc, - const struct setting *settings, const char *name) + const struct setting *settings, const char *name, IWICPalette *palette) { HRESULT hr; IWICBitmapEncoder *encoder; @@ -622,7 +1135,7 @@ hr = CoCreateInstance(clsid_encoder, NULL, CLSCTX_INPROC_SERVER, &IID_IWICBitmapEncoder, (void**)&encoder); - ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr); + ok(SUCCEEDED(hr), "CoCreateInstance(%s) failed, hr=%x\n", wine_dbgstr_guid(clsid_encoder), hr); if (SUCCEEDED(hr)) { hglobal = GlobalAlloc(GMEM_MOVEABLE, 0); @@ -635,8 +1148,24 @@ if (hglobal && SUCCEEDED(hr)) { + if (palette) + { + hr = IWICBitmapEncoder_SetPalette(encoder, palette); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "wrong error %#x (%s)\n", hr, name); + } + hr = IWICBitmapEncoder_Initialize(encoder, stream, WICBitmapEncoderNoCache); ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr); + + if (palette) + { + hr = IWICBitmapEncoder_SetPalette(encoder, palette); + if (IsEqualGUID(clsid_encoder, &CLSID_WICGifEncoder)) + ok(hr == S_OK, "SetPalette failed, hr=%#x\n", hr); + else + ok(hr == WINCODEC_ERR_UNSUPPORTEDOPERATION, "wrong error %#x\n", hr); + hr = S_OK; + } i=0; while (SUCCEEDED(hr) && srcs[i]) @@ -671,28 +1200,64 @@ } } + if (palette) + { + hr = IWICBitmapFrameEncode_SetPalette(frameencode, palette); + ok(hr == WINCODEC_ERR_NOTINITIALIZED, "wrong error %#x\n", hr); + } + hr = IWICBitmapFrameEncode_Initialize(frameencode, options); ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr); memcpy(&pixelformat, srcs[i]->format, sizeof(GUID)); hr = IWICBitmapFrameEncode_SetPixelFormat(frameencode, &pixelformat); ok(SUCCEEDED(hr), "SetPixelFormat failed, hr=%x\n", hr); - ok(IsEqualGUID(&pixelformat, srcs[i]->format), "SetPixelFormat changed the format\n"); + ok(IsEqualGUID(&pixelformat, dsts[i]->format) || + broken(IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)) || + broken(IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2 && IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)), + "SetPixelFormat changed the format to %s (%s)\n", wine_dbgstr_guid(&pixelformat), name); hr = IWICBitmapFrameEncode_SetSize(frameencode, srcs[i]->width, srcs[i]->height); ok(SUCCEEDED(hr), "SetSize failed, hr=%x\n", hr); + + if (palette) + { + WICColor colors[256]; + + hr = IWICBitmapFrameEncode_SetPalette(frameencode, palette); + ok(SUCCEEDED(hr), "SetPalette failed, hr=%x (%s)\n", hr, name); + + /* trash the assigned palette */ + memset(colors, 0, sizeof(colors)); + hr = IWICPalette_InitializeCustom(palette, colors, 256); + ok(hr == S_OK, "InitializeCustom error %#x\n", hr); + } hr = IWICBitmapFrameEncode_WriteSource(frameencode, &src_obj->IWICBitmapSource_iface, rc); if (rc && (rc->Width <= 0 || rc->Height <= 0)) { /* WriteSource fails but WriteSource_Proxy succeeds. */ - ok(hr == E_INVALIDARG, "WriteSource failed, hr=%x (%s)\n", hr, name); + ok(hr == E_INVALIDARG, "WriteSource should fail, hr=%x (%s)\n", hr, name); hr = IWICBitmapFrameEncode_WriteSource_Proxy(frameencode, &src_obj->IWICBitmapSource_iface, rc); + ok(SUCCEEDED(hr), "WriteSource_Proxy failed, %dx%d, hr=%x (%s)\n", rc->Width, rc->Height, hr, name); } - ok(SUCCEEDED(hr), "WriteSource failed, hr=%x (%s)\n", hr, name); - - hr = IWICBitmapFrameEncode_Commit(frameencode); - ok(SUCCEEDED(hr), "Commit failed, hr=%x\n", hr); + else + { + if (rc) + ok(SUCCEEDED(hr), "WriteSource(%dx%d) failed, hr=%x (%s)\n", rc->Width, rc->Height, hr, name); + else + ok(hr == S_OK || + broken(hr == E_INVALIDARG && IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && srcs[i]->bpp == 2) /* XP */ || + broken(hr == E_INVALIDARG && IsEqualGUID(clsid_encoder, &CLSID_WICTiffEncoder) && srcs[i]->bpp == 2) /* XP */ || + broken(hr == E_INVALIDARG && IsEqualGUID(clsid_encoder, &CLSID_WICBmpEncoder) && IsEqualGUID(srcs[i]->format, &GUID_WICPixelFormatBlackWhite)) /* XP */, + "WriteSource(NULL) failed, hr=%x (%s)\n", hr, name); + } + + if (SUCCEEDED(hr)) + { + hr = IWICBitmapFrameEncode_Commit(frameencode); + ok(SUCCEEDED(hr), "Commit failed, hr=%x (%s)\n", hr, name); + } IWICBitmapFrameEncode_Release(frameencode); IPropertyBag2_Release(options); @@ -707,6 +1272,9 @@ { hr = IWICBitmapEncoder_Commit(encoder); ok(SUCCEEDED(hr), "Commit failed, hr=%x\n", hr); + + if (IsEqualGUID(&pixelformat, dsts[0]->format)) + check_bitmap_format(stream, clsid_encoder, dsts[0]->format); } if (SUCCEEDED(hr)) @@ -718,18 +1286,135 @@ if (SUCCEEDED(hr)) { + IWICPalette *frame_palette; + + hr = IWICImagingFactory_CreatePalette(factory, &frame_palette); + ok(hr == S_OK, "CreatePalette error %#x\n", hr); + + hr = IWICBitmapDecoder_CopyPalette(decoder, frame_palette); + if (IsEqualGUID(clsid_decoder, &CLSID_WICGifDecoder)) + ok(hr == WINCODEC_ERR_WRONGSTATE, "wrong error %#x\n", hr); + else + ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "wrong error %#x\n", hr); + hr = IWICBitmapDecoder_Initialize(decoder, stream, WICDecodeMetadataCacheOnDemand); ok(SUCCEEDED(hr), "Initialize failed, hr=%x\n", hr); + hr = IWICBitmapDecoder_CopyPalette(decoder, frame_palette); + if (IsEqualGUID(clsid_decoder, &CLSID_WICGifDecoder)) + ok(hr == S_OK || broken(hr == WINCODEC_ERR_FRAMEMISSING) /* XP */, "CopyPalette failed, hr=%#x\n", hr); + else + ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "wrong error %#x\n", hr); + + hr = S_OK; i=0; while (SUCCEEDED(hr) && dsts[i]) { hr = IWICBitmapDecoder_GetFrame(decoder, i, &framedecode); - ok(SUCCEEDED(hr), "GetFrame failed, hr=%x\n", hr); + ok(SUCCEEDED(hr), "GetFrame failed, hr=%x (%s)\n", hr, name); if (SUCCEEDED(hr)) { - compare_bitmap_data(dsts[i], (IWICBitmapSource*)framedecode, name); + 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); + + hr = IWICBitmapFrameDecode_CopyPalette(framedecode, frame_palette); + if (winetest_debug > 1) + trace("%s, bpp %d, %s, hr %#x\n", name, dsts[i]->bpp, wine_dbgstr_guid(dsts[i]->format), hr); + if (dsts[i]->bpp > 8 || IsEqualGUID(dsts[i]->format, &GUID_WICPixelFormatBlackWhite)) + ok(hr == WINCODEC_ERR_PALETTEUNAVAILABLE, "wrong error %#x\n", hr); + else + { + UINT count, ret; + WICColor colors[256]; + + ok(hr == S_OK, "CopyPalette error %#x (%s)\n", hr, name); + + count = 0; + hr = IWICPalette_GetColorCount(frame_palette, &count); + ok(hr == S_OK, "GetColorCount error %#x\n", hr); + + memset(colors, 0, sizeof(colors)); + ret = 0; + hr = IWICPalette_GetColors(frame_palette, count, colors, &ret); + ok(hr == S_OK, "GetColors error %#x\n", hr); + ok(ret == count, "expected %u, got %u\n", count, ret); + if (IsEqualGUID(clsid_decoder, &CLSID_WICPngDecoder)) + { + /* Newer libpng versions don't accept larger palettes than the declared + * bit depth, so we need to generate the palette of the correct length. + */ + ok(count == 256 || (dsts[i]->bpp == 1 && count == 2) || + (dsts[i]->bpp == 2 && count == 4) || (dsts[i]->bpp == 4 && count == 16), + "expected 256, got %u (%s)\n", count, name); + + ok(colors[0] == 0x11111111, "got %08x (%s)\n", colors[0], name); + ok(colors[1] == 0x22222222, "got %08x (%s)\n", colors[1], name); + if (count > 2) + { + ok(colors[2] == 0x33333333, "got %08x (%s)\n", colors[2], name); + ok(colors[3] == 0x44444444, "got %08x (%s)\n", colors[3], name); + if (count > 4) + { + ok(colors[4] == 0x55555555, "got %08x (%s)\n", colors[4], name); + ok(colors[5] == 0, "got %08x (%s)\n", colors[5], name); + } + } + } + else if (IsEqualGUID(clsid_decoder, &CLSID_WICBmpDecoder) || + IsEqualGUID(clsid_decoder, &CLSID_WICTiffDecoder) || + IsEqualGUID(clsid_decoder, &CLSID_WICGifDecoder)) + { + if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormatBlackWhite) || + IsEqualGUID(&pixelformat, &GUID_WICPixelFormat8bppIndexed)) + { + ok(count == 256, "expected 256, got %u (%s)\n", count, name); + + ok(colors[0] == 0xff111111, "got %08x (%s)\n", colors[0], name); + ok(colors[1] == 0xff222222, "got %08x (%s)\n", colors[1], name); + ok(colors[2] == 0xff333333, "got %08x (%s)\n", colors[2], name); + ok(colors[3] == 0xff444444, "got %08x (%s)\n", colors[3], name); + 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(&pixelformat, &GUID_WICPixelFormat2bppIndexed)) + { + ok(count == 4, "expected 4, got %u (%s)\n", count, name); + + ok(colors[0] == 0xff111111, "got %08x (%s)\n", colors[0], name); + ok(colors[1] == 0xff222222, "got %08x (%s)\n", colors[1], name); + ok(colors[2] == 0xff333333, "got %08x (%s)\n", colors[2], name); + ok(colors[3] == 0xff444444, "got %08x (%s)\n", colors[3], name); + } + else if (IsEqualGUID(&pixelformat, &GUID_WICPixelFormat4bppIndexed)) + { + ok(count == 16, "expected 16, got %u (%s)\n", count, name); + + ok(colors[0] == 0xff111111, "got %08x (%s)\n", colors[0], name); + ok(colors[1] == 0xff222222, "got %08x (%s)\n", colors[1], name); + ok(colors[2] == 0xff333333, "got %08x (%s)\n", colors[2], name); + ok(colors[3] == 0xff444444, "got %08x (%s)\n", colors[3], name); + ok(colors[4] == 0xff555555, "got %08x (%s)\n", colors[4], name); + ok(colors[5] == 0xff000000, "got %08x (%s)\n", colors[5], name); + } + else + { + ok(count == 2, "expected 2, got %u (%s)\n", count, name); + + ok(colors[0] == 0xff111111, "got %08x (%s)\n", colors[0], name); + ok(colors[1] == 0xff222222, "got %08x (%s)\n", colors[1], name); + } + } + else + { + ok(count == 2, "expected 2, got %u (%s)\n", count, name); + + ok(colors[0] == 0xff111111, "got %08x\n", colors[0]); + ok(colors[1] == 0xff222222, "got %08x\n", colors[1]); + } + } IWICBitmapFrameDecode_Release(framedecode); } @@ -737,6 +1422,7 @@ i++; } + IWICPalette_Release(frame_palette); IWICBitmapDecoder_Release(decoder); } @@ -752,13 +1438,31 @@ { const struct bitmap_data *srcs[2]; const struct bitmap_data *dsts[2]; + WICColor colors[256]; + IWICPalette *palette; + HRESULT hr; + + hr = IWICImagingFactory_CreatePalette(factory, &palette); + ok(hr == S_OK, "CreatePalette error %#x\n", hr); + + memset(colors, 0, sizeof(colors)); + colors[0] = 0x11111111; + colors[1] = 0x22222222; + colors[2] = 0x33333333; + colors[3] = 0x44444444; + colors[4] = 0x55555555; + /* TIFF decoder fails to decode a 8bpp frame if palette has less than 256 colors */ + hr = IWICPalette_InitializeCustom(palette, colors, 256); + ok(hr == S_OK, "InitializeCustom error %#x\n", hr); srcs[0] = src; srcs[1] = NULL; dsts[0] = dst; dsts[1] = NULL; - test_multi_encoder(srcs, clsid_encoder, dsts, clsid_decoder, NULL, NULL, name); + test_multi_encoder(srcs, clsid_encoder, dsts, clsid_decoder, NULL, NULL, name, palette); + + IWICPalette_Release(palette); } static void test_encoder_rects(void) @@ -774,23 +1478,23 @@ 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"); + test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects full", NULL); rc.Width = 0; - test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects width=0"); + test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects width=0", NULL); rc.Width = -1; - test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects width=-1"); - - rc.Width = 4; + test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects width=-1", NULL); + + rc.Width = 32; rc.Height = 0; - test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects height=0"); + test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects height=0", NULL); rc.Height = -1; - test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects height=-1"); + test_multi_encoder(srcs, &CLSID_WICTiffEncoder, dsts, &CLSID_WICTiffDecoder, &rc, NULL, "test_encoder_rects height=-1", NULL); } static const struct bitmap_data *multiple_frames[3] = { @@ -807,9 +1511,184 @@ {NULL} }; +static void test_converter_8bppIndexed(void) +{ + HRESULT hr; + BitmapTestSrc *src_obj; + IWICFormatConverter *converter; + IWICPalette *palette; + UINT count, i; + BYTE buf[32 * 2 * 3]; /* enough to hold 32x2 24bppBGR data */ + + CreateTestBitmap(&testdata_24bppBGR, &src_obj); + + hr = IWICImagingFactory_CreatePalette(factory, &palette); + ok(hr == S_OK, "CreatePalette error %#x\n", hr); + count = 0xdeadbeef; + hr = IWICPalette_GetColorCount(palette, &count); + ok(hr == S_OK, "GetColorCount error %#x\n", hr); + ok(count == 0, "expected 0, got %u\n", count); + + /* NULL palette + Custom type*/ + hr = IWICImagingFactory_CreateFormatConverter(factory, &converter); + ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr); + hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface, + &GUID_WICPixelFormat24bppBGR, WICBitmapDitherTypeNone, + NULL, 0.0, WICBitmapPaletteTypeCustom); + ok(hr == S_OK, "Initialize error %#x\n", hr); + hr = IWICFormatConverter_CopyPalette(converter, palette); + ok(hr == 0xdeadbeef, "unexpected error %#x\n", hr); + hr = IWICFormatConverter_CopyPixels(converter, NULL, 32 * 3, sizeof(buf), buf); + ok(hr == S_OK, "CopyPixels error %#x\n", hr); + IWICFormatConverter_Release(converter); + + /* NULL palette + Custom type*/ + hr = IWICImagingFactory_CreateFormatConverter(factory, &converter); + ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr); + hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface, + &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone, + NULL, 0.0, WICBitmapPaletteTypeCustom); + ok(hr == E_INVALIDARG, "unexpected error %#x\n", hr); + hr = IWICFormatConverter_CopyPalette(converter, palette); + ok(hr == WINCODEC_ERR_WRONGSTATE, "unexpected error %#x\n", hr); + hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf); + ok(hr == WINCODEC_ERR_WRONGSTATE, "unexpected error %#x\n", hr); + IWICFormatConverter_Release(converter); + + /* empty palette + Custom type*/ + hr = IWICImagingFactory_CreateFormatConverter(factory, &converter); + ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr); + hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface, + &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone, + palette, 0.0, WICBitmapPaletteTypeCustom); + ok(hr == S_OK, "Initialize error %#x\n", hr); + hr = IWICFormatConverter_CopyPalette(converter, palette); + ok(hr == S_OK, "CopyPalette error %#x\n", hr); + count = 0xdeadbeef; + hr = IWICPalette_GetColorCount(palette, &count); + ok(hr == S_OK, "GetColorCount error %#x\n", hr); + ok(count == 0, "expected 0, got %u\n", count); + memset(buf, 0xaa, sizeof(buf)); + hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf); + ok(hr == S_OK, "CopyPixels error %#x\n", hr); + count = 0; + for (i = 0; i < 32 * 2; i++) + if (buf[i] != 0) count++; + ok(count == 0, "expected 0\n"); + IWICFormatConverter_Release(converter); + + /* NULL palette + Predefined type*/ + hr = IWICImagingFactory_CreateFormatConverter(factory, &converter); + ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr); + hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface, + &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone, + NULL, 0.0, WICBitmapPaletteTypeFixedGray16); + ok(hr == S_OK, "Initialize error %#x\n", hr); + hr = IWICFormatConverter_CopyPalette(converter, palette); + ok(hr == S_OK, "CopyPalette error %#x\n", hr); + count = 0xdeadbeef; + hr = IWICPalette_GetColorCount(palette, &count); + ok(hr == S_OK, "GetColorCount error %#x\n", hr); + ok(count == 16, "expected 16, got %u\n", count); + hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf); + ok(hr == S_OK, "CopyPixels error %#x\n", hr); + count = 0; + for (i = 0; i < 32 * 2; i++) + if (buf[i] != 0) count++; + ok(count != 0, "expected != 0\n"); + IWICFormatConverter_Release(converter); + + /* not empty palette + Predefined type*/ + hr = IWICImagingFactory_CreateFormatConverter(factory, &converter); + ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr); + hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface, + &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone, + palette, 0.0, WICBitmapPaletteTypeFixedHalftone64); + ok(hr == S_OK, "Initialize error %#x\n", hr); + hr = IWICFormatConverter_CopyPalette(converter, palette); + ok(hr == S_OK, "CopyPalette error %#x\n", hr); + count = 0xdeadbeef; + hr = IWICPalette_GetColorCount(palette, &count); + ok(hr == S_OK, "GetColorCount error %#x\n", hr); + ok(count == 16, "expected 16, got %u\n", count); + hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf); + ok(hr == S_OK, "CopyPixels error %#x\n", hr); + count = 0; + for (i = 0; i < 32 * 2; i++) + if (buf[i] != 0) count++; + ok(count != 0, "expected != 0\n"); + IWICFormatConverter_Release(converter); + + /* not empty palette + MedianCut type*/ + hr = IWICImagingFactory_CreateFormatConverter(factory, &converter); + ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr); + hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface, + &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone, + palette, 0.0, WICBitmapPaletteTypeMedianCut); + ok(hr == S_OK, "Initialize error %#x\n", hr); + hr = IWICFormatConverter_CopyPalette(converter, palette); + ok(hr == S_OK, "CopyPalette error %#x\n", hr); + count = 0xdeadbeef; + hr = IWICPalette_GetColorCount(palette, &count); + ok(hr == S_OK, "GetColorCount error %#x\n", hr); + ok(count == 16, "expected 16, got %u\n", count); + hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf); + ok(hr == S_OK, "CopyPixels error %#x\n", hr); + count = 0; + for (i = 0; i < 32 * 2; i++) + if (buf[i] != 0) count++; + ok(count != 0, "expected != 0\n"); + IWICFormatConverter_Release(converter); + + /* NULL palette + MedianCut type*/ + hr = IWICImagingFactory_CreateFormatConverter(factory, &converter); + ok(hr == S_OK, "CreateFormatConverter error %#x\n", hr); + hr = IWICFormatConverter_Initialize(converter, &src_obj->IWICBitmapSource_iface, + &GUID_WICPixelFormat8bppIndexed, WICBitmapDitherTypeNone, + NULL, 0.0, WICBitmapPaletteTypeMedianCut); + ok(hr == S_OK || broken(hr == E_INVALIDARG) /* XP */, "Initialize error %#x\n", hr); + if (hr == S_OK) + { + hr = IWICFormatConverter_CopyPalette(converter, palette); + ok(hr == S_OK, "CopyPalette error %#x\n", hr); + count = 0xdeadbeef; + hr = IWICPalette_GetColorCount(palette, &count); + ok(hr == S_OK, "GetColorCount error %#x\n", hr); + ok(count == 8, "expected 8, got %u\n", count); + hr = IWICFormatConverter_CopyPixels(converter, NULL, 32, sizeof(buf), buf); + ok(hr == S_OK, "CopyPixels error %#x\n", hr); + count = 0; + for (i = 0; i < 32 * 2; i++) + if (buf[i] != 0) count++; + ok(count != 0, "expected != 0\n"); + } + IWICFormatConverter_Release(converter); + + IWICPalette_Release(palette); + DeleteTestBitmap(src_obj); +} + START_TEST(converter) { + HRESULT hr; + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + + hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICImagingFactory, (void **)&factory); + ok(hr == S_OK, "failed to create factory: %#x\n", hr); + + test_converter_8bppIndexed(); + + test_conversion(&testdata_24bppRGB, &testdata_2bppIndexed, "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); @@ -823,6 +1702,7 @@ test_conversion(&testdata_32bppBGR, &testdata_24bppRGB, "32bppBGR -> 24bppRGB", FALSE); test_conversion(&testdata_24bppRGB, &testdata_32bppBGR, "24bppRGB -> 32bppBGR", FALSE); + test_conversion(&testdata_32bppBGRA, &testdata_24bppRGB, "32bppBGRA -> 24bppRGB", FALSE); test_conversion(&testdata_24bppRGB, &testdata_32bppGrayFloat, "24bppRGB -> 32bppGrayFloat", FALSE); test_conversion(&testdata_32bppBGR, &testdata_32bppGrayFloat, "32bppBGR -> 32bppGrayFloat", FALSE); @@ -835,22 +1715,62 @@ test_invalid_conversion(); test_default_converter(); + test_encoder(&testdata_8bppIndexed, &CLSID_WICGifEncoder, + &testdata_8bppIndexed, &CLSID_WICGifDecoder, "GIF encoder 8bppIndexed"); + + test_encoder(&testdata_BlackWhite, &CLSID_WICPngEncoder, + &testdata_BlackWhite, &CLSID_WICPngDecoder, "PNG encoder BlackWhite"); + test_encoder(&testdata_1bppIndexed, &CLSID_WICPngEncoder, + &testdata_1bppIndexed, &CLSID_WICPngDecoder, "PNG encoder 1bppIndexed"); + test_encoder(&testdata_2bppIndexed, &CLSID_WICPngEncoder, + &testdata_2bppIndexed, &CLSID_WICPngDecoder, "PNG encoder 2bppIndexed"); + test_encoder(&testdata_4bppIndexed, &CLSID_WICPngEncoder, + &testdata_4bppIndexed, &CLSID_WICPngDecoder, "PNG encoder 4bppIndexed"); + test_encoder(&testdata_8bppIndexed, &CLSID_WICPngEncoder, + &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"); + test_encoder(&testdata_1bppIndexed, &CLSID_WICBmpEncoder, + &testdata_1bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 1bppIndexed"); + test_encoder(&testdata_2bppIndexed, &CLSID_WICBmpEncoder, + &testdata_2bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 2bppIndexed"); + test_encoder(&testdata_4bppIndexed, &CLSID_WICBmpEncoder, + &testdata_4bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 4bppIndexed"); + test_encoder(&testdata_8bppIndexed, &CLSID_WICBmpEncoder, + &testdata_8bppIndexed, &CLSID_WICBmpDecoder, "BMP encoder 8bppIndexed"); test_encoder(&testdata_32bppBGR, &CLSID_WICBmpEncoder, &testdata_32bppBGR, &CLSID_WICBmpDecoder, "BMP encoder 32bppBGR"); - test_encoder(&testdata_24bppBGR, &CLSID_WICPngEncoder, - &testdata_24bppBGR, &CLSID_WICPngDecoder, "PNG encoder 24bppBGR"); - + test_encoder(&testdata_BlackWhite, &CLSID_WICTiffEncoder, + &testdata_BlackWhite, &CLSID_WICTiffDecoder, "TIFF encoder BlackWhite"); + test_encoder(&testdata_1bppIndexed, &CLSID_WICTiffEncoder, + &testdata_1bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 1bppIndexed"); + test_encoder(&testdata_2bppIndexed, &CLSID_WICTiffEncoder, + &testdata_2bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 2bppIndexed"); + test_encoder(&testdata_4bppIndexed, &CLSID_WICTiffEncoder, + &testdata_4bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 4bppIndexed"); + test_encoder(&testdata_8bppIndexed, &CLSID_WICTiffEncoder, + &testdata_8bppIndexed, &CLSID_WICTiffDecoder, "TIFF encoder 8bppIndexed"); test_encoder(&testdata_24bppBGR, &CLSID_WICTiffEncoder, &testdata_24bppBGR, &CLSID_WICTiffDecoder, "TIFF encoder 24bppBGR"); test_multi_encoder(multiple_frames, &CLSID_WICTiffEncoder, - multiple_frames, &CLSID_WICTiffDecoder, NULL, NULL, "TIFF encoder multi-frame"); + multiple_frames, &CLSID_WICTiffDecoder, NULL, NULL, "TIFF encoder multi-frame", NULL); test_encoder_rects(); test_multi_encoder(single_frame, &CLSID_WICPngEncoder, - single_frame, &CLSID_WICPngDecoder, NULL, png_interlace_settings, "PNG encoder interlaced"); + single_frame, &CLSID_WICPngDecoder, NULL, png_interlace_settings, "PNG encoder interlaced", NULL); + + IWICImagingFactory_Release(factory); CoUninitialize(); } Modified: trunk/rostests/winetests/windowscodecs/palette.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/p…
============================================================================== --- trunk/rostests/winetests/windowscodecs/palette.c [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/palette.c [iso-8859-1] Thu Nov 17 23:23:38 2016 @@ -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 @@ -32,9 +32,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; @@ -43,11 +44,6 @@ 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)) @@ -212,8 +208,6 @@ IWICPalette_Release(palette2); IWICPalette_Release(palette); } - - IWICImagingFactory_Release(factory); } static void generate_gray16_palette(DWORD *entries, UINT count) @@ -456,17 +450,12 @@ { WICBitmapPaletteTypeFixedHalftone256, 0, 0, 256, { 0 } }, { WICBitmapPaletteTypeFixedHalftone256, 0, 0, 256, { 0 }, 1 } }; - IWICImagingFactory *factory; IWICPalette *palette; HRESULT hr; WICBitmapPaletteType type; UINT count, i, ret; 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); @@ -543,16 +532,136 @@ 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); + ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr); + + hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 1, FALSE); + ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr); + + hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 257, FALSE); + ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr); + + hr = IWICPalette_InitializeFromBitmap(palette, NULL, 16, FALSE); + ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr); + + hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 2, FALSE); + ok(hr == S_OK, "InitializeFromBitmap error %#x\n", hr); + 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); + + hr = IWICPalette_InitializeFromBitmap(palette, (IWICBitmapSource *)bitmap, 2, TRUE); + ok(hr == S_OK, "InitializeFromBitmap error %#x\n", hr); + 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); + ok(hr == S_OK, "InitializeFromBitmap error %#x\n", hr); + 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); + ok(hr == S_OK, "InitializeFromBitmap error %#x\n", hr); + 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(); } Modified: trunk/rostests/winetests/windowscodecs/pngformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/windowscodecs/p…
============================================================================== --- trunk/rostests/winetests/windowscodecs/pngformat.c [iso-8859-1] (original) +++ trunk/rostests/winetests/windowscodecs/pngformat.c [iso-8859-1] Thu Nov 17 23:23:38 2016 @@ -281,15 +281,16 @@ static IWICImagingFactory *factory; -static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size) +static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder) { HGLOBAL hmem; BYTE *data; HRESULT hr; - IWICBitmapDecoder *decoder = NULL; IStream *stream; GUID format; LONG refcount; + + *decoder = NULL; hmem = GlobalAlloc(0, image_size); data = GlobalLock(hmem); @@ -299,19 +300,19 @@ hr = CreateStreamOnHGlobal(hmem, TRUE, &stream); ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr); - hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); - ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); - if (FAILED(hr)) return NULL; - - hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); - ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); - ok(IsEqualGUID(&format, &GUID_ContainerFormatPng), - "wrong container format %s\n", wine_dbgstr_guid(&format)); - - refcount = IStream_Release(stream); - ok(refcount > 0, "expected stream refcount > 0\n"); - - return decoder; + hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, decoder); + if (hr == S_OK) + { + hr = IWICBitmapDecoder_GetContainerFormat(*decoder, &format); + ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_ContainerFormatPng), + "wrong container format %s\n", wine_dbgstr_guid(&format)); + + refcount = IStream_Release(stream); + ok(refcount > 0, "expected stream refcount > 0\n"); + } + + return hr; } static WCHAR *save_profile( BYTE *buffer, UINT size ) @@ -347,9 +348,9 @@ BYTE *buffer; BOOL ret; - decoder = create_decoder(png_no_color_profile, sizeof(png_no_color_profile)); - ok(decoder != 0, "Failed to load PNG image data\n"); - if (!decoder) return; + hr = create_decoder(png_no_color_profile, sizeof(png_no_color_profile), &decoder); + ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr); + if (hr != S_OK) return; /* global color context */ hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, NULL); @@ -375,9 +376,9 @@ IWICBitmapFrameDecode_Release(frame); IWICBitmapDecoder_Release(decoder); - decoder = create_decoder(png_color_profile, sizeof(png_color_profile)); - ok(decoder != 0, "Failed to load PNG image data\n"); - if (!decoder) return; + hr = create_decoder(png_color_profile, sizeof(png_color_profile), &decoder); + ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr); + if (hr != S_OK) return; /* global color context */ count = 0xdeadbeef; @@ -553,9 +554,9 @@ UINT count, ret; WICColor color[256]; - decoder = create_decoder(png_PLTE_tRNS, sizeof(png_PLTE_tRNS)); - ok(decoder != 0, "Failed to load PNG image data\n"); - if (!decoder) return; + hr = create_decoder(png_PLTE_tRNS, sizeof(png_PLTE_tRNS), &decoder); + ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr); + if (hr != S_OK) return; hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); @@ -589,9 +590,69 @@ static const char png_1x1_data[] = { 0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a, 0x00,0x00,0x00,0x0d,'I','H','D','R',0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,0xde, + 0x00,0x00,0x03,0x00,'P','L','T','E', + 0x01,0x01,0x01,0x02,0x02,0x02,0x03,0x03,0x03,0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x06,0x06,0x07,0x07,0x07,0x08,0x08,0x08, + 0x09,0x09,0x09,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x0e,0x0e,0x0e,0x0f,0x0f,0x0f,0x10,0x10,0x10, + 0x11,0x11,0x11,0x12,0x12,0x12,0x13,0x13,0x13,0x14,0x14,0x14,0x15,0x15,0x15,0x16,0x16,0x16,0x17,0x17,0x17,0x18,0x18,0x18, + 0x19,0x19,0x19,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1f,0x1f,0x1f,0x20,0x20,0x20, + 0x21,0x21,0x21,0x22,0x22,0x22,0x23,0x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25,0x26,0x26,0x26,0x27,0x27,0x27,0x28,0x28,0x28, + 0x29,0x29,0x29,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c,0x2c,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,0x2f,0x2f,0x2f,0x30,0x30,0x30, + 0x31,0x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33,0x34,0x34,0x34,0x35,0x35,0x35,0x36,0x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38, + 0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40, + 0x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43,0x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46,0x46,0x46,0x47,0x47,0x47,0x48,0x48,0x48, + 0x49,0x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4f,0x4f,0x4f,0x50,0x50,0x50, + 0x51,0x51,0x51,0x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54,0x54,0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,0x57,0x58,0x58,0x58, + 0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5b,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5e,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60,0x60, + 0x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63,0x63,0x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66,0x66,0x67,0x67,0x67,0x68,0x68,0x68, + 0x69,0x69,0x69,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x6f,0x70,0x70,0x70, + 0x71,0x71,0x71,0x72,0x72,0x72,0x73,0x73,0x73,0x74,0x74,0x74,0x75,0x75,0x75,0x76,0x76,0x76,0x77,0x77,0x77,0x78,0x78,0x78, + 0x79,0x79,0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7b,0x7c,0x7c,0x7c,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80, + 0x01,0x01,0x01,0x02,0x02,0x02,0x03,0x03,0x03,0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x06,0x06,0x07,0x07,0x07,0x08,0x08,0x08, + 0x09,0x09,0x09,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x0e,0x0e,0x0e,0x0f,0x0f,0x0f,0x10,0x10,0x10, + 0x11,0x11,0x11,0x12,0x12,0x12,0x13,0x13,0x13,0x14,0x14,0x14,0x15,0x15,0x15,0x16,0x16,0x16,0x17,0x17,0x17,0x18,0x18,0x18, + 0x19,0x19,0x19,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1f,0x1f,0x1f,0x20,0x20,0x20, + 0x21,0x21,0x21,0x22,0x22,0x22,0x23,0x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25,0x26,0x26,0x26,0x27,0x27,0x27,0x28,0x28,0x28, + 0x29,0x29,0x29,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c,0x2c,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,0x2f,0x2f,0x2f,0x30,0x30,0x30, + 0x31,0x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33,0x34,0x34,0x34,0x35,0x35,0x35,0x36,0x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38, + 0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40, + 0x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43,0x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46,0x46,0x46,0x47,0x47,0x47,0x48,0x48,0x48, + 0x49,0x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4f,0x4f,0x4f,0x50,0x50,0x50, + 0x51,0x51,0x51,0x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54,0x54,0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,0x57,0x58,0x58,0x58, + 0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5b,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5e,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60,0x60, + 0x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63,0x63,0x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66,0x66,0x67,0x67,0x67,0x68,0x68,0x68, + 0x69,0x69,0x69,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x6f,0x70,0x70,0x70, + 0x71,0x71,0x71,0x72,0x72,0x72,0x73,0x73,0x73,0x74,0x74,0x74,0x75,0x75,0x75,0x76,0x76,0x76,0x77,0x77,0x77,0x78,0x78,0x78, + 0x79,0x79,0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7b,0x7c,0x7c,0x7c,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80, + 0x76,0xb6,0x24,0x31, + 0x00,0x00,0x00,0x02,'t','R','N','S',0xff,0x00,0xe5,0xb7,0x30,0x4a, 0x00,0x00,0x00,0x0c,'I','D','A','T',0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,0xe7, 0x00,0x00,0x00,0x00,'I','E','N','D',0xae,0x42,0x60,0x82 }; + +static BOOL is_valid_png_type_depth(int color_type, int bit_depth, BOOL plte) +{ + switch (color_type) + { + case 0: /* Grayscale */ + return bit_depth == 1 || bit_depth == 2 || bit_depth == 4 || bit_depth == 8 || bit_depth == 16; + + case 2: /* True Color */ + return bit_depth == 8 || bit_depth == 16; + + case 3: /* Indexed Color */ + return (bit_depth == 1 || bit_depth == 2 || bit_depth == 4 || bit_depth == 8) && plte; + + case 4: /* Grayscale with alpha */ + return bit_depth == 8 || bit_depth == 16; + + case 6: /* True Color with alpha */ + return bit_depth == 8 || bit_depth == 16; + + default: + ok(0, "unknown PNG type %d, depth %d\n", color_type, bit_depth); + return FALSE; + } +} static void test_color_formats(void) { @@ -599,33 +660,138 @@ { char bit_depth, color_type; const GUID *format; + const GUID *format_PLTE; + const GUID *format_PLTE_tRNS; + BOOL todo; + BOOL todo_load; } td[] = { /* 2 - PNG_COLOR_TYPE_RGB */ - { 8, 2, &GUID_WICPixelFormat24bppBGR }, + { 1, 2, NULL, NULL, NULL }, + { 2, 2, NULL, NULL, NULL }, + { 4, 2, NULL, NULL, NULL }, + { 8, 2, &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppBGR, &GUID_WICPixelFormat24bppBGR }, + /* libpng refuses to load our test image complaining about extra compressed data, + * but libpng is still able to load the image with other combination of type/depth + * making RGB 16 bpp case special for some reason. Therefore todo = TRUE. + */ + { 16, 2, &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat48bppRGB, &GUID_WICPixelFormat48bppRGB, TRUE, TRUE }, + { 24, 2, NULL, NULL, NULL }, + { 32, 2, NULL, NULL, NULL }, /* 0 - PNG_COLOR_TYPE_GRAY */ - { 1, 0, &GUID_WICPixelFormatBlackWhite }, - { 2, 0, &GUID_WICPixelFormat2bppGray }, - { 4, 0, &GUID_WICPixelFormat4bppGray }, - { 8, 0, &GUID_WICPixelFormat8bppGray }, - { 16, 0, &GUID_WICPixelFormat16bppGray }, + { 1, 0, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormatBlackWhite, &GUID_WICPixelFormat1bppIndexed, TRUE }, + { 2, 0, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppGray, &GUID_WICPixelFormat2bppIndexed, TRUE }, + { 4, 0, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppGray, &GUID_WICPixelFormat4bppIndexed, TRUE }, + { 8, 0, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppGray, &GUID_WICPixelFormat8bppIndexed, TRUE }, + { 16, 0, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat16bppGray, &GUID_WICPixelFormat64bppRGBA, TRUE }, + { 24, 0, NULL, NULL, NULL }, + { 32, 0, NULL, NULL, NULL }, + /* 3 - PNG_COLOR_TYPE_PALETTE */ + { 1, 3, &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat1bppIndexed, &GUID_WICPixelFormat1bppIndexed }, + { 2, 3, &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat2bppIndexed, &GUID_WICPixelFormat2bppIndexed }, + { 4, 3, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat4bppIndexed, &GUID_WICPixelFormat4bppIndexed }, + { 8, 3, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat8bppIndexed, &GUID_WICPixelFormat8bppIndexed }, + { 16, 3, NULL, NULL, NULL }, + { 24, 3, NULL, NULL, NULL }, + { 32, 3, NULL, NULL, NULL }, }; char buf[sizeof(png_1x1_data)]; HRESULT hr; IWICBitmapDecoder *decoder; IWICBitmapFrameDecode *frame; GUID format; - int i; + int i, PLTE_off = 0, tRNS_off = 0; + + memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); + for (i = 0; i < sizeof(png_1x1_data) - 4; i++) + { + if (!memcmp(buf + i, "tRNS", 4)) + tRNS_off = i; + else if (!memcmp(buf + i, "PLTE", 4)) + PLTE_off = i; + } + + ok(PLTE_off && tRNS_off, "PLTE offset %d, tRNS offset %d\n", PLTE_off, tRNS_off); + if (!PLTE_off || !tRNS_off) return; + + /* In order to test the image data with and without PLTE and tRNS chunks + * it's been decided to simply sero out the chunk id for testing puposes, + * and under Windows such images get loaded just fine. But unfortunately + * libpng refuses to load such images complaining about unknown chunk type. + * A workaround for this libpng limitation is to mark the "disabled" chunks + * with tEXt id. + */ for (i = 0; i < sizeof(td)/sizeof(td[0]); i++) { + /* with the tRNS and PLTE chunks */ memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); buf[24] = td[i].bit_depth; buf[25] = td[i].color_type; - decoder = create_decoder(buf, sizeof(buf)); - ok(decoder != NULL, "Failed to load PNG image data\n"); - if (!decoder) continue; + hr = create_decoder(buf, sizeof(buf), &decoder); + if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE)) + ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr); + else +todo_wine_if(td[i].todo_load) + ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr); + if (hr != S_OK) goto next_1; + + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); + ok(hr == S_OK, "GetFrame error %#x\n", hr); + + hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); + ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); +todo_wine_if(td[i].todo) + ok(IsEqualGUID(&format, td[i].format_PLTE_tRNS), + "PLTE+tRNS: expected %s, got %s (type %d, bpp %d)\n", + wine_dbgstr_guid(td[i].format_PLTE_tRNS), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth); + + IWICBitmapFrameDecode_Release(frame); + IWICBitmapDecoder_Release(decoder); + +next_1: + /* without the tRNS chunk */ + memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); + buf[24] = td[i].bit_depth; + buf[25] = td[i].color_type; + memcpy(buf + tRNS_off, "tEXt", 4); + + hr = create_decoder(buf, sizeof(buf), &decoder); + if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, TRUE)) + ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr); + else +todo_wine_if(td[i].todo_load) + ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr); + if (hr != S_OK) goto next_2; + + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); + ok(hr == S_OK, "GetFrame error %#x\n", hr); + + hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); + ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); + ok(IsEqualGUID(&format, td[i].format_PLTE), + "PLTE: expected %s, got %s (type %d, bpp %d)\n", + wine_dbgstr_guid(td[i].format_PLTE), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth); + + IWICBitmapFrameDecode_Release(frame); + IWICBitmapDecoder_Release(decoder); + +next_2: + /* without the tRNS and PLTE chunks */ + memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); + buf[24] = td[i].bit_depth; + buf[25] = td[i].color_type; + memcpy(buf + PLTE_off, "tEXt", 4); + memcpy(buf + tRNS_off, "tEXt", 4); + + hr = create_decoder(buf, sizeof(buf), &decoder); + if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE)) + ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr); + else +todo_wine_if(td[i].todo_load) + ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr); + if (hr != S_OK) goto next_3; hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); @@ -633,7 +799,36 @@ hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); ok(IsEqualGUID(&format, td[i].format), - "expected %s, got %s\n", wine_dbgstr_guid(td[i].format), wine_dbgstr_guid(&format)); + "expected %s, got %s (type %d, bpp %d)\n", + wine_dbgstr_guid(td[i].format), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth); + + IWICBitmapFrameDecode_Release(frame); + IWICBitmapDecoder_Release(decoder); + +next_3: + /* without the PLTE chunk */ + memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); + buf[24] = td[i].bit_depth; + buf[25] = td[i].color_type; + memcpy(buf + PLTE_off, "tEXt", 4); + + hr = create_decoder(buf, sizeof(buf), &decoder); + if (!is_valid_png_type_depth(td[i].color_type, td[i].bit_depth, FALSE)) + ok(hr == WINCODEC_ERR_UNKNOWNIMAGEFORMAT, "%d: wrong error %#x\n", i, hr); + else +todo_wine_if(td[i].todo_load) + ok(hr == S_OK, "%d: Failed to load PNG image data (type %d, bpp %d) %#x\n", i, td[i].color_type, td[i].bit_depth, hr); + if (hr != S_OK) continue; + + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); + ok(hr == S_OK, "GetFrame error %#x\n", hr); + + hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format); + ok(hr == S_OK, "GetPixelFormat error %#x\n", hr); +todo_wine_if(td[i].todo) + ok(IsEqualGUID(&format, td[i].format_PLTE_tRNS), + "tRNS: expected %s, got %s (type %d, bpp %d)\n", + wine_dbgstr_guid(td[i].format_PLTE_tRNS), wine_dbgstr_guid(&format), td[i].color_type, td[i].bit_depth); IWICBitmapFrameDecode_Release(frame); IWICBitmapDecoder_Release(decoder);
8 years, 1 month
1
0
0
0
[akhaldi] 73303: [WINDOWSCODECS] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 23:22:42 2016 New Revision: 73303 URL:
http://svn.reactos.org/svn/reactos?rev=73303&view=rev
Log: [WINDOWSCODECS] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/reactos/dll/win32/windowscodecs/bmpdecode.c trunk/reactos/dll/win32/windowscodecs/bmpencode.c trunk/reactos/dll/win32/windowscodecs/clsfactory.c trunk/reactos/dll/win32/windowscodecs/converter.c trunk/reactos/dll/win32/windowscodecs/gifformat.c trunk/reactos/dll/win32/windowscodecs/icnsformat.c trunk/reactos/dll/win32/windowscodecs/imgfactory.c trunk/reactos/dll/win32/windowscodecs/info.c trunk/reactos/dll/win32/windowscodecs/jpegformat.c trunk/reactos/dll/win32/windowscodecs/main.c trunk/reactos/dll/win32/windowscodecs/metadataquery.c trunk/reactos/dll/win32/windowscodecs/palette.c trunk/reactos/dll/win32/windowscodecs/pngformat.c trunk/reactos/dll/win32/windowscodecs/regsvr.c trunk/reactos/dll/win32/windowscodecs/tiffformat.c trunk/reactos/dll/win32/windowscodecs/typeof.h trunk/reactos/dll/win32/windowscodecs/wincodecs_private.h trunk/reactos/dll/win32/windowscodecs/windowscodecs_wincodec.idl trunk/reactos/media/doc/README.WINE [This mail would be too long, it was shortened to contain the URLs only.] Modified: trunk/reactos/dll/win32/windowscodecs/bmpdecode.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/bm…
Modified: trunk/reactos/dll/win32/windowscodecs/bmpencode.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/bm…
Modified: trunk/reactos/dll/win32/windowscodecs/clsfactory.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/cl…
Modified: trunk/reactos/dll/win32/windowscodecs/converter.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/co…
Modified: trunk/reactos/dll/win32/windowscodecs/gifformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/gi…
Modified: trunk/reactos/dll/win32/windowscodecs/icnsformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/ic…
Modified: trunk/reactos/dll/win32/windowscodecs/imgfactory.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/im…
Modified: trunk/reactos/dll/win32/windowscodecs/info.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/in…
Modified: trunk/reactos/dll/win32/windowscodecs/jpegformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/jp…
Modified: trunk/reactos/dll/win32/windowscodecs/main.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/ma…
Modified: trunk/reactos/dll/win32/windowscodecs/metadataquery.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/me…
Modified: trunk/reactos/dll/win32/windowscodecs/palette.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/pa…
Modified: trunk/reactos/dll/win32/windowscodecs/pngformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/pn…
Modified: trunk/reactos/dll/win32/windowscodecs/regsvr.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/re…
Modified: trunk/reactos/dll/win32/windowscodecs/tiffformat.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/ti…
Modified: trunk/reactos/dll/win32/windowscodecs/typeof.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/ty…
Modified: trunk/reactos/dll/win32/windowscodecs/wincodecs_private.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/wi…
Modified: trunk/reactos/dll/win32/windowscodecs/windowscodecs_wincodec.idl URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/windowscodecs/wi…
Modified: trunk/reactos/media/doc/README.WINE URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=…
8 years, 1 month
1
0
0
0
[akhaldi] 73302: [PSDK] Add missing WINCODEC_ERR_UNKNOWNIMAGEFORMAT.
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 23:20:00 2016 New Revision: 73302 URL:
http://svn.reactos.org/svn/reactos?rev=73302&view=rev
Log: [PSDK] Add missing WINCODEC_ERR_UNKNOWNIMAGEFORMAT. Modified: trunk/reactos/sdk/include/psdk/winerror.h Modified: trunk/reactos/sdk/include/psdk/winerror.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/sdk/include/psdk/winerror.…
============================================================================== --- trunk/reactos/sdk/include/psdk/winerror.h [iso-8859-1] (original) +++ trunk/reactos/sdk/include/psdk/winerror.h [iso-8859-1] Thu Nov 17 23:20:00 2016 @@ -3268,6 +3268,8 @@ #define SCARD_W_CACHE_ITEM_STALE _HRESULT_TYPEDEF_(0x80100071L) #define SCARD_W_CACHE_ITEM_TOO_BIG _HRESULT_TYPEDEF_(0x80100072L) +#define WINCODEC_ERR_UNKNOWNIMAGEFORMAT _HRESULT_TYPEDEF_(0x88982f07) + #define ERROR_AUDITING_DISABLED _HRESULT_TYPEDEF_(0xC0090001L) #define ERROR_ALL_SIDS_FILTERED _HRESULT_TYPEDEF_(0xC0090002L)
8 years, 1 month
1
0
0
0
[akhaldi] 73301: [WBOMPROX_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409
by akhaldi@svn.reactos.org
Author: akhaldi Date: Thu Nov 17 23:19:20 2016 New Revision: 73301 URL:
http://svn.reactos.org/svn/reactos?rev=73301&view=rev
Log: [WBOMPROX_WINETEST] Sync with Wine Staging 1.9.23. CORE-12409 Modified: trunk/rostests/winetests/wbemprox/query.c Modified: trunk/rostests/winetests/wbemprox/query.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/wbemprox/query.…
============================================================================== --- trunk/rostests/winetests/wbemprox/query.c [iso-8859-1] (original) +++ trunk/rostests/winetests/wbemprox/query.c [iso-8859-1] Thu Nov 17 23:19:20 2016 @@ -310,7 +310,6 @@ VariantInit( &val ); hr = IWbemClassObject_Get( obj, identificationcodeW, 0, &val, &type, NULL ); ok( hr == S_OK, "failed to get identication code %08x\n", hr ); - todo_wine ok( V_VT( &val ) == VT_NULL, "unexpected variant type 0x%x\n", V_VT( &val ) ); ok( type == CIM_STRING, "unexpected type 0x%x\n", type ); VariantClear( &val ); @@ -590,7 +589,6 @@ VariantInit( &val ); hr = IWbemClassObject_Get( obj, chassistypesW, 0, &val, &type, NULL ); ok( hr == S_OK, "failed to get chassis types %08x\n", hr ); - todo_wine ok( V_VT( &val ) == (VT_I4|VT_ARRAY), "unexpected variant type 0x%x\n", V_VT( &val ) ); ok( type == (CIM_UINT16|CIM_FLAG_ARRAY), "unexpected type 0x%x\n", type ); hr = SafeArrayAccessData( V_ARRAY( &val ), (void **)&data ); @@ -1051,6 +1049,172 @@ SysFreeString( class ); } +static void test_OperatingSystem( IWbemServices *services ) +{ + static const WCHAR queryW[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_', + 'O','p','e','r','a','t','i','n','g','S','y','s','t','e','m',0}; + static const WCHAR buildnumberW[] = {'B','u','i','l','d','N','u','m','b','e','r',0}; + static const WCHAR captionW[] = {'C','a','p','t','i','o','n',0}; + static const WCHAR csdversionW[] = {'C','S','D','V','e','r','s','i','o','n',0}; + static const WCHAR nameW[] = {'N','a','m','e',0}; + static const WCHAR osproductsuiteW[] = {'O','S','P','r','o','d','u','c','t','S','u','i','t','e',0}; + static const WCHAR ostypeW[] = {'O','S','T','y','p','e',0}; + static const WCHAR suitemaskW[] = {'S','u','i','t','e','M','a','s','k',0}; + static const WCHAR versionW[] = {'V','e','r','s','i','o','n',0}; + static const WCHAR servicepackmajorW[] = + {'S','e','r','v','i','c','e','P','a','c','k','M','a','j','o','r','V','e','r','s','i','o','n',0}; + static const WCHAR servicepackminorW[] = + {'S','e','r','v','i','c','e','P','a','c','k','M','i','n','o','r','V','e','r','s','i','o','n',0}; + BSTR wql = SysAllocString( wqlW ), query = SysAllocString( queryW ); + IEnumWbemClassObject *result; + IWbemClassObject *obj; + CIMTYPE type; + ULONG count; + VARIANT val; + HRESULT hr; + + hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result ); + ok( hr == S_OK, "IWbemServices_ExecQuery failed %08x\n", hr ); + + hr = IEnumWbemClassObject_Next( result, 10000, 1, &obj, &count ); + ok( hr == S_OK, "IEnumWbemClassObject_Next failed %08x\n", hr ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, buildnumberW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get buildnumber %08x\n", hr ); + ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_STRING, "unexpected type 0x%x\n", type ); + trace( "buildnumber: %s\n", wine_dbgstr_w(V_BSTR( &val )) ); + VariantClear( &val ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, captionW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get caption %08x\n", hr ); + ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_STRING, "unexpected type 0x%x\n", type ); + trace( "caption: %s\n", wine_dbgstr_w(V_BSTR( &val )) ); + VariantClear( &val ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, csdversionW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get csdversion %08x\n", hr ); + ok( V_VT( &val ) == VT_BSTR || V_VT( &val ) == VT_NULL, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_STRING, "unexpected type 0x%x\n", type ); + trace( "csdversion: %s\n", wine_dbgstr_w(V_BSTR( &val )) ); + VariantClear( &val ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, nameW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get name %08x\n", hr ); + ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_STRING, "unexpected type 0x%x\n", type ); + trace( "name: %s\n", wine_dbgstr_w(V_BSTR( &val )) ); + VariantClear( &val ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, osproductsuiteW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get osproductsuite %08x\n", hr ); + ok( V_VT( &val ) == VT_I4 || broken(V_VT( &val ) == VT_NULL) /* winxp */, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_UINT32, "unexpected type 0x%x\n", type ); + trace( "osproductsuite: %d (%08x)\n", V_I4( &val ), V_I4( &val ) ); + VariantClear( &val ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, ostypeW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get ostype %08x\n", hr ); + ok( V_VT( &val ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_UINT16, "unexpected type 0x%x\n", type ); + trace( "ostype: %d\n", V_I4( &val ) ); + VariantClear( &val ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, servicepackmajorW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get servicepackmajor %08x\n", hr ); + ok( V_VT( &val ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_UINT16, "unexpected type 0x%x\n", type ); + trace( "servicepackmajor: %d\n", V_I4( &val ) ); + VariantClear( &val ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, servicepackminorW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get servicepackminor %08x\n", hr ); + ok( V_VT( &val ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_UINT16, "unexpected type 0x%x\n", type ); + trace( "servicepackminor: %d\n", V_I4( &val ) ); + VariantClear( &val ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, suitemaskW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get suitemask %08x\n", hr ); + ok( V_VT( &val ) == VT_I4, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_UINT32, "unexpected type 0x%x\n", type ); + trace( "suitemask: %d (%08x)\n", V_I4( &val ), V_I4( &val ) ); + VariantClear( &val ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( obj, versionW, 0, &val, &type, NULL ); + ok( hr == S_OK, "failed to get version %08x\n", hr ); + ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); + ok( type == CIM_STRING, "unexpected type 0x%x\n", type ); + trace( "version: %s\n", wine_dbgstr_w(V_BSTR( &val )) ); + VariantClear( &val ); + + IWbemClassObject_Release( obj ); + IEnumWbemClassObject_Release( result ); + SysFreeString( query ); + SysFreeString( wql ); +} + +static void test_ComputerSystemProduct( IWbemServices *services ) +{ + static const WCHAR uuidW[] = {'U','U','I','D',0}; + static const WCHAR queryW[] = + {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ','W','i','n','3','2','_', + 'C','o','m','p','u','t','e','r','S','y','s','t','e','m','P','r','o','d','u','c','t',0}; + BSTR wql = SysAllocString( wqlW ), query = SysAllocString( queryW ); + IEnumWbemClassObject *result; + IWbemClassObject *service; + VARIANT value; + CIMTYPE type; + HRESULT hr; + DWORD count; + + hr = IWbemServices_ExecQuery( services, wql, query, 0, NULL, &result ); + if (hr != S_OK) + { + win_skip( "Win32_ComputerSystemProduct not available\n" ); + return; + } + + hr = IEnumWbemClassObject_Next( result, 10000, 1, &service, &count ); + ok( hr == S_OK, "got %08x\n", hr ); + + type = 0xdeadbeef; + VariantInit( &value ); + hr = IWbemClassObject_Get( service, uuidW, 0, &value, &type, NULL ); + ok( hr == S_OK, "failed to get computer name %08x\n", hr ); + ok( V_VT( &value ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &value ) ); + ok( type == CIM_STRING, "unexpected type 0x%x\n", type ); + trace( "uuid %s\n", wine_dbgstr_w(V_BSTR(&value)) ); + VariantClear( &value ); + + IWbemClassObject_Release( service ); + IEnumWbemClassObject_Release( result ); + SysFreeString( query ); + SysFreeString( wql ); +} + START_TEST(query) { static const WCHAR cimv2W[] = {'R','O','O','T','\\','C','I','M','V','2',0}; @@ -1088,6 +1252,8 @@ test_query_async( services ); test_GetNames( services ); test_SystemSecurity( services ); + test_OperatingSystem( services ); + test_ComputerSystemProduct( services ); SysFreeString( path ); IWbemServices_Release( services );
8 years, 1 month
1
0
0
0
← Newer
1
...
8
9
10
11
12
13
14
...
32
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Results per page:
10
25
50
100
200