From: Hans Leidekker Subject: [PATCH 1/3] mscms: Add a partial implementation of WcsOpenColorProfileA/W. Message-Id: <20190224170326.23480-1-hans@codeweavers.com> Date: Sun, 24 Feb 2019 18:03:24 +0100 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46708 Signed-off-by: Hans Leidekker --- dlls/mscms/mscms.spec | 4 +-- dlls/mscms/profile.c | 71 +++++++++++++++++++++++++++++++++++++-------------- include/icm.h | 2 ++ 3 files changed, 56 insertions(+), 21 deletions(-) diff --git a/dlls/mscms/mscms.spec b/dlls/mscms/mscms.spec index f521ac6969..fec0af571d 100644 --- a/dlls/mscms/mscms.spec +++ b/dlls/mscms/mscms.spec @@ -96,8 +96,8 @@ @ stub WcsGetDefaultRenderingIntent @ stdcall WcsGetUsePerUserProfiles(wstr long ptr) @ stub WcsGpCanInstallOrUninstallProfiles -@ stub WcsOpenColorProfileA -@ stub WcsOpenColorProfileW +@ stdcall WcsOpenColorProfileA(ptr ptr ptr long long long long) +@ stdcall WcsOpenColorProfileW(ptr ptr ptr long long long long) @ stub WcsSetCalibrationManagementState @ stub WcsSetDefaultColorProfile @ stub WcsSetDefaultRenderingIntent diff --git a/dlls/mscms/profile.c b/dlls/mscms/profile.c index a0b9d4133d..6bc55e7ae6 100644 --- a/dlls/mscms/profile.c +++ b/dlls/mscms/profile.c @@ -1327,6 +1327,18 @@ BOOL WINAPI UninstallColorProfileW( PCWSTR machine, PCWSTR profile, BOOL delete return TRUE; } +static BOOL profile_AtoW( const PROFILE *in, PROFILE *out ) +{ + int len; + if (!in->pProfileData) return FALSE; + len = MultiByteToWideChar( CP_ACP, 0, in->pProfileData, -1, NULL, 0 ); + if (!(out->pProfileData = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return FALSE; + out->cbDataSize = len * sizeof(WCHAR); + MultiByteToWideChar( CP_ACP, 0, in->pProfileData, -1, out->pProfileData, len ); + out->dwType = in->dwType; + return TRUE; +} + /****************************************************************************** * OpenColorProfileA [MSCMS.@] * @@ -1335,6 +1347,7 @@ BOOL WINAPI UninstallColorProfileW( PCWSTR machine, PCWSTR profile, BOOL delete HPROFILE WINAPI OpenColorProfileA( PPROFILE profile, DWORD access, DWORD sharing, DWORD creation ) { HPROFILE handle = NULL; + PROFILE profileW; TRACE( "( %p, 0x%08x, 0x%08x, 0x%08x )\n", profile, access, sharing, creation ); @@ -1344,25 +1357,9 @@ HPROFILE WINAPI OpenColorProfileA( PPROFILE profile, DWORD access, DWORD sharing if (profile->dwType & PROFILE_MEMBUFFER) return OpenColorProfileW( profile, access, sharing, creation ); - if (profile->dwType & PROFILE_FILENAME) - { - UINT len; - PROFILE profileW; - - profileW.dwType = profile->dwType; - - len = MultiByteToWideChar( CP_ACP, 0, profile->pProfileData, -1, NULL, 0 ); - profileW.pProfileData = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); - - if (profileW.pProfileData) - { - profileW.cbDataSize = len * sizeof(WCHAR); - MultiByteToWideChar( CP_ACP, 0, profile->pProfileData, -1, profileW.pProfileData, len ); - - handle = OpenColorProfileW( &profileW, access, sharing, creation ); - HeapFree( GetProcessHeap(), 0, profileW.pProfileData ); - } - } + if (!profile_AtoW( profile, &profileW )) return FALSE; + handle = OpenColorProfileW( &profileW, access, sharing, creation ); + HeapFree( GetProcessHeap(), 0, profileW.pProfileData ); return handle; } @@ -1546,3 +1543,39 @@ BOOL WINAPI WcsEnumColorProfilesSize( WCS_PROFILE_MANAGEMENT_SCOPE scope, ENUMTY SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); return FALSE; } + +/****************************************************************************** + * WcsOpenColorProfileA [MSCMS.@] + */ +HPROFILE WINAPI WcsOpenColorProfileA( PROFILE *cdm, PROFILE *camp, PROFILE *gmmp, DWORD access, DWORD sharing, + DWORD creation, DWORD flags ) +{ + PROFILE cdmW, campW = {0}, gmmpW = {0}; + HPROFILE ret = NULL; + + TRACE( "%p, %p, %p, %08x, %08x, %08x, %08x\n", cdm, camp, gmmp, access, sharing, creation, flags ); + + if (!cdm || !profile_AtoW( cdm, &cdmW )) return NULL; + if (camp && !profile_AtoW( camp, &campW )) goto done; + if (gmmp && !profile_AtoW( gmmp, &gmmpW )) goto done; + + ret = WcsOpenColorProfileW( &cdmW, &campW, &gmmpW, access, sharing, creation, flags ); + +done: + HeapFree( GetProcessHeap(), 0, cdmW.pProfileData ); + HeapFree( GetProcessHeap(), 0, campW.pProfileData ); + HeapFree( GetProcessHeap(), 0, gmmpW.pProfileData ); + return ret; +} + +/****************************************************************************** + * WcsOpenColorProfileW [MSCMS.@] + */ +HPROFILE WINAPI WcsOpenColorProfileW( PROFILE *cdm, PROFILE *camp, PROFILE *gmmp, DWORD access, DWORD sharing, + DWORD creation, DWORD flags ) +{ + TRACE( "%p, %p, %p, %08x, %08x, %08x, %08x\n", cdm, camp, gmmp, access, sharing, creation, flags ); + FIXME("no support for WCS profiles\n" ); + + return OpenColorProfileW( cdm, access, sharing, creation ); +} diff --git a/include/icm.h b/include/icm.h index fbbdede3ed..de5bf2626e 100644 --- a/include/icm.h +++ b/include/icm.h @@ -411,6 +411,8 @@ BOOL WINAPI UnregisterCMMW(PCWSTR,DWORD); #define UnregisterCMM WINELIB_NAME_AW(UnregisterCMM) BOOL WINAPI WcsEnumColorProfilesSize(WCS_PROFILE_MANAGEMENT_SCOPE,ENUMTYPEW*,DWORD*); BOOL WINAPI WcsGetUsePerUserProfiles(const WCHAR*,DWORD,BOOL*); +HPROFILE WINAPI WcsOpenColorProfileA(PROFILE*,PROFILE*,PROFILE*,DWORD,DWORD,DWORD,DWORD); +HPROFILE WINAPI WcsOpenColorProfileW(PROFILE*,PROFILE*,PROFILE*,DWORD,DWORD,DWORD,DWORD); #define PROFILE_FILENAME 1 #define PROFILE_MEMBUFFER 2 -- 2.11.0