gdi32: Use NtGdiPolyPolyDraw for PolylineTo implementation.
[wine.git] / dlls / gdi32 / icm.c
blobb86771a6f878cf53fc670df16934483facd71856
1 /*
2 * Image Color Management
4 * Copyright 2004 Marcus Meissner
5 * Copyright 2008 Hans Leidekker
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include <stdarg.h>
23 #include <string.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winnls.h"
29 #include "winreg.h"
31 #include "ntgdi_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(icm);
38 struct enum_profiles
40 ICMENUMPROCA funcA;
41 LPARAM data;
44 static INT CALLBACK enum_profiles_callbackA( LPWSTR filename, LPARAM lparam )
46 int len, ret = -1;
47 struct enum_profiles *ep = (struct enum_profiles *)lparam;
48 char *filenameA;
50 len = WideCharToMultiByte( CP_ACP, 0, filename, -1, NULL, 0, NULL, NULL );
51 filenameA = HeapAlloc( GetProcessHeap(), 0, len );
52 if (filenameA)
54 WideCharToMultiByte( CP_ACP, 0, filename, -1, filenameA, len, NULL, NULL );
55 ret = ep->funcA( filenameA, ep->data );
56 HeapFree( GetProcessHeap(), 0, filenameA );
58 return ret;
61 /***********************************************************************
62 * EnumICMProfilesA (GDI32.@)
64 INT WINAPI EnumICMProfilesA(HDC hdc, ICMENUMPROCA func, LPARAM lparam)
66 struct enum_profiles ep;
68 if (!func) return -1;
69 ep.funcA = func;
70 ep.data = lparam;
71 return EnumICMProfilesW( hdc, enum_profiles_callbackA, (LPARAM)&ep );
74 /***********************************************************************
75 * EnumICMProfilesW (GDI32.@)
77 INT WINAPI EnumICMProfilesW(HDC hdc, ICMENUMPROCW func, LPARAM lparam)
79 DC *dc;
80 INT ret = -1;
82 TRACE("%p, %p, 0x%08lx\n", hdc, func, lparam);
84 if (!func) return -1;
85 if ((dc = get_dc_ptr(hdc)))
87 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pEnumICMProfiles );
88 ret = physdev->funcs->pEnumICMProfiles( physdev, func, lparam );
89 release_dc_ptr(dc);
91 return ret;
94 /**********************************************************************
95 * GetICMProfileA (GDI32.@)
97 * Returns the filename of the specified device context's color
98 * management profile, even if color management is not enabled
99 * for that DC.
101 * RETURNS
102 * TRUE if filename is copied successfully.
103 * FALSE if the buffer length pointed to by size is too small.
105 * FIXME
106 * How does Windows assign these? Some registry key?
108 BOOL WINAPI GetICMProfileA(HDC hdc, LPDWORD size, LPSTR filename)
110 WCHAR filenameW[MAX_PATH];
111 DWORD buflen = MAX_PATH;
112 BOOL ret = FALSE;
114 TRACE("%p, %p, %p\n", hdc, size, filename);
116 if (!hdc || !size) return FALSE;
118 if (GetICMProfileW(hdc, &buflen, filenameW))
120 int len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL);
122 if (!filename)
124 *size = len;
125 return FALSE;
128 if (*size >= len)
130 WideCharToMultiByte(CP_ACP, 0, filenameW, -1, filename, *size, NULL, NULL);
131 ret = TRUE;
133 else SetLastError(ERROR_INSUFFICIENT_BUFFER);
134 *size = len;
136 return ret;
139 /**********************************************************************
140 * GetICMProfileW (GDI32.@)
142 BOOL WINAPI GetICMProfileW(HDC hdc, LPDWORD size, LPWSTR filename)
144 BOOL ret = FALSE;
145 DC *dc = get_dc_ptr(hdc);
147 TRACE("%p, %p, %p\n", hdc, size, filename);
149 if (dc)
151 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pGetICMProfile );
152 ret = physdev->funcs->pGetICMProfile( physdev, size, filename );
153 release_dc_ptr(dc);
155 return ret;
158 /**********************************************************************
159 * GetLogColorSpaceA (GDI32.@)
161 BOOL WINAPI GetLogColorSpaceA(HCOLORSPACE colorspace, LPLOGCOLORSPACEA buffer, DWORD size)
163 FIXME("%p %p 0x%08x stub\n", colorspace, buffer, size);
164 return FALSE;
167 /**********************************************************************
168 * GetLogColorSpaceW (GDI32.@)
170 BOOL WINAPI GetLogColorSpaceW(HCOLORSPACE colorspace, LPLOGCOLORSPACEW buffer, DWORD size)
172 FIXME("%p %p 0x%08x stub\n", colorspace, buffer, size);
173 return FALSE;
176 /**********************************************************************
177 * SetICMProfileA (GDI32.@)
179 BOOL WINAPI SetICMProfileA(HDC hdc, LPSTR filename)
181 FIXME("%p %s stub\n", hdc, debugstr_a(filename));
183 if (!filename)
185 SetLastError( ERROR_INVALID_PARAMETER );
186 return FALSE;
188 if (!hdc)
190 SetLastError( ERROR_INVALID_HANDLE );
191 return FALSE;
193 return TRUE;
196 /**********************************************************************
197 * SetICMProfileW (GDI32.@)
199 BOOL WINAPI SetICMProfileW(HDC hdc, LPWSTR filename)
201 FIXME("%p %s stub\n", hdc, debugstr_w(filename));
203 if (!filename)
205 SetLastError( ERROR_INVALID_PARAMETER );
206 return FALSE;
208 if (!hdc)
210 SetLastError( ERROR_INVALID_HANDLE );
211 return FALSE;
213 return TRUE;
216 /**********************************************************************
217 * UpdateICMRegKeyA (GDI32.@)
219 BOOL WINAPI UpdateICMRegKeyA(DWORD reserved, LPSTR cmid, LPSTR filename, UINT command)
221 FIXME("0x%08x, %s, %s, 0x%08x stub\n", reserved, debugstr_a(cmid), debugstr_a(filename), command);
222 return TRUE;
225 /**********************************************************************
226 * UpdateICMRegKeyW (GDI32.@)
228 BOOL WINAPI UpdateICMRegKeyW(DWORD reserved, LPWSTR cmid, LPWSTR filename, UINT command)
230 FIXME("0x%08x, %s, %s, 0x%08x stub\n", reserved, debugstr_w(cmid), debugstr_w(filename), command);
231 return TRUE;