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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/*
* 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
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winnls.h"
#include "winreg.h"
#include "gdi_private.h"
#include "wine/debug.h"
#include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(icm);
struct enum_profiles
{
ICMENUMPROCA funcA;
LPARAM data;
};
static INT CALLBACK enum_profiles_callbackA( LPWSTR filename, LPARAM lparam )
{
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 );
ret = ep->funcA( filenameA, ep->data );
HeapFree( GetProcessHeap(), 0, filenameA );
}
return ret;
}
/***********************************************************************
* EnumICMProfilesA (GDI32.@)
*/
INT WINAPI EnumICMProfilesA(HDC hdc, ICMENUMPROCA func, LPARAM lparam)
{
struct enum_profiles ep;
if (!func) return -1;
ep.funcA = func;
ep.data = lparam;
return EnumICMProfilesW( hdc, enum_profiles_callbackA, (LPARAM)&ep );
}
/***********************************************************************
* EnumICMProfilesW (GDI32.@)
*/
INT WINAPI EnumICMProfilesW(HDC hdc, ICMENUMPROCW func, LPARAM lparam)
{
DC *dc;
INT ret = -1;
TRACE("%p, %p, 0x%08lx\n", hdc, func, lparam);
if (!func) return -1;
if ((dc = get_dc_ptr(hdc)))
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pEnumICMProfiles );
ret = physdev->funcs->pEnumICMProfiles( physdev, func, lparam );
release_dc_ptr(dc);
}
return ret;
}
/**********************************************************************
* 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)
{
BOOL ret = FALSE;
DC *dc = get_dc_ptr(hdc);
TRACE("%p, %p, %p\n", hdc, size, filename);
if (dc)
{
PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetICMProfile );
ret = physdev->funcs->pGetICMProfile( physdev, size, filename );
release_dc_ptr(dc);
}
return ret;
}
/**********************************************************************
* 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));
if (!filename)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
if (!hdc)
{
SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
return TRUE;
}
/**********************************************************************
* SetICMProfileW (GDI32.@)
*/
BOOL WINAPI SetICMProfileW(HDC hdc, LPWSTR filename)
{
FIXME("%p %s stub\n", hdc, debugstr_w(filename));
if (!filename)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
if (!hdc)
{
SetLastError( ERROR_INVALID_HANDLE );
return FALSE;
}
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;
}