gdi32: Make GetICMProfile behave more like native. Rewrite ansi version as a wrapper and move color management functions to their own file.

This commit is contained in:
Hans Leidekker 2008-01-21 16:33:03 +01:00 committed by Alexandre Julliard
parent 6f3607af0b
commit 20c1e503e9
2 changed files with 139 additions and 146 deletions

View File

@ -2,6 +2,7 @@
* Image Color Management
*
* Copyright 2004 Marcus Meissner
* Copyright 2008 Hans Leidekker
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -22,11 +23,14 @@
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winnls.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(icm);
@ -34,15 +38,146 @@ WINE_DEFAULT_DEBUG_CHANNEL(icm);
/***********************************************************************
* EnumICMProfilesA (GDI32.@)
*/
INT WINAPI EnumICMProfilesA(HDC hdc,ICMENUMPROCA func,LPARAM lParam) {
FIXME("(%p, %p, 0x%08lx), stub.\n",hdc,func,lParam);
INT WINAPI EnumICMProfilesA(HDC hdc, ICMENUMPROCA func, LPARAM lparam)
{
FIXME("%p, %p, 0x%08lx stub\n", hdc, func, lparam);
return -1;
}
/***********************************************************************
* EnumICMProfilesW (GDI32.@)
*/
INT WINAPI EnumICMProfilesW(HDC hdc,ICMENUMPROCW func,LPARAM lParam) {
FIXME("(%p, %p, 0x%08lx), stub.\n",hdc,func,lParam);
INT WINAPI EnumICMProfilesW(HDC hdc, ICMENUMPROCW func, LPARAM lparam)
{
FIXME("%p, %p, 0x%08lx stub\n", hdc, func, lparam);
return -1;
}
/**********************************************************************
* 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);
if (!hdc || !size || !filename) return FALSE;
if (GetICMProfileW(hdc, &buflen, filenameW))
{
int len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL);
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)
{
DWORD required;
WCHAR systemdir[MAX_PATH];
static const WCHAR profile[] =
{'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s',
'\\','c','o','l','o','r','\\','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};
TRACE("%p, %p, %p\n", hdc, size, filename);
if (!hdc || !size) return FALSE;
required = GetSystemDirectoryW(systemdir, MAX_PATH);
required += sizeof(profile) / sizeof(WCHAR);
if (*size < required)
{
*size = required;
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
if (filename)
{
strcpyW(filename, systemdir);
strcatW(filename, profile);
if (GetFileAttributesW(filename) == INVALID_FILE_ATTRIBUTES)
WARN("color profile not found\n");
}
*size = required;
return TRUE;
}
/**********************************************************************
* 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));
return TRUE;
}
/**********************************************************************
* SetICMProfileW (GDI32.@)
*/
BOOL WINAPI SetICMProfileW(HDC hdc, LPWSTR filename)
{
FIXME("%p %s stub\n", hdc, debugstr_w(filename));
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;
}

View File

@ -876,145 +876,3 @@ BOOL WINAPI SetMagicColors(HDC hdc, ULONG u1, ULONG u2)
FIXME("(%p 0x%08x 0x%08x): stub\n", hdc, u1, u2);
return TRUE;
}
/**********************************************************************
* 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 name copied successfully OR lpszFilename is NULL
* FALSE if the buffer length pointed to by lpcbName is too small
*
* NOTE
* The buffer length pointed to by lpcbName is ALWAYS updated to
* the length required regardless of other actions this function
* may take.
*
* FIXME
* How does Windows assign these? Some registry key?
*/
/*********************************************************************/
BOOL WINAPI GetICMProfileA(HDC hDC, LPDWORD lpcbName, LPSTR lpszFilename)
{
DWORD callerLen;
static const char icm[] = "winefake.icm";
FIXME("(%p, %p, %p): partial stub\n", hDC, lpcbName, lpszFilename);
callerLen = *lpcbName;
/* all 3 behaviors require the required buffer size to be set */
*lpcbName = sizeof(icm);
/* behavior 1: if lpszFilename is NULL, return size of string and no error */
if (!lpszFilename) return TRUE;
/* behavior 2: if buffer size too small, return size of string and error */
if (callerLen < sizeof(icm))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
/* behavior 3: if buffer size OK and pointer not NULL, copy and return size */
memcpy(lpszFilename, icm, sizeof(icm));
return TRUE;
}
/**********************************************************************
* GetICMProfileW [GDI32.@]
**/
BOOL WINAPI GetICMProfileW(HDC hDC, LPDWORD lpcbName, LPWSTR lpszFilename)
{
DWORD callerLen;
static const WCHAR icm[] = { 'w','i','n','e','f','a','k','e','.','i','c','m', 0 };
FIXME("(%p, %p, %p): partial stub\n", hDC, lpcbName, lpszFilename);
callerLen = *lpcbName;
/* all 3 behaviors require the required buffer size to be set */
*lpcbName = sizeof(icm) / sizeof(WCHAR);
/* behavior 1: if lpszFilename is NULL, return size of string and no error */
if (!lpszFilename) return TRUE;
/* behavior 2: if buffer size too small, return size of string and error */
if (callerLen < sizeof(icm)/sizeof(WCHAR))
{
SetLastError(ERROR_INSUFFICIENT_BUFFER);
return FALSE;
}
/* behavior 3: if buffer size OK and pointer not NULL, copy and return size */
memcpy(lpszFilename, icm, sizeof(icm));
return TRUE;
}
/**********************************************************************
* GetLogColorSpaceA [GDI32.@]
*
*/
BOOL WINAPI GetLogColorSpaceA(HCOLORSPACE hColorSpace, LPLOGCOLORSPACEA lpBuffer, DWORD nSize)
{
FIXME("%p %p 0x%08x: stub!\n", hColorSpace, lpBuffer, nSize);
return FALSE;
}
/**********************************************************************
* GetLogColorSpaceW [GDI32.@]
*
*/
BOOL WINAPI GetLogColorSpaceW(HCOLORSPACE hColorSpace, LPLOGCOLORSPACEW lpBuffer, DWORD nSize)
{
FIXME("%p %p 0x%08x: stub!\n", hColorSpace, lpBuffer, nSize);
return FALSE;
}
/**********************************************************************
* SetICMProfileA [GDI32.@]
*
*/
BOOL WINAPI SetICMProfileA(HDC hDC, LPSTR lpszFilename)
{
FIXME("hDC %p filename %s: stub!\n", hDC, debugstr_a(lpszFilename));
return TRUE; /* success */
}
/**********************************************************************
* SetICMProfileA [GDI32.@]
*
*/
BOOL WINAPI SetICMProfileW(HDC hDC, LPWSTR lpszFilename)
{
FIXME("hDC %p filename %s: stub!\n", hDC, debugstr_w(lpszFilename));
return TRUE; /* success */
}
/**********************************************************************
* UpdateICMRegKeyA [GDI32.@]
*
*/
BOOL WINAPI UpdateICMRegKeyA(DWORD dwReserved, LPSTR lpszCMID, LPSTR lpszFileName, UINT nCommand)
{
FIXME("(0x%08x, %s, %s, 0x%08x): stub!\n", dwReserved, debugstr_a(lpszCMID),
debugstr_a(lpszFileName), nCommand);
return TRUE; /* success */
}
/**********************************************************************
* UpdateICMRegKeyW [GDI32.@]
*
*/
BOOL WINAPI UpdateICMRegKeyW(DWORD dwReserved, LPWSTR lpszCMID, LPWSTR lpszFileName, UINT nCommand)
{
FIXME("(0x%08x, %s, %s, 0x%08x): stub!\n", dwReserved, debugstr_w(lpszCMID),
debugstr_w(lpszFileName), nCommand);
return TRUE; /* success */
}