2004-10-07 19:12:41 +00:00
|
|
|
/*
|
|
|
|
* MSCMS - Color Management System for Wine
|
|
|
|
*
|
2005-02-14 20:53:59 +00:00
|
|
|
* Copyright 2004, 2005 Hans Leidekker
|
2004-10-07 19:12:41 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winnls.h"
|
|
|
|
#include "wingdi.h"
|
2004-10-22 19:56:51 +00:00
|
|
|
#include "winuser.h"
|
2004-10-07 19:12:41 +00:00
|
|
|
#include "icm.h"
|
|
|
|
|
2005-07-15 10:09:43 +00:00
|
|
|
#include "mscms_priv.h"
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2004-11-03 22:14:25 +00:00
|
|
|
#define IS_SEPARATOR(ch) ((ch) == '\\' || (ch) == '/')
|
|
|
|
|
|
|
|
static void MSCMS_basename( LPCWSTR path, LPWSTR name )
|
|
|
|
{
|
|
|
|
INT i = lstrlenW( path );
|
|
|
|
|
|
|
|
while (i > 0 && !IS_SEPARATOR(path[i - 1])) i--;
|
|
|
|
lstrcpyW( name, &path[i] );
|
|
|
|
}
|
|
|
|
|
2004-10-07 19:12:41 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mscms);
|
|
|
|
|
2004-11-19 18:22:20 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetColorDirectoryA [MSCMS.@]
|
|
|
|
*
|
|
|
|
* See GetColorDirectoryW.
|
|
|
|
*/
|
2004-10-07 19:12:41 +00:00
|
|
|
BOOL WINAPI GetColorDirectoryA( PCSTR machine, PSTR buffer, PDWORD size )
|
|
|
|
{
|
|
|
|
INT len;
|
|
|
|
LPWSTR bufferW;
|
|
|
|
BOOL ret = FALSE;
|
2004-12-07 14:42:47 +00:00
|
|
|
DWORD sizeW;
|
|
|
|
|
|
|
|
TRACE( "( %p, %p )\n", buffer, size );
|
|
|
|
|
|
|
|
if (machine || !size) return FALSE;
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
if (!buffer)
|
|
|
|
{
|
|
|
|
ret = GetColorDirectoryW( NULL, NULL, &sizeW );
|
|
|
|
*size = sizeW / sizeof(WCHAR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
sizeW = *size * sizeof(WCHAR);
|
2004-10-07 19:12:41 +00:00
|
|
|
|
|
|
|
bufferW = HeapAlloc( GetProcessHeap(), 0, sizeW );
|
|
|
|
|
|
|
|
if (bufferW)
|
|
|
|
{
|
|
|
|
ret = GetColorDirectoryW( NULL, bufferW, &sizeW );
|
2004-11-21 15:48:18 +00:00
|
|
|
*size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, bufferW, *size, buffer, *size, NULL, NULL );
|
|
|
|
if (!len) ret = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, bufferW );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-11-19 18:22:20 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetColorDirectoryW [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Get the directory where color profiles are stored.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* machine [I] Name of the machine for which to get the color directory.
|
|
|
|
* Must be NULL, which indicates the local machine.
|
2004-12-13 13:23:17 +00:00
|
|
|
* buffer [I] Buffer to receive the path name.
|
2004-11-19 18:22:20 +00:00
|
|
|
* size [I/O] Size of the buffer in bytes. On return the variable holds
|
|
|
|
* the number of bytes actually needed.
|
|
|
|
*/
|
2004-10-07 19:12:41 +00:00
|
|
|
BOOL WINAPI GetColorDirectoryW( PCWSTR machine, PWSTR buffer, PDWORD size )
|
|
|
|
{
|
2005-04-11 18:49:40 +00:00
|
|
|
WCHAR colordir[MAX_PATH];
|
2005-07-05 10:56:52 +00:00
|
|
|
static const WCHAR colorsubdir[] = { '\\','c','o','l','o','r',0 };
|
2004-10-07 19:12:41 +00:00
|
|
|
DWORD len;
|
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
TRACE( "( %p, %p )\n", buffer, size );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
if (machine || !size) return FALSE;
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2005-07-05 10:56:52 +00:00
|
|
|
GetSystemDirectoryW( colordir, sizeof(colordir) / sizeof(WCHAR) );
|
2005-04-11 18:49:40 +00:00
|
|
|
lstrcatW( colordir, colorsubdir );
|
|
|
|
|
2004-10-07 19:12:41 +00:00
|
|
|
len = lstrlenW( colordir ) * sizeof(WCHAR);
|
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
if (len <= *size && buffer)
|
2004-10-07 19:12:41 +00:00
|
|
|
{
|
2004-11-03 22:14:25 +00:00
|
|
|
lstrcpyW( buffer, colordir );
|
2004-12-07 14:42:47 +00:00
|
|
|
*size = len;
|
2004-10-07 19:12:41 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*size = len;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-12-13 13:23:17 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetColorProfileElement [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Retrieve data for a specified tag type.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* profile [I] Handle to a color profile.
|
|
|
|
* type [I] ICC tag type.
|
|
|
|
* offset [I] Offset in bytes to start copying from.
|
|
|
|
* size [I/O] Size of the buffer in bytes. On return the variable holds
|
|
|
|
* the number of bytes actually needed.
|
|
|
|
* buffer [O] Buffer to receive the tag data.
|
|
|
|
* ref [O] Pointer to a BOOL that specifies whether more than one tag
|
|
|
|
* references the data.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
2004-11-30 21:06:14 +00:00
|
|
|
BOOL WINAPI GetColorProfileElement( HPROFILE profile, TAGTYPE type, DWORD offset, PDWORD size,
|
|
|
|
PVOID buffer, PBOOL ref )
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2004-11-30 21:06:14 +00:00
|
|
|
icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile );
|
|
|
|
DWORD i, count;
|
|
|
|
icTag tag;
|
|
|
|
|
|
|
|
TRACE( "( %p, 0x%08lx, %ld, %p, %p, %p )\n", profile, type, offset, size, buffer, ref );
|
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
if (!iccprofile || !size || !ref) return FALSE;
|
2004-11-30 21:06:14 +00:00
|
|
|
count = MSCMS_get_tag_count( iccprofile );
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
MSCMS_get_tag_by_index( iccprofile, i, &tag );
|
|
|
|
|
|
|
|
if (tag.sig == type)
|
|
|
|
{
|
|
|
|
if ((tag.size - offset) > *size || !buffer)
|
|
|
|
{
|
|
|
|
*size = (tag.size - offset);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
MSCMS_get_tag_data( iccprofile, &tag, offset, buffer );
|
|
|
|
|
|
|
|
*ref = FALSE; /* FIXME: calculate properly */
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2004-11-30 21:06:14 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-11-21 15:48:18 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetColorProfileElementTag [MSCMS.@]
|
|
|
|
*
|
2004-12-13 13:23:17 +00:00
|
|
|
* Get the tag type from a color profile by index.
|
2004-11-21 15:48:18 +00:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* profile [I] Handle to a color profile.
|
|
|
|
* index [I] Index into the tag table of the color profile.
|
2004-12-13 13:23:17 +00:00
|
|
|
* type [O] Pointer to a variable that holds the ICC tag type on return.
|
2004-11-21 15:48:18 +00:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The tag table index starts at 1.
|
|
|
|
* Use GetCountColorProfileElements to retrieve a count of tagged elements.
|
|
|
|
*/
|
2004-11-30 21:06:14 +00:00
|
|
|
BOOL WINAPI GetColorProfileElementTag( HPROFILE profile, DWORD index, PTAGTYPE type )
|
2004-11-21 15:48:18 +00:00
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2004-11-30 21:06:14 +00:00
|
|
|
icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile );
|
|
|
|
DWORD count;
|
|
|
|
icTag tag;
|
2004-11-21 15:48:18 +00:00
|
|
|
|
2004-11-30 21:06:14 +00:00
|
|
|
TRACE( "( %p, %ld, %p )\n", profile, index, type );
|
2004-11-21 15:48:18 +00:00
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
if (!iccprofile || !type) return FALSE;
|
2004-11-30 21:06:14 +00:00
|
|
|
|
|
|
|
count = MSCMS_get_tag_count( iccprofile );
|
2004-12-07 14:42:47 +00:00
|
|
|
if (index > count || index < 1) return FALSE;
|
2004-11-30 21:06:14 +00:00
|
|
|
|
|
|
|
MSCMS_get_tag_by_index( iccprofile, index - 1, &tag );
|
|
|
|
*type = tag.sig;
|
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2004-11-30 21:06:14 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-12-13 13:23:17 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetColorProfileFromHandle [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Retrieve an ICC color profile by handle.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* profile [I] Handle to a color profile.
|
|
|
|
* buffer [O] Buffer to receive the ICC profile.
|
|
|
|
* size [I/O] Size of the buffer in bytes. On return the variable holds the
|
|
|
|
* number of bytes actually needed.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The profile returned will be in big-endian format.
|
|
|
|
*/
|
2004-11-30 21:06:14 +00:00
|
|
|
BOOL WINAPI GetColorProfileFromHandle( HPROFILE profile, PBYTE buffer, PDWORD size )
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2004-11-30 21:06:14 +00:00
|
|
|
icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile );
|
|
|
|
PROFILEHEADER header;
|
|
|
|
|
|
|
|
TRACE( "( %p, %p, %p )\n", profile, buffer, size );
|
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
if (!iccprofile || !size) return FALSE;
|
|
|
|
MSCMS_get_profile_header( iccprofile, &header );
|
2004-11-30 21:06:14 +00:00
|
|
|
|
|
|
|
if (!buffer || header.phSize > *size)
|
2004-11-21 15:48:18 +00:00
|
|
|
{
|
2004-11-30 21:06:14 +00:00
|
|
|
*size = header.phSize;
|
|
|
|
return FALSE;
|
2004-11-21 15:48:18 +00:00
|
|
|
}
|
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
/* No endian conversion needed */
|
2004-11-30 21:06:14 +00:00
|
|
|
memcpy( buffer, iccprofile, header.phSize );
|
2004-12-20 17:04:11 +00:00
|
|
|
|
|
|
|
*size = header.phSize;
|
2004-11-30 21:06:14 +00:00
|
|
|
ret = TRUE;
|
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2004-11-30 21:06:14 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-12-13 13:23:17 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetColorProfileHeader [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Retrieve a color profile header by handle.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* profile [I] Handle to a color profile.
|
|
|
|
* header [O] Buffer to receive the ICC profile header.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* The profile header returned will be adjusted for endianess.
|
|
|
|
*/
|
2004-11-30 21:06:14 +00:00
|
|
|
BOOL WINAPI GetColorProfileHeader( HPROFILE profile, PPROFILEHEADER header )
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2004-11-30 21:06:14 +00:00
|
|
|
icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile );
|
|
|
|
|
|
|
|
TRACE( "( %p, %p )\n", profile, header );
|
|
|
|
|
|
|
|
if (!iccprofile || !header) return FALSE;
|
|
|
|
|
|
|
|
MSCMS_get_profile_header( iccprofile, header );
|
|
|
|
return TRUE;
|
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2004-11-21 15:48:18 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetCountColorProfileElements [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Retrieve the number of elements in a color profile.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* profile [I] Handle to a color profile.
|
|
|
|
* count [O] Pointer to a variable which is set to the number of elements
|
|
|
|
* in the color profile.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetCountColorProfileElements( HPROFILE profile, PDWORD count )
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2004-11-30 21:06:14 +00:00
|
|
|
icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile );
|
2004-11-21 15:48:18 +00:00
|
|
|
|
|
|
|
TRACE( "( %p, %p )\n", profile, count );
|
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
if (!iccprofile || !count) return FALSE;
|
2004-11-30 21:06:14 +00:00
|
|
|
*count = MSCMS_get_tag_count( iccprofile );
|
|
|
|
ret = TRUE;
|
2004-11-21 15:48:18 +00:00
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2004-11-21 15:48:18 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-03-09 18:42:52 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetStandardColorSpaceProfileA [MSCMS.@]
|
|
|
|
*
|
|
|
|
* See GetStandardColorSpaceProfileW.
|
|
|
|
*/
|
2004-11-21 15:48:18 +00:00
|
|
|
BOOL WINAPI GetStandardColorSpaceProfileA( PCSTR machine, DWORD id, PSTR profile, PDWORD size )
|
|
|
|
{
|
|
|
|
INT len;
|
|
|
|
LPWSTR profileW;
|
|
|
|
BOOL ret = FALSE;
|
2004-12-07 14:42:47 +00:00
|
|
|
DWORD sizeW;
|
2004-11-21 15:48:18 +00:00
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
TRACE( "( 0x%08lx, %p, %p )\n", id, profile, size );
|
2004-11-21 15:48:18 +00:00
|
|
|
|
2006-01-13 13:09:04 +00:00
|
|
|
if (machine)
|
|
|
|
{
|
2006-02-20 10:13:28 +00:00
|
|
|
SetLastError( ERROR_NOT_SUPPORTED );
|
2006-01-13 13:09:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!size)
|
|
|
|
{
|
2006-02-20 10:13:28 +00:00
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
2006-01-13 13:09:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2004-12-07 14:42:47 +00:00
|
|
|
|
|
|
|
sizeW = *size * sizeof(WCHAR);
|
|
|
|
|
|
|
|
if (!profile)
|
|
|
|
{
|
|
|
|
ret = GetStandardColorSpaceProfileW( NULL, id, NULL, &sizeW );
|
|
|
|
*size = sizeW / sizeof(WCHAR);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-11-21 15:48:18 +00:00
|
|
|
|
|
|
|
profileW = HeapAlloc( GetProcessHeap(), 0, sizeW );
|
|
|
|
|
|
|
|
if (profileW)
|
|
|
|
{
|
|
|
|
ret = GetStandardColorSpaceProfileW( NULL, id, profileW, &sizeW );
|
|
|
|
*size = WideCharToMultiByte( CP_ACP, 0, profileW, -1, NULL, 0, NULL, NULL );
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, profileW, *size, profile, *size, NULL, NULL );
|
|
|
|
if (!len) ret = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, profileW );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-03-09 18:42:52 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* GetStandardColorSpaceProfileW [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Retrieve the profile filename for a given standard color space id.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* machine [I] Name of the machine for which to get the standard color space.
|
|
|
|
* Must be NULL, which indicates the local machine.
|
|
|
|
* id [I] Id of a standard color space.
|
2005-03-23 13:15:18 +00:00
|
|
|
* profile [O] Buffer to receive the profile filename.
|
2005-03-09 18:42:52 +00:00
|
|
|
* size [I/O] Size of the filename buffer in bytes.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
2004-11-21 15:48:18 +00:00
|
|
|
BOOL WINAPI GetStandardColorSpaceProfileW( PCWSTR machine, DWORD id, PWSTR profile, PDWORD size )
|
|
|
|
{
|
2005-07-05 10:56:52 +00:00
|
|
|
static const WCHAR rgbprofilefile[] =
|
|
|
|
{ '\\','s','r','g','b',' ','c','o','l','o','r',' ',
|
|
|
|
's','p','a','c','e',' ','p','r','o','f','i','l','e','.','i','c','m',0 };
|
2005-04-11 18:49:40 +00:00
|
|
|
WCHAR rgbprofile[MAX_PATH];
|
2005-07-05 10:56:52 +00:00
|
|
|
DWORD len = sizeof(rgbprofile);
|
2004-11-21 15:48:18 +00:00
|
|
|
|
2004-12-07 14:42:47 +00:00
|
|
|
TRACE( "( 0x%08lx, %p, %p )\n", id, profile, size );
|
|
|
|
|
2006-01-13 13:09:04 +00:00
|
|
|
if (machine)
|
|
|
|
{
|
2006-02-20 10:13:28 +00:00
|
|
|
SetLastError( ERROR_NOT_SUPPORTED );
|
2006-01-13 13:09:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!size)
|
|
|
|
{
|
2006-02-20 10:13:28 +00:00
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
2006-01-13 13:09:04 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2005-07-05 10:56:52 +00:00
|
|
|
GetColorDirectoryW( machine, rgbprofile, &len );
|
2004-12-07 14:42:47 +00:00
|
|
|
|
|
|
|
switch (id)
|
|
|
|
{
|
|
|
|
case 0x52474220: /* 'RGB ' */
|
2005-04-11 18:49:40 +00:00
|
|
|
lstrcatW( rgbprofile, rgbprofilefile );
|
2005-07-05 10:56:52 +00:00
|
|
|
len = lstrlenW( rgbprofile ) * sizeof(WCHAR);
|
2004-12-07 14:42:47 +00:00
|
|
|
|
|
|
|
if (*size < len || !profile)
|
|
|
|
{
|
|
|
|
*size = len;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
lstrcpyW( profile, rgbprofile );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2004-11-21 15:48:18 +00:00
|
|
|
}
|
|
|
|
|
2004-11-19 18:22:20 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* InstallColorProfileA [MSCMS.@]
|
|
|
|
*
|
|
|
|
* See InstallColorProfileW.
|
|
|
|
*/
|
2004-10-07 19:12:41 +00:00
|
|
|
BOOL WINAPI InstallColorProfileA( PCSTR machine, PCSTR profile )
|
|
|
|
{
|
|
|
|
UINT len;
|
|
|
|
LPWSTR profileW;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE( "( %s )\n", debugstr_a(profile) );
|
|
|
|
|
|
|
|
if (machine || !profile) return FALSE;
|
|
|
|
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
|
|
|
|
profileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
|
|
|
|
|
|
if (profileW)
|
|
|
|
{
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
|
|
|
|
|
|
|
|
ret = InstallColorProfileW( NULL, profileW );
|
|
|
|
HeapFree( GetProcessHeap(), 0, profileW );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-11-19 18:22:20 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* InstallColorProfileW [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Install a color profile.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* machine [I] Name of the machine to install the profile on. Must be NULL,
|
|
|
|
* which indicates the local machine.
|
|
|
|
* profile [I] Full path name of the profile to install.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
2004-10-07 19:12:41 +00:00
|
|
|
BOOL WINAPI InstallColorProfileW( PCWSTR machine, PCWSTR profile )
|
|
|
|
{
|
2004-11-03 22:14:25 +00:00
|
|
|
WCHAR dest[MAX_PATH], base[MAX_PATH];
|
|
|
|
DWORD size = sizeof(dest);
|
|
|
|
static const WCHAR slash[] = { '\\', 0 };
|
|
|
|
|
|
|
|
TRACE( "( %s )\n", debugstr_w(profile) );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
|
|
|
if (machine || !profile) return FALSE;
|
|
|
|
|
2004-11-03 22:14:25 +00:00
|
|
|
if (!GetColorDirectoryW( machine, dest, &size )) return FALSE;
|
|
|
|
|
|
|
|
MSCMS_basename( profile, base );
|
|
|
|
|
|
|
|
lstrcatW( dest, slash );
|
|
|
|
lstrcatW( dest, base );
|
|
|
|
|
|
|
|
/* Is source equal to destination? */
|
|
|
|
if (!lstrcmpW( profile, dest )) return TRUE;
|
|
|
|
|
|
|
|
return CopyFileW( profile, dest, TRUE );
|
2004-10-07 19:12:41 +00:00
|
|
|
}
|
|
|
|
|
2004-11-21 15:48:18 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* IsColorProfileTagPresent [MSCMS.@]
|
|
|
|
*
|
2004-12-13 13:23:17 +00:00
|
|
|
* Determine if a given ICC tag type is present in a color profile.
|
2004-11-21 15:48:18 +00:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* profile [I] Color profile handle.
|
2004-12-13 13:23:17 +00:00
|
|
|
* tag [I] ICC tag type.
|
|
|
|
* present [O] Pointer to a BOOL variable. Set to TRUE if tag type is present,
|
2004-11-21 15:48:18 +00:00
|
|
|
* FALSE otherwise.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
2004-12-13 13:23:17 +00:00
|
|
|
BOOL WINAPI IsColorProfileTagPresent( HPROFILE profile, TAGTYPE type, PBOOL present )
|
2004-11-21 15:48:18 +00:00
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2005-02-21 18:38:15 +00:00
|
|
|
icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile );
|
|
|
|
DWORD i, count;
|
|
|
|
icTag tag;
|
2004-11-21 15:48:18 +00:00
|
|
|
|
2004-12-13 13:23:17 +00:00
|
|
|
TRACE( "( %p, 0x%08lx, %p )\n", profile, type, present );
|
2004-11-21 15:48:18 +00:00
|
|
|
|
2005-02-21 18:38:15 +00:00
|
|
|
if (!iccprofile || !present) return FALSE;
|
|
|
|
|
|
|
|
count = MSCMS_get_tag_count( iccprofile );
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
MSCMS_get_tag_by_index( iccprofile, i, &tag );
|
|
|
|
|
|
|
|
if (tag.sig == type)
|
|
|
|
{
|
|
|
|
*present = ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-11-21 15:48:18 +00:00
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2005-02-21 18:38:15 +00:00
|
|
|
return ret;
|
2004-11-21 15:48:18 +00:00
|
|
|
}
|
|
|
|
|
2004-11-19 18:22:20 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* IsColorProfileValid [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Determine if a given color profile is valid.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* profile [I] Color profile handle.
|
|
|
|
* valid [O] Pointer to a BOOL variable. Set to TRUE if profile is valid,
|
|
|
|
* FALSE otherwise.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsColorProfileValid( HPROFILE profile, PBOOL valid )
|
|
|
|
{
|
2004-11-30 21:06:14 +00:00
|
|
|
BOOL ret = FALSE;
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2004-11-30 21:06:14 +00:00
|
|
|
icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile );
|
|
|
|
|
|
|
|
TRACE( "( %p, %p )\n", profile, valid );
|
2004-11-19 18:22:20 +00:00
|
|
|
|
2004-11-30 21:06:14 +00:00
|
|
|
if (!valid) return FALSE;
|
|
|
|
if (iccprofile) return *valid = TRUE;
|
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2004-11-30 21:06:14 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-12-13 13:23:17 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* SetColorProfileElement [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Set data for a specified tag type.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* profile [I] Handle to a color profile.
|
|
|
|
* type [I] ICC tag type.
|
|
|
|
* offset [I] Offset in bytes to start copying to.
|
|
|
|
* size [I/O] Size of the buffer in bytes. On return the variable holds the
|
|
|
|
* number of bytes actually needed.
|
|
|
|
* buffer [O] Buffer holding the tag data.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetColorProfileElement( HPROFILE profile, TAGTYPE type, DWORD offset, PDWORD size,
|
|
|
|
PVOID buffer )
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2004-12-13 13:23:17 +00:00
|
|
|
icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile );
|
2005-02-14 20:53:59 +00:00
|
|
|
DWORD i, count, access = MSCMS_hprofile2access( profile );
|
2004-12-13 13:23:17 +00:00
|
|
|
icTag tag;
|
|
|
|
|
|
|
|
TRACE( "( %p, 0x%08lx, %ld, %p, %p )\n", profile, type, offset, size, buffer );
|
|
|
|
|
|
|
|
if (!iccprofile || !size || !buffer) return FALSE;
|
2005-02-14 20:53:59 +00:00
|
|
|
if (!(access & PROFILE_READWRITE)) return FALSE;
|
|
|
|
|
2004-12-13 13:23:17 +00:00
|
|
|
count = MSCMS_get_tag_count( iccprofile );
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
MSCMS_get_tag_by_index( iccprofile, i, &tag );
|
|
|
|
|
|
|
|
if (tag.sig == type)
|
|
|
|
{
|
|
|
|
if (offset > tag.size) return FALSE;
|
|
|
|
|
|
|
|
MSCMS_set_tag_data( iccprofile, &tag, offset, buffer );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2004-12-13 13:23:17 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-03-09 18:42:52 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* SetColorProfileHeader [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Set header data for a given profile.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* profile [I] Handle to a color profile.
|
|
|
|
* header [I] Buffer holding the header data.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
2004-11-30 21:06:14 +00:00
|
|
|
BOOL WINAPI SetColorProfileHeader( HPROFILE profile, PPROFILEHEADER header )
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2004-11-30 21:06:14 +00:00
|
|
|
icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile );
|
2005-02-14 20:53:59 +00:00
|
|
|
DWORD access = MSCMS_hprofile2access( profile );
|
2004-11-30 21:06:14 +00:00
|
|
|
|
|
|
|
TRACE( "( %p, %p )\n", profile, header );
|
|
|
|
|
|
|
|
if (!iccprofile || !header) return FALSE;
|
2005-02-14 20:53:59 +00:00
|
|
|
if (!(access & PROFILE_READWRITE)) return FALSE;
|
2004-11-30 21:06:14 +00:00
|
|
|
|
|
|
|
MSCMS_set_profile_header( iccprofile, header );
|
|
|
|
return TRUE;
|
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2004-11-30 21:06:14 +00:00
|
|
|
return ret;
|
2004-11-19 18:22:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* UninstallColorProfileA [MSCMS.@]
|
|
|
|
*
|
|
|
|
* See UninstallColorProfileW.
|
|
|
|
*/
|
2004-10-07 19:12:41 +00:00
|
|
|
BOOL WINAPI UninstallColorProfileA( PCSTR machine, PCSTR profile, BOOL delete )
|
|
|
|
{
|
2004-11-03 22:14:25 +00:00
|
|
|
UINT len;
|
|
|
|
LPWSTR profileW;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
2004-11-19 18:22:20 +00:00
|
|
|
TRACE( "( %s, %x )\n", debugstr_a(profile), delete );
|
2004-11-03 22:14:25 +00:00
|
|
|
|
2004-10-07 19:12:41 +00:00
|
|
|
if (machine || !profile) return FALSE;
|
|
|
|
|
2004-11-03 22:14:25 +00:00
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, profile, -1, NULL, 0 );
|
|
|
|
profileW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2004-11-03 22:14:25 +00:00
|
|
|
if (profileW)
|
|
|
|
{
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, profile, -1, profileW, len );
|
|
|
|
|
|
|
|
ret = UninstallColorProfileW( NULL, profileW , delete );
|
|
|
|
|
|
|
|
HeapFree( GetProcessHeap(), 0, profileW );
|
|
|
|
}
|
|
|
|
return ret;
|
2004-10-07 19:12:41 +00:00
|
|
|
}
|
|
|
|
|
2004-11-19 18:22:20 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* UninstallColorProfileW [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Uninstall a color profile.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* machine [I] Name of the machine to uninstall the profile on. Must be NULL,
|
|
|
|
* which indicates the local machine.
|
|
|
|
* profile [I] Full path name of the profile to uninstall.
|
|
|
|
* delete [I] Bool that specifies whether the profile file should be deleted.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
2004-10-07 19:12:41 +00:00
|
|
|
BOOL WINAPI UninstallColorProfileW( PCWSTR machine, PCWSTR profile, BOOL delete )
|
|
|
|
{
|
2004-11-19 18:22:20 +00:00
|
|
|
TRACE( "( %s, %x )\n", debugstr_w(profile), delete );
|
|
|
|
|
2004-10-07 19:12:41 +00:00
|
|
|
if (machine || !profile) return FALSE;
|
|
|
|
|
2004-11-30 21:06:14 +00:00
|
|
|
if (delete) return DeleteFileW( profile );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-11-19 18:22:20 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* OpenColorProfileA [MSCMS.@]
|
|
|
|
*
|
|
|
|
* See OpenColorProfileW.
|
|
|
|
*/
|
2004-10-07 19:12:41 +00:00
|
|
|
HPROFILE WINAPI OpenColorProfileA( PPROFILE profile, DWORD access, DWORD sharing, DWORD creation )
|
|
|
|
{
|
|
|
|
HPROFILE handle = NULL;
|
|
|
|
|
2004-11-21 15:48:18 +00:00
|
|
|
TRACE( "( %p, 0x%08lx, 0x%08lx, 0x%08lx )\n", profile, access, sharing, creation );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
|
|
|
if (!profile || !profile->pProfileData) return NULL;
|
|
|
|
|
|
|
|
/* No AW conversion needed for memory based profiles */
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* OpenColorProfileW [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Open a color profile.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2004-11-19 18:22:20 +00:00
|
|
|
* profile [I] Pointer to a color profile structure.
|
|
|
|
* access [I] Desired access.
|
|
|
|
* sharing [I] Sharing mode.
|
|
|
|
* creation [I] Creation mode.
|
2004-10-07 19:12:41 +00:00
|
|
|
*
|
|
|
|
* RETURNS
|
2004-11-19 18:22:20 +00:00
|
|
|
* Success: Handle to the opened profile.
|
2004-10-07 19:12:41 +00:00
|
|
|
* Failure: NULL
|
|
|
|
*
|
|
|
|
* NOTES
|
2004-11-19 18:22:20 +00:00
|
|
|
* Values for access: PROFILE_READ or PROFILE_READWRITE.
|
|
|
|
* Values for sharing: 0 (no sharing), FILE_SHARE_READ and/or FILE_SHARE_WRITE.
|
2004-10-07 19:12:41 +00:00
|
|
|
* Values for creation: one of CREATE_NEW, CREATE_ALWAYS, OPEN_EXISTING,
|
|
|
|
* OPEN_ALWAYS, TRUNCATE_EXISTING.
|
2004-11-30 21:06:14 +00:00
|
|
|
* Sharing and creation flags are ignored for memory based profiles.
|
2004-10-07 19:12:41 +00:00
|
|
|
*/
|
|
|
|
HPROFILE WINAPI OpenColorProfileW( PPROFILE profile, DWORD access, DWORD sharing, DWORD creation )
|
|
|
|
{
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2004-10-07 19:12:41 +00:00
|
|
|
cmsHPROFILE cmsprofile = NULL;
|
2004-11-30 21:06:14 +00:00
|
|
|
icProfile *iccprofile = NULL;
|
2004-10-07 19:12:41 +00:00
|
|
|
HANDLE handle = NULL;
|
2004-11-30 21:06:14 +00:00
|
|
|
DWORD size;
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2004-11-21 15:48:18 +00:00
|
|
|
TRACE( "( %p, 0x%08lx, 0x%08lx, 0x%08lx )\n", profile, access, sharing, creation );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
|
|
|
if (!profile || !profile->pProfileData) return NULL;
|
|
|
|
|
|
|
|
if (profile->dwType & PROFILE_MEMBUFFER)
|
|
|
|
{
|
2006-01-06 20:07:55 +00:00
|
|
|
/* FIXME: access flags not implemented for memory based profiles */
|
2004-11-30 21:06:14 +00:00
|
|
|
|
|
|
|
iccprofile = profile->pProfileData;
|
|
|
|
size = profile->cbDataSize;
|
|
|
|
|
|
|
|
cmsprofile = cmsOpenProfileFromMem( iccprofile, size );
|
2004-10-07 19:12:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (profile->dwType & PROFILE_FILENAME)
|
|
|
|
{
|
2004-11-30 21:06:14 +00:00
|
|
|
DWORD read, flags = 0;
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2004-11-30 21:06:14 +00:00
|
|
|
TRACE( "profile file: %s\n", debugstr_w( (WCHAR *)profile->pProfileData ) );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
|
|
|
if (access & PROFILE_READ) flags = GENERIC_READ;
|
|
|
|
if (access & PROFILE_READWRITE) flags = GENERIC_READ|GENERIC_WRITE;
|
|
|
|
|
|
|
|
if (!flags) return NULL;
|
|
|
|
|
|
|
|
handle = CreateFileW( profile->pProfileData, flags, sharing, NULL, creation, 0, NULL );
|
2004-11-30 21:06:14 +00:00
|
|
|
if (handle == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
WARN( "Unable to open color profile\n" );
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2004-11-30 21:06:14 +00:00
|
|
|
if ((size = GetFileSize( handle, NULL )) == INVALID_FILE_SIZE)
|
|
|
|
{
|
|
|
|
ERR( "Unable to retrieve size of color profile\n" );
|
|
|
|
CloseHandle( handle );
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2005-03-24 21:01:35 +00:00
|
|
|
iccprofile = HeapAlloc( GetProcessHeap(), 0, size );
|
2004-11-30 21:06:14 +00:00
|
|
|
if (!iccprofile)
|
2004-10-07 19:12:41 +00:00
|
|
|
{
|
2004-11-30 21:06:14 +00:00
|
|
|
ERR( "Unable to allocate memory for color profile\n" );
|
|
|
|
CloseHandle( handle );
|
|
|
|
return NULL;
|
2004-10-07 19:12:41 +00:00
|
|
|
}
|
2004-11-30 21:06:14 +00:00
|
|
|
|
|
|
|
if (!ReadFile( handle, iccprofile, size, &read, NULL ) || read != size)
|
|
|
|
{
|
|
|
|
ERR( "Unable to read color profile\n" );
|
|
|
|
|
|
|
|
CloseHandle( handle );
|
|
|
|
HeapFree( GetProcessHeap, 0, iccprofile );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmsprofile = cmsOpenProfileFromMem( iccprofile, size );
|
2004-10-07 19:12:41 +00:00
|
|
|
}
|
|
|
|
|
2004-11-30 21:06:14 +00:00
|
|
|
if (cmsprofile)
|
2005-02-14 20:53:59 +00:00
|
|
|
return MSCMS_create_hprofile_handle( handle, iccprofile, cmsprofile, access );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2004-10-07 19:12:41 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-10-08 21:02:22 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* CloseColorProfile [MSCMS.@]
|
|
|
|
*
|
|
|
|
* Close a color profile.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2004-11-19 18:22:20 +00:00
|
|
|
* profile [I] Handle to the profile.
|
2004-10-08 21:02:22 +00:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
2004-10-07 19:12:41 +00:00
|
|
|
BOOL WINAPI CloseColorProfile( HPROFILE profile )
|
|
|
|
{
|
2004-11-30 21:06:14 +00:00
|
|
|
BOOL ret = FALSE;
|
2005-07-18 15:10:36 +00:00
|
|
|
#ifdef HAVE_LCMS
|
2005-02-14 20:53:59 +00:00
|
|
|
icProfile *iccprofile = MSCMS_hprofile2iccprofile( profile );
|
|
|
|
HANDLE file = MSCMS_hprofile2handle( profile );
|
|
|
|
DWORD access = MSCMS_hprofile2access( profile );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
|
|
|
TRACE( "( %p )\n", profile );
|
|
|
|
|
2005-02-14 20:53:59 +00:00
|
|
|
if (file && (access & PROFILE_READWRITE))
|
|
|
|
{
|
|
|
|
DWORD written, size = MSCMS_get_profile_size( iccprofile );
|
|
|
|
|
|
|
|
if (SetFilePointer( file, 0, NULL, FILE_BEGIN ) ||
|
|
|
|
!WriteFile( file, iccprofile, size, &written, NULL ) || written != size)
|
|
|
|
ERR( "Unable to write color profile\n" );
|
|
|
|
}
|
2004-11-30 21:06:14 +00:00
|
|
|
|
2005-02-14 20:53:59 +00:00
|
|
|
ret = cmsCloseProfile( MSCMS_hprofile2cmsprofile( profile ) );
|
2004-11-30 21:06:14 +00:00
|
|
|
HeapFree( GetProcessHeap(), 0, MSCMS_hprofile2iccprofile( profile ) );
|
2004-10-07 19:12:41 +00:00
|
|
|
|
2005-02-14 20:53:59 +00:00
|
|
|
CloseHandle( MSCMS_hprofile2handle( profile ) );
|
2004-10-07 19:12:41 +00:00
|
|
|
MSCMS_destroy_hprofile_handle( profile );
|
|
|
|
|
2005-07-18 15:10:36 +00:00
|
|
|
#endif /* HAVE_LCMS */
|
2004-11-30 21:06:14 +00:00
|
|
|
return ret;
|
2004-10-07 19:12:41 +00:00
|
|
|
}
|