ReactOS 0.4.15-dev-8102-g108db8f
transform.c File Reference
#include "config.h"
#include "wine/debug.h"
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "wingdi.h"
#include "winuser.h"
#include "icm.h"
#include "mscms_priv.h"
Include dependency graph for transform.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (mscms)
 
HTRANSFORM WINAPI CreateColorTransformA (LPLOGCOLORSPACEA space, HPROFILE dest, HPROFILE target, DWORD flags)
 
HTRANSFORM WINAPI CreateColorTransformW (LPLOGCOLORSPACEW space, HPROFILE dest, HPROFILE target, DWORD flags)
 
HTRANSFORM WINAPI CreateMultiProfileTransform (PHPROFILE profiles, DWORD nprofiles, PDWORD intents, DWORD nintents, DWORD flags, DWORD cmm)
 
BOOL WINAPI DeleteColorTransform (HTRANSFORM handle)
 
BOOL WINAPI TranslateBitmapBits (HTRANSFORM handle, PVOID srcbits, BMFORMAT input, DWORD width, DWORD height, DWORD inputstride, PVOID destbits, BMFORMAT output, DWORD outputstride, PBMCALLBACKFN callback, ULONG data)
 
BOOL WINAPI TranslateColors (HTRANSFORM handle, PCOLOR in, DWORD count, COLORTYPE input_type, PCOLOR out, COLORTYPE output_type)
 

Function Documentation

◆ CreateColorTransformA()

HTRANSFORM WINAPI CreateColorTransformA ( LPLOGCOLORSPACEA  space,
HPROFILE  dest,
HPROFILE  target,
DWORD  flags 
)

Definition at line 94 of file transform.c.

96{
98 DWORD len;
99
100 TRACE( "( %p, %p, %p, 0x%08x )\n", space, dest, target, flags );
101
102 if (!space || !dest) return FALSE;
103
104 memcpy( &spaceW, space, FIELD_OFFSET(LOGCOLORSPACEA, lcsFilename) );
105 spaceW.lcsSize = sizeof(LOGCOLORSPACEW);
106
107 len = MultiByteToWideChar( CP_ACP, 0, space->lcsFilename, -1, NULL, 0 );
108 MultiByteToWideChar( CP_ACP, 0, space->lcsFilename, -1, spaceW.lcsFilename, len );
109
111}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
HTRANSFORM WINAPI CreateColorTransformW(LPLOGCOLORSPACEW space, HPROFILE dest, HPROFILE target, DWORD flags)
Definition: transform.c:128
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
GLenum target
Definition: glext.h:7315
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static char * dest
Definition: rtl.c:135
static const WCHAR spaceW[]
Definition: mxwriter.c:44
#define TRACE(s)
Definition: solgame.cpp:4
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
struct tagLOGCOLORSPACEW LOGCOLORSPACEW

◆ CreateColorTransformW()

HTRANSFORM WINAPI CreateColorTransformW ( LPLOGCOLORSPACEW  space,
HPROFILE  dest,
HPROFILE  target,
DWORD  flags 
)

Definition at line 128 of file transform.c.

130{
132#ifdef HAVE_LCMS2
133 struct transform transform;
134 struct profile *dst, *tgt = NULL;
135 cmsHPROFILE cmsinput, cmsoutput, cmstarget = NULL;
136 DWORD proofing = 0;
137 int intent;
138
139 TRACE( "( %p, %p, %p, 0x%08x )\n", space, dest, target, flags );
140
141 if (!space || !(dst = grab_profile( dest ))) return FALSE;
142
143 if (target && !(tgt = grab_profile( target )))
144 {
145 release_profile( dst );
146 return FALSE;
147 }
148 intent = space->lcsIntent > 3 ? INTENT_PERCEPTUAL : space->lcsIntent;
149
150 TRACE( "lcsIntent: %x\n", space->lcsIntent );
151 TRACE( "lcsCSType: %s\n", dbgstr_tag( space->lcsCSType ) );
152 TRACE( "lcsFilename: %s\n", debugstr_w( space->lcsFilename ) );
153
154 cmsinput = cmsCreate_sRGBProfile(); /* FIXME: create from supplied color space */
155 if (target)
156 {
157 proofing = cmsFLAGS_SOFTPROOFING;
158 cmstarget = tgt->cmsprofile;
159 }
160 cmsoutput = dst->cmsprofile;
161 transform.cmstransform = cmsCreateProofingTransform(cmsinput, 0, cmsoutput, 0, cmstarget,
163 proofing);
164 if (!transform.cmstransform)
165 {
166 if (tgt) release_profile( tgt );
167 release_profile( dst );
168 return FALSE;
169 }
170
171 ret = create_transform( &transform );
172
173 if (tgt) release_profile( tgt );
174 release_profile( dst );
175
176#endif /* HAVE_LCMS2 */
177 return ret;
178}
GLuint GLenum GLenum transform
Definition: glext.h:9407
GLenum GLenum dst
Definition: glext.h:6340
#define INTENT_ABSOLUTE_COLORIMETRIC
Definition: icm.h:191
#define INTENT_PERCEPTUAL
Definition: icm.h:188
#define profile
Definition: kernel32.h:12
#define debugstr_w
Definition: kernel32.h:32
const char * dbgstr_tag(DWORD) DECLSPEC_HIDDEN
Definition: profile.c:58
int ret

Referenced by CreateColorTransformA().

◆ CreateMultiProfileTransform()

HTRANSFORM WINAPI CreateMultiProfileTransform ( PHPROFILE  profiles,
DWORD  nprofiles,
PDWORD  intents,
DWORD  nintents,
DWORD  flags,
DWORD  cmm 
)

Definition at line 196 of file transform.c.

198{
200#ifdef HAVE_LCMS2
201 cmsHPROFILE *cmsprofiles;
202 struct transform transform;
203 struct profile *profile0, *profile1;
204
205 TRACE( "( %p, 0x%08x, %p, 0x%08x, 0x%08x, 0x%08x )\n",
206 profiles, nprofiles, intents, nintents, flags, cmm );
207
208 if (!profiles || !nprofiles || !intents) return NULL;
209
210 if (nprofiles > 2)
211 {
212 FIXME("more than 2 profiles not supported\n");
213 return NULL;
214 }
215
216 profile0 = grab_profile( profiles[0] );
217 if (!profile0) return NULL;
218 profile1 = grab_profile( profiles[1] );
219 if (!profile1)
220 {
221 release_profile( profile0 );
222 return NULL;
223 }
224
225 if ((cmsprofiles = HeapAlloc( GetProcessHeap(), 0, (nprofiles + 1) * sizeof(cmsHPROFILE) )))
226 {
227 cmsprofiles[0] = profile0->cmsprofile;
228 cmsprofiles[1] = profile1->cmsprofile;
229
230 transform.cmstransform = cmsCreateMultiprofileTransform( cmsprofiles, nprofiles, 0,
231 0, *intents, 0 );
232 HeapFree( GetProcessHeap(), 0, cmsprofiles );
233 if (!transform.cmstransform)
234 {
235 release_profile( profile0 );
236 release_profile( profile1 );
237 return FALSE;
238 }
239 ret = create_transform( &transform );
240 }
241
242 release_profile( profile0 );
243 release_profile( profile1 );
244
245#endif /* HAVE_LCMS2 */
246 return ret;
247}
#define FIXME(fmt,...)
Definition: debug.h:114
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
static const char profile1[]
Definition: profile.c:116

Referenced by init_function_ptrs().

◆ DeleteColorTransform()

BOOL WINAPI DeleteColorTransform ( HTRANSFORM  handle)

Definition at line 261 of file transform.c.

262{
263 BOOL ret = FALSE;
264#ifdef HAVE_LCMS2
265
266 TRACE( "( %p )\n", handle );
267
268 ret = close_transform( handle );
269
270#endif /* HAVE_LCMS2 */
271 return ret;
272}
unsigned int BOOL
Definition: ntddk_ex.h:94

Referenced by init_function_ptrs().

◆ TranslateBitmapBits()

BOOL WINAPI TranslateBitmapBits ( HTRANSFORM  handle,
PVOID  srcbits,
BMFORMAT  input,
DWORD  width,
DWORD  height,
DWORD  inputstride,
PVOID  destbits,
BMFORMAT  output,
DWORD  outputstride,
PBMCALLBACKFN  callback,
ULONG  data 
)

Definition at line 296 of file transform.c.

299{
300 BOOL ret = FALSE;
301#ifdef HAVE_LCMS2
302 struct transform *transform = grab_transform( handle );
303
304 TRACE( "( %p, %p, 0x%08x, 0x%08x, 0x%08x, 0x%08x, %p, 0x%08x, 0x%08x, %p, 0x%08x )\n",
305 handle, srcbits, input, width, height, inputstride, destbits, output,
306 outputstride, callback, data );
307
308 if (!transform) return FALSE;
309 if (!cmsChangeBuffersFormat( transform->cmstransform, from_bmformat(input), from_bmformat(output) ))
310 return FALSE;
311
312 cmsDoTransform( transform->cmstransform, srcbits, destbits, width * height );
313 release_transform( transform );
314 ret = TRUE;
315
316#endif /* HAVE_LCMS2 */
317 return ret;
318}
#define TRUE
Definition: types.h:120
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLenum GLenum GLenum input
Definition: glext.h:9031
static IPrintDialogCallback callback
Definition: printdlg.c:326

◆ TranslateColors()

BOOL WINAPI TranslateColors ( HTRANSFORM  handle,
PCOLOR  in,
DWORD  count,
COLORTYPE  input_type,
PCOLOR  out,
COLORTYPE  output_type 
)

Definition at line 337 of file transform.c.

339{
340#ifdef HAVE_LCMS2
341 BOOL ret = TRUE;
342 struct transform *transform = grab_transform( handle );
343 cmsHTRANSFORM xfrm;
344 unsigned int i;
345
346 TRACE( "( %p, %p, %d, %d, %p, %d )\n", handle, in, count, input_type, out, output_type );
347
348 if (!transform) return FALSE;
349
350 xfrm = transform->cmstransform;
351 if (!cmsChangeBuffersFormat( xfrm, from_type(input_type), from_type(output_type) ))
352 return FALSE;
353
354 switch (input_type)
355 {
356 case COLOR_RGB:
357 {
358 switch (output_type)
359 {
360 case COLOR_RGB: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].rgb, &out[i].rgb, 1 ); goto done;
361 case COLOR_Lab: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].rgb, &out[i].Lab, 1 ); goto done;
362 case COLOR_GRAY: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].rgb, &out[i].gray, 1 ); goto done;
363 case COLOR_CMYK: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].rgb, &out[i].cmyk, 1 ); goto done;
364 case COLOR_XYZ: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].rgb, &out[i].XYZ, 1 ); goto done;
365 default:
366 FIXME("unhandled input/output pair: %d/%d\n", input_type, output_type);
367 ret = FALSE;
368 break;
369 }
370 break;
371 }
372 case COLOR_Lab:
373 {
374 switch (output_type)
375 {
376 case COLOR_RGB: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].Lab, &out[i].rgb, 1 ); goto done;
377 case COLOR_Lab: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].Lab, &out[i].Lab, 1 ); goto done;
378 case COLOR_GRAY: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].Lab, &out[i].gray, 1 ); goto done;
379 case COLOR_CMYK: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].Lab, &out[i].cmyk, 1 ); goto done;
380 case COLOR_XYZ: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].Lab, &out[i].XYZ, 1 ); goto done;
381 default:
382 FIXME("unhandled input/output pair: %d/%d\n", input_type, output_type);
383 ret = FALSE;
384 break;
385 }
386 break;
387 }
388 case COLOR_GRAY:
389 {
390 switch (output_type)
391 {
392 case COLOR_RGB: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].gray, &out[i].rgb, 1 ); goto done;
393 case COLOR_Lab: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].gray, &out[i].Lab, 1 ); goto done;
394 case COLOR_GRAY: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].gray, &out[i].gray, 1 ); goto done;
395 case COLOR_CMYK: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].gray, &out[i].cmyk, 1 ); goto done;
396 case COLOR_XYZ: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].gray, &out[i].XYZ, 1 ); goto done;
397 default:
398 FIXME("unhandled input/output pair: %d/%d\n", input_type, output_type);
399 ret = FALSE;
400 break;
401 }
402 break;
403 }
404 case COLOR_CMYK:
405 {
406 switch (output_type)
407 {
408 case COLOR_RGB: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].cmyk, &out[i].rgb, 1 ); goto done;
409 case COLOR_Lab: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].cmyk, &out[i].Lab, 1 ); goto done;
410 case COLOR_GRAY: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].cmyk, &out[i].gray, 1 ); goto done;
411 case COLOR_CMYK: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].cmyk, &out[i].cmyk, 1 ); goto done;
412 case COLOR_XYZ: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].cmyk, &out[i].XYZ, 1 ); goto done;
413 default:
414 FIXME("unhandled input/output pair: %d/%d\n", input_type, output_type);
415 ret = FALSE;
416 break;
417 }
418 break;
419 }
420 case COLOR_XYZ:
421 {
422 switch (output_type)
423 {
424 case COLOR_RGB: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].XYZ, &out[i].rgb, 1 ); goto done;
425 case COLOR_Lab: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].XYZ, &out[i].Lab, 1 ); goto done;
426 case COLOR_GRAY: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].XYZ, &out[i].gray, 1 ); goto done;
427 case COLOR_CMYK: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].XYZ, &out[i].cmyk, 1 ); goto done;
428 case COLOR_XYZ: for (i = 0; i < count; i++) cmsDoTransform( xfrm, &in[i].XYZ, &out[i].XYZ, 1 ); goto done;
429 default:
430 FIXME("unhandled input/output pair: %d/%d\n", input_type, output_type);
431 ret = FALSE;
432 break;
433 }
434 break;
435 }
436 default:
437 FIXME("unhandled input/output pair: %d/%d\n", input_type, output_type);
438 ret = FALSE;
439 break;
440 }
441
442done:
443 release_transform( transform );
444 return ret;
445
446#else /* HAVE_LCMS2 */
447 return FALSE;
448#endif /* HAVE_LCMS2 */
449}
#define COLOR_GRAY
Definition: ui.h:329
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint in
Definition: glext.h:9616
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ COLOR_XYZ
Definition: icm.h:126
@ COLOR_CMYK
Definition: icm.h:130
@ COLOR_Lab
Definition: icm.h:128
@ COLOR_RGB
Definition: icm.h:125
static FILE * out
Definition: regtests2xml.c:44
output_type
Definition: stylesheet.c:56
_In_ ULONG _In_ ULONG rgb
Definition: winddi.h:3521

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( mscms  )