2004-01-13 06:20:17 +01:00
|
|
|
/*
|
|
|
|
* Image Color Management
|
|
|
|
*
|
|
|
|
* Copyright 2004 Marcus Meissner
|
2008-01-21 16:33:03 +01:00
|
|
|
* Copyright 2008 Hans Leidekker
|
2004-01-13 06:20:17 +01: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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-01-13 06:20:17 +01:00
|
|
|
*/
|
|
|
|
|
2021-09-09 14:02:03 +02:00
|
|
|
#include "gdi_private.h"
|
2008-01-21 16:33:03 +01:00
|
|
|
#include "winnls.h"
|
2008-03-05 15:57:21 +01:00
|
|
|
|
2004-01-13 06:20:17 +01:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(icm);
|
|
|
|
|
|
|
|
|
2010-10-26 12:40:41 +02:00
|
|
|
struct enum_profiles
|
|
|
|
{
|
2011-03-11 12:33:34 +01:00
|
|
|
ICMENUMPROCA funcA;
|
2010-10-26 12:40:41 +02:00
|
|
|
LPARAM data;
|
|
|
|
};
|
|
|
|
|
2011-03-11 12:33:34 +01:00
|
|
|
static INT CALLBACK enum_profiles_callbackA( LPWSTR filename, LPARAM lparam )
|
2010-10-26 12:40:41 +02:00
|
|
|
{
|
|
|
|
int len, ret = -1;
|
|
|
|
struct enum_profiles *ep = (struct enum_profiles *)lparam;
|
|
|
|
char *filenameA;
|
|
|
|
|
|
|
|
len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
|
|
|
|
filenameA = HeapAlloc( GetProcessHeap(), 0, len );
|
|
|
|
if (filenameA)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte( CP_ACP, 0, filename, -1, filenameA, len, NULL, NULL );
|
2011-03-11 12:33:34 +01:00
|
|
|
ret = ep->funcA( filenameA, ep->data );
|
2010-10-26 12:40:41 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, filenameA );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-01-13 06:20:17 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* EnumICMProfilesA (GDI32.@)
|
|
|
|
*/
|
2008-01-21 16:33:03 +01:00
|
|
|
INT WINAPI EnumICMProfilesA(HDC hdc, ICMENUMPROCA func, LPARAM lparam)
|
|
|
|
{
|
2011-03-11 12:33:34 +01:00
|
|
|
struct enum_profiles ep;
|
2010-10-26 12:41:49 +02:00
|
|
|
|
|
|
|
if (!func) return -1;
|
2011-03-11 12:33:34 +01:00
|
|
|
ep.funcA = func;
|
|
|
|
ep.data = lparam;
|
|
|
|
return EnumICMProfilesW( hdc, enum_profiles_callbackA, (LPARAM)&ep );
|
2004-01-13 06:20:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EnumICMProfilesW (GDI32.@)
|
|
|
|
*/
|
2008-01-21 16:33:03 +01:00
|
|
|
INT WINAPI EnumICMProfilesW(HDC hdc, ICMENUMPROCW func, LPARAM lparam)
|
|
|
|
{
|
2021-09-09 14:01:51 +02:00
|
|
|
WCHAR profile[MAX_PATH];
|
|
|
|
DWORD size = ARRAYSIZE(profile);
|
2010-10-26 12:40:41 +02:00
|
|
|
|
2021-09-09 14:01:51 +02:00
|
|
|
TRACE( "%p, %p, 0x%08lx\n", hdc, func, lparam );
|
2010-10-26 12:41:49 +02:00
|
|
|
|
|
|
|
if (!func) return -1;
|
2021-10-06 16:20:26 +02:00
|
|
|
if (!__wine_get_icm_profile( hdc, FALSE, &size, profile )) return -1;
|
2021-09-09 14:01:51 +02:00
|
|
|
/* FIXME: support multiple profiles */
|
2021-09-09 14:02:03 +02:00
|
|
|
return func( profile, lparam );
|
2004-01-13 06:20:17 +01:00
|
|
|
}
|
2008-01-21 16:33:03 +01:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetICMProfileA (GDI32.@)
|
|
|
|
*
|
|
|
|
* Returns the filename of the specified device context's color
|
|
|
|
* management profile, even if color management is not enabled
|
|
|
|
* for that DC.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE if filename is copied successfully.
|
|
|
|
* FALSE if the buffer length pointed to by size is too small.
|
|
|
|
*
|
|
|
|
* FIXME
|
|
|
|
* How does Windows assign these? Some registry key?
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetICMProfileA(HDC hdc, LPDWORD size, LPSTR filename)
|
|
|
|
{
|
|
|
|
WCHAR filenameW[MAX_PATH];
|
|
|
|
DWORD buflen = MAX_PATH;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
TRACE("%p, %p, %p\n", hdc, size, filename);
|
|
|
|
|
2015-12-21 10:22:41 +01:00
|
|
|
if (!hdc || !size) return FALSE;
|
2008-01-21 16:33:03 +01:00
|
|
|
|
|
|
|
if (GetICMProfileW(hdc, &buflen, filenameW))
|
|
|
|
{
|
|
|
|
int len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL);
|
2015-12-21 10:22:41 +01:00
|
|
|
|
|
|
|
if (!filename)
|
|
|
|
{
|
|
|
|
*size = len;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-01-21 16:33:03 +01:00
|
|
|
if (*size >= len)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, filenameW, -1, filename, *size, NULL, NULL);
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
*size = len;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetICMProfileW (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetICMProfileW(HDC hdc, LPDWORD size, LPWSTR filename)
|
|
|
|
{
|
|
|
|
TRACE("%p, %p, %p\n", hdc, size, filename);
|
|
|
|
|
2021-10-06 16:20:26 +02:00
|
|
|
return __wine_get_icm_profile( hdc, TRUE, size, filename );
|
2008-01-21 16:33:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetLogColorSpaceA (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetLogColorSpaceA(HCOLORSPACE colorspace, LPLOGCOLORSPACEA buffer, DWORD size)
|
|
|
|
{
|
|
|
|
FIXME("%p %p 0x%08x stub\n", colorspace, buffer, size);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetLogColorSpaceW (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetLogColorSpaceW(HCOLORSPACE colorspace, LPLOGCOLORSPACEW buffer, DWORD size)
|
|
|
|
{
|
|
|
|
FIXME("%p %p 0x%08x stub\n", colorspace, buffer, size);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* SetICMProfileA (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetICMProfileA(HDC hdc, LPSTR filename)
|
|
|
|
{
|
|
|
|
FIXME("%p %s stub\n", hdc, debugstr_a(filename));
|
2010-10-26 12:41:49 +02:00
|
|
|
|
|
|
|
if (!filename)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!hdc)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_HANDLE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-01-21 16:33:03 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* SetICMProfileW (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetICMProfileW(HDC hdc, LPWSTR filename)
|
|
|
|
{
|
|
|
|
FIXME("%p %s stub\n", hdc, debugstr_w(filename));
|
2010-10-26 12:41:49 +02:00
|
|
|
|
|
|
|
if (!filename)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!hdc)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_HANDLE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-01-21 16:33:03 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* UpdateICMRegKeyA (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI UpdateICMRegKeyA(DWORD reserved, LPSTR cmid, LPSTR filename, UINT command)
|
|
|
|
{
|
|
|
|
FIXME("0x%08x, %s, %s, 0x%08x stub\n", reserved, debugstr_a(cmid), debugstr_a(filename), command);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* UpdateICMRegKeyW (GDI32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI UpdateICMRegKeyW(DWORD reserved, LPWSTR cmid, LPWSTR filename, UINT command)
|
|
|
|
{
|
|
|
|
FIXME("0x%08x, %s, %s, 0x%08x stub\n", reserved, debugstr_w(cmid), debugstr_w(filename), command);
|
|
|
|
return TRUE;
|
|
|
|
}
|