xref: /reactos/win32ss/gdi/gdi32/objects/icm.c (revision 970344bd)
1 #include <precomp.h>
2 
3 #define NDEBUG
4 #include <debug.h>
5 
6 
7 HCOLORSPACE
8 FASTCALL
IntCreateColorSpaceW(LPLOGCOLORSPACEW lplcpw,BOOL Ascii)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
CreateColorSpaceW(LPLOGCOLORSPACEW lplcpw)33 CreateColorSpaceW(
34     LPLOGCOLORSPACEW lplcpw
35 )
36 {
37     return IntCreateColorSpaceW(lplcpw, FALSE);
38 }
39 
40 
41 /*
42  * @implemented
43  */
44 HCOLORSPACE
45 WINAPI
CreateColorSpaceA(LPLOGCOLORSPACEA lplcpa)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
GetColorSpace(HDC hDC)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
SetColorSpace(HDC hDC,HCOLORSPACE hCS)102 SetColorSpace(
103     HDC hDC,
104     HCOLORSPACE hCS
105 )
106 {
107     HCOLORSPACE rhCS = GetColorSpace(hDC);
108 
109     if (GDI_HANDLE_GET_TYPE(hDC) == GDILoObjType_LO_DC_TYPE)
110     {
111         if (NtGdiSetColorSpace(hDC, hCS)) return rhCS;
112     }
113 #if 0
114     if (GDI_HANDLE_GET_TYPE(hDC) != GDILoObjType_LO_METADC16_TYPE)
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 && !EMFDC_SetColorSpace( pLDC, hCS ))
123         {
124             return NULL;
125         }
126     }
127 #endif
128     return NULL;
129 }
130 
131 
132 /*
133  * @unimplemented
134  */
135 BOOL
136 WINAPI
GetICMProfileA(HDC hdc,LPDWORD pBufSize,LPSTR pszFilename)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) return FALSE;
148 
149     if (GetICMProfileW(hdc, &buflen, filenameW))
150     {
151         ULONG len = WideCharToMultiByte(CP_ACP, 0, filenameW, -1, NULL, 0, NULL, NULL);
152 
153         if (!pszFilename)
154         {
155             *pBufSize = len;
156             return FALSE;
157         }
158 
159         if (*pBufSize >= len)
160         {
161             WideCharToMultiByte(CP_ACP, 0, filenameW, -1, pszFilename, *pBufSize, NULL, NULL);
162             ret = TRUE;
163         }
164         else SetLastError(ERROR_INSUFFICIENT_BUFFER);
165         *pBufSize = len;
166     }
167 
168     return ret;
169 }
170 
171 
172 /*
173  * @unimplemented
174  */
175 BOOL
176 WINAPI
GetICMProfileW(HDC hdc,LPDWORD size,LPWSTR filename)177 GetICMProfileW(
178     HDC		hdc,
179     LPDWORD		size,
180     LPWSTR		filename
181 )
182 {
183     if (!hdc || !size || !filename) return FALSE;
184 
185     UNIMPLEMENTED;
186     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
187     return FALSE;
188 }
189 
190 
191 /*
192  * @unimplemented
193  */
194 BOOL
195 WINAPI
SetICMProfileA(HDC a0,LPSTR a1)196 SetICMProfileA(
197     HDC	a0,
198     LPSTR	a1
199 )
200 {
201     UNIMPLEMENTED;
202     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
203     return FALSE;
204 }
205 
206 
207 /*
208  * @unimplemented
209  */
210 BOOL
211 WINAPI
SetICMProfileW(HDC a0,LPWSTR a1)212 SetICMProfileW(
213     HDC	a0,
214     LPWSTR	a1
215 )
216 {
217     UNIMPLEMENTED;
218     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
219     return FALSE;
220 }
221 
222 
223 /*
224  * @unimplemented
225  */
226 int
227 WINAPI
EnumICMProfilesA(HDC a0,ICMENUMPROCA a1,LPARAM a2)228 EnumICMProfilesA(
229     HDC		a0,
230     ICMENUMPROCA	a1,
231     LPARAM		a2
232 )
233 {
234     /*
235      * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer
236      * to find out how big a buffer we need. Then allocate that buffer
237      * and call NtGdiEnumICMProfiles again to have the buffer filled.
238      *
239      * Finally, step through the buffer ( MULTI-SZ recommended for format ),
240      * and convert each string to ANSI, calling the user's callback function
241      * until we run out of strings or the user returns FALSE
242      */
243 
244     UNIMPLEMENTED;
245     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
246     return 0;
247 }
248 
249 
250 /*
251  * @unimplemented
252  */
253 int
254 WINAPI
EnumICMProfilesW(HDC hDC,ICMENUMPROCW lpEnumICMProfilesFunc,LPARAM lParam)255 EnumICMProfilesW(
256     HDC		hDC,
257     ICMENUMPROCW	lpEnumICMProfilesFunc,
258     LPARAM		lParam
259 )
260 {
261     /*
262      * FIXME - call NtGdiEnumICMProfiles with NULL for lpstrBuffer
263      * to find out how big a buffer we need. Then allocate that buffer
264      * and call NtGdiEnumICMProfiles again to have the buffer filled.
265      *
266      * Finally, step through the buffer ( MULTI-SZ recommended for format ),
267      * and call the user's callback function until we run out of strings or
268      * the user returns FALSE
269      */
270     UNIMPLEMENTED;
271     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
272     return 0;
273 }
274 
275 
276 /*
277  * @unimplemented
278  */
279 BOOL
280 WINAPI
UpdateICMRegKeyA(DWORD a0,LPSTR a1,LPSTR a2,UINT a3)281 UpdateICMRegKeyA(
282     DWORD	a0,
283     LPSTR	a1,
284     LPSTR	a2,
285     UINT	a3
286 )
287 {
288     UNIMPLEMENTED;
289     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
290     return FALSE;
291 }
292 
293 
294 /*
295  * @unimplemented
296  */
297 BOOL
298 WINAPI
UpdateICMRegKeyW(DWORD a0,LPWSTR a1,LPWSTR a2,UINT a3)299 UpdateICMRegKeyW(
300     DWORD	a0,
301     LPWSTR	a1,
302     LPWSTR	a2,
303     UINT	a3
304 )
305 {
306     UNIMPLEMENTED;
307     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
308     return FALSE;
309 }
310 
311 /*
312  * @unimplemented
313  */
314 int
315 WINAPI
SetICMMode(HDC hdc,int iEnableICM)316 SetICMMode(
317     HDC	hdc,
318     int	iEnableICM
319 )
320 {
321     /*FIXME:  Assume that ICM is always off, and cannot be turned on */
322     if (iEnableICM == ICM_OFF) return ICM_OFF;
323     if (iEnableICM == ICM_ON) return 0;
324     if (iEnableICM == ICM_QUERY) return ICM_OFF;
325 
326     UNIMPLEMENTED;
327     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
328     return 0;
329 }
330 
331 /*
332  * @unimplemented
333  *
334  */
335 HBITMAP
336 WINAPI
GdiConvertBitmapV5(HBITMAP in_format_BitMap,HBITMAP src_BitMap,INT bpp,INT unuse)337 GdiConvertBitmapV5(
338     HBITMAP in_format_BitMap,
339     HBITMAP src_BitMap,
340     INT bpp,
341     INT unuse)
342 {
343     /* FIXME guessing the prototypes */
344 
345     /*
346      * it have create a new bitmap with desired in format,
347      * then convert it src_bitmap to new format
348      * and return it as HBITMAP
349      */
350 
351     return FALSE;
352 }
353