* Sync up to trunk head (r65095).
[reactos.git] / win32ss / gdi / gdi32 / objects / icm.c
1 #include <precomp.h>
2
3 #define NDEBUG
4 #include <debug.h>
5
6
7 HCOLORSPACE
8 FASTCALL
9 IntCreateColorSpaceW(
10 LPLOGCOLORSPACEW lplcpw,
11 BOOL Ascii
12 )
13 {
14 LOGCOLORSPACEEXW lcpeexw;
15
16 if ((lplcpw->lcsSignature != LCS_SIGNATURE) ||
17 (lplcpw->lcsVersion != 0x400) ||
18 (lplcpw->lcsSize != sizeof(LOGCOLORSPACEW)))
19 {
20 SetLastError(ERROR_INVALID_COLORSPACE);
21 return NULL;
22 }
23 RtlCopyMemory(&lcpeexw.lcsColorSpace, lplcpw, sizeof(LOGCOLORSPACEW));
24
25 return NtGdiCreateColorSpace(&lcpeexw);
26 }
27
28 /*
29 * @implemented
30 */
31 HCOLORSPACE
32 WINAPI
33 CreateColorSpaceW(
34 LPLOGCOLORSPACEW lplcpw
35 )
36 {
37 return IntCreateColorSpaceW(lplcpw, FALSE);
38 }
39
40
41 /*
42 * @implemented
43 */
44 HCOLORSPACE
45 WINAPI
46 CreateColorSpaceA(
47 LPLOGCOLORSPACEA lplcpa
48 )
49 {
50 LOGCOLORSPACEW lcpw;
51
52 if ((lplcpa->lcsSignature != LCS_SIGNATURE) ||
53 (lplcpa->lcsVersion != 0x400) ||
54 (lplcpa->lcsSize != sizeof(LOGCOLORSPACEA)))
55 {
56 SetLastError(ERROR_INVALID_COLORSPACE);
57 return NULL;
58 }
59
60 lcpw.lcsSignature = lplcpa->lcsSignature;
61 lcpw.lcsVersion = lplcpa->lcsVersion;
62 lcpw.lcsSize = sizeof(LOGCOLORSPACEW);
63 lcpw.lcsCSType = lplcpa->lcsCSType;
64 lcpw.lcsIntent = lplcpa->lcsIntent;
65 lcpw.lcsEndpoints = lplcpa->lcsEndpoints;
66 lcpw.lcsGammaRed = lplcpa->lcsGammaRed;
67 lcpw.lcsGammaGreen = lplcpa->lcsGammaGreen;
68 lcpw.lcsGammaBlue = lplcpa->lcsGammaBlue;
69
70 RtlMultiByteToUnicodeN( lcpw.lcsFilename,
71 MAX_PATH,
72 NULL,
73 lplcpa->lcsFilename,
74 strlen(lplcpa->lcsFilename) + 1);
75
76 return IntCreateColorSpaceW(&lcpw, FALSE);
77 }
78
79 /*
80 * @implemented
81 */
82 HCOLORSPACE
83 WINAPI
84 GetColorSpace(HDC hDC)
85 {
86 PDC_ATTR pDc_Attr;
87
88 if (!GdiGetHandleUserData(hDC, GDI_OBJECT_TYPE_DC, (PVOID)&pDc_Attr))
89 {
90 SetLastError(ERROR_INVALID_HANDLE);
91 return NULL;
92 }
93 return pDc_Attr->hColorSpace;
94 }
95
96
97 /*
98 * @implemented
99 */
100 HCOLORSPACE
101 WINAPI
102 SetColorSpace(
103 HDC hDC,
104 HCOLORSPACE hCS
105 )
106 {
107 HCOLORSPACE rhCS = GetColorSpace(hDC);
108
109 if (GDI_HANDLE_GET_TYPE(hDC) == GDI_OBJECT_TYPE_DC)
110 {
111 if (NtGdiSetColorSpace(hDC, hCS)) return rhCS;
112 }
113 #if 0
114 if (GDI_HANDLE_GET_TYPE(hDC) != GDI_OBJECT_TYPE_METADC)
115 {
116 PLDC pLDC = GdiGetLDC(hDC);
117 if ( !pLDC )
118 {
119 SetLastError(ERROR_INVALID_HANDLE);
120 return NULL;
121 }
122 if (pLDC->iType == LDC_EMFLDC)
123 {
124 return NULL;
125 }
126 }
127 #endif
128 return NULL;
129 }
130
131
132 /*
133 * @unimplemented
134 */
135 BOOL
136 WINAPI
137 GetICMProfileA(
138 HDC hdc,
139 LPDWORD pBufSize,
140 LPSTR pszFilename
141 )
142 {
143 WCHAR filenameW[MAX_PATH];
144 DWORD buflen = MAX_PATH;
145 BOOL ret = FALSE;
146
147 if (!hdc || !pBufSize || !pszFilename) return FALSE;
148
149 if (GetICMProfileW(hdc, &buflen, filenameW))
150 {
151 ULONG len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL);
152 if (*pBufSize >= len)
153 {
154 WideCharToMultiByte(CP_ACP, 0, filenameW, -1, pszFilename, *pBufSize, NULL, NULL);
155 ret = TRUE;
156 }
157 else SetLastError(ERROR_INSUFFICIENT_BUFFER);
158 *pBufSize = len;
159 }
160
161 return ret;
162 }
163
164
165 /*
166 * @unimplemented
167 */
168 BOOL
169 WINAPI
170 GetICMProfileW(
171 HDC hdc,
172 LPDWORD size,
173 LPWSTR filename
174 )
175 {
176 if (!hdc || !size || !filename) return FALSE;
177
178 UNIMPLEMENTED;
179 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
180 return FALSE;
181 }
182
183
184 /*
185 * @unimplemented
186 */
187 BOOL
188 WINAPI
189 SetICMProfileA(
190 HDC a0,
191 LPSTR a1
192 )
193 {
194 UNIMPLEMENTED;
195 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
196 return FALSE;
197 }
198
199
200 /*
201 * @unimplemented
202 */
203 BOOL
204 WINAPI
205 SetICMProfileW(
206 HDC a0,
207 LPWSTR a1
208 )
209 {
210 UNIMPLEMENTED;
211 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
212 return FALSE;
213 }
214
215
216 /*
217 * @unimplemented
218 */
219 int
220 WINAPI
221 EnumICMProfilesA(
222 HDC a0,
223 ICMENUMPROCA a1,
224 LPARAM a2
225 )
226 {
227 /*
228 * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer
229 * to find out how big a buffer we need. Then allocate that buffer
230 * and call NtGdiEnumICMProfiles again to have the buffer filled.
231 *
232 * Finally, step through the buffer ( MULTI-SZ recommended for format ),
233 * and convert each string to ANSI, calling the user's callback function
234 * until we run out of strings or the user returns FALSE
235 */
236
237 UNIMPLEMENTED;
238 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
239 return 0;
240 }
241
242
243 /*
244 * @unimplemented
245 */
246 int
247 WINAPI
248 EnumICMProfilesW(
249 HDC hDC,
250 ICMENUMPROCW lpEnumICMProfilesFunc,
251 LPARAM lParam
252 )
253 {
254 /*
255 * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer
256 * to find out how big a buffer we need. Then allocate that buffer
257 * and call NtGdiEnumICMProfiles again to have the buffer filled.
258 *
259 * Finally, step through the buffer ( MULTI-SZ recommended for format ),
260 * and call the user's callback function until we run out of strings or
261 * the user returns FALSE
262 */
263 UNIMPLEMENTED;
264 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
265 return 0;
266 }
267
268
269 /*
270 * @unimplemented
271 */
272 BOOL
273 WINAPI
274 UpdateICMRegKeyA(
275 DWORD a0,
276 LPSTR a1,
277 LPSTR a2,
278 UINT a3
279 )
280 {
281 UNIMPLEMENTED;
282 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
283 return FALSE;
284 }
285
286
287 /*
288 * @unimplemented
289 */
290 BOOL
291 WINAPI
292 UpdateICMRegKeyW(
293 DWORD a0,
294 LPWSTR a1,
295 LPWSTR a2,
296 UINT a3
297 )
298 {
299 UNIMPLEMENTED;
300 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
301 return FALSE;
302 }
303
304 /*
305 * @unimplemented
306 */
307 int
308 WINAPI
309 SetICMMode(
310 HDC hdc,
311 int iEnableICM
312 )
313 {
314 /*FIXME: Assume that ICM is always off, and cannot be turned on */
315 if (iEnableICM == ICM_OFF) return ICM_OFF;
316 if (iEnableICM == ICM_ON) return 0;
317 if (iEnableICM == ICM_QUERY) return ICM_OFF;
318
319 UNIMPLEMENTED;
320 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
321 return 0;
322 }