58
66
#define max(a,b) ((a) > (b)?(a):(b))
69
// See B.K.O #148930: compile with lcms v.1.17
70
#if (LCMS_VERSION > 116)
71
typedef LCMSBOOL BOOL;
62
75
/* Matrix operations - arbitrary size ----------------------------------------------------- */
71
// See B.K.O #148930: compile with lcms v.1.17
72
#if (LCMS_VERSION > 116)
73
typedef LCMSBOOL BOOL;
76
85
LPMATN cdecl MATNalloc(int Rows, int Cols);
77
86
void cdecl MATNfree (LPMATN mat);
107
116
int cdecl cmsxIT8EnumProperties(LCMSHANDLE cmsxIT8, char ***PropertyNames);
108
117
int cdecl cmsxIT8EnumDataFormat(LCMSHANDLE cmsxIT8, char ***SampleNames);
109
118
BOOL cdecl cmsxIT8SetDataFormat(LCMSHANDLE cmsxIT8, int n, const char *Sample);
111
119
BOOL cdecl cmsxIT8GetDataSetByPos(LCMSHANDLE IT8, int col, int row, char* Val, int ValBufferLen);
113
BOOL cdecl cmsxIT8GetDataSet(LCMSHANDLE cmsxIT8, const char* cPatch,
115
char* Val, int ValBuffLen);
120
BOOL cdecl cmsxIT8GetDataSet(LCMSHANDLE cmsxIT8, const char* cPatch, const char* cSample, char* Val, int ValBuffLen);
117
121
BOOL cdecl cmsxIT8GetDataSetDbl(LCMSHANDLE cmsxIT8, const char* cPatch, const char* cSample, double* v);
119
BOOL cdecl cmsxIT8SetDataSet(LCMSHANDLE cmsxIT8, const char* cPatch,
122
BOOL cdecl cmsxIT8SetDataSet(LCMSHANDLE cmsxIT8, const char* cPatch, const char* cSample, char *Val);
123
123
BOOL cdecl cmsxIT8SetDataSetDbl(LCMSHANDLE cmsxIT8, const char* cPatch, const char* cSample, double Val);
125
124
const char *cdecl cmsxIT8GenericPatchName(int nPatch, char* buffer);
129
127
/* Patch collections (measurement lists) -------------------------------------------------- */
131
129
#define PATCH_HAS_Lab 0x00000001
136
134
#define PATCH_HAS_HEXACRM 0x00000020
137
135
#define PATCH_HAS_STD_Lab 0x00010000
138
136
#define PATCH_HAS_STD_XYZ 0x00020000
139
#define PATCH_HAS_XYZ_PROOF 0x00100000
137
#define PATCH_HAS_XYZ_PROOF 0x00100000
140
138
#define PATCH_HAS_MEAN_DE 0x01000000
141
139
#define PATCH_HAS_STD_DE 0x02000000
142
140
#define PATCH_HAS_CHISQ 0x04000000
145
#define MAXPATCHNAMELEN 20
143
#define MAXPATCHNAMELEN 20
146
145
/* A patch in memory */
150
150
DWORD dwFlags; /* Is quite possible to have colorant in only */
151
151
/* some patches of sheet, so mark each entry with */
156
156
cmsCIELab Lab; /* The tristimulus values of target */
159
cmsCIEXYZ XYZProof; /* The absolute XYZ value returned by profile */
160
/* (gamut constrained to device) */
159
cmsCIEXYZ XYZProof; /* The absolute XYZ value returned by profile */
160
/* (gamut constrained to device) */
162
162
union { /* The possible colorants. Only one space is */
163
163
/* allowed...obviously only one set of */
196
197
void cdecl cmsxPCollFreeMeasurements(LPMEASUREMENT m);
197
198
SETOFPATCHES cdecl cmsxPCollBuildSet(LPMEASUREMENT m, BOOL lDefault);
199
BOOL cdecl cmsxPCollBuildMeasurement(LPMEASUREMENT m,
200
const char *ReferenceSheet,
201
const char *MeasurementSheet,
202
DWORD dwNeededSamplesType);
200
BOOL cdecl cmsxPCollBuildMeasurement(LPMEASUREMENT m, const char *ReferenceSheet,
201
const char *MeasurementSheet, DWORD dwNeededSamplesType);
204
203
int cdecl cmsxPCollCountSet(LPMEASUREMENT m, SETOFPATCHES Set);
205
204
BOOL cdecl cmsxPCollValidatePatches(LPMEASUREMENT m, DWORD dwFlags);
214
213
double r, double g, double b,
215
214
LPcmsCIEXYZ XYZ, LPcmsCIELab Lab);
217
void cdecl cmsxPCollLinearizePatches(LPMEASUREMENT m, SETOFPATCHES Valids,
218
LPGAMMATABLE Gamma[3]);
216
void cdecl cmsxPCollLinearizePatches(LPMEASUREMENT m, SETOFPATCHES Valids, LPGAMMATABLE Gamma[3]);
220
218
/* Extraction utilities */
242
240
/* Find important values */
244
LPPATCH cdecl cmsxPCollFindWhite(LPMEASUREMENT m, SETOFPATCHES Valids, double* Distance);
245
LPPATCH cdecl cmsxPCollFindBlack(LPMEASUREMENT m, SETOFPATCHES Valids, double* Distance);
246
LPPATCH cdecl cmsxPCollFindPrimary(LPMEASUREMENT m, SETOFPATCHES Valids, int Channel, double* Distance);
242
LPPATCH cdecl cmsxPCollFindWhite(LPMEASUREMENT m, SETOFPATCHES Valids, double* Distance);
243
LPPATCH cdecl cmsxPCollFindBlack(LPMEASUREMENT m, SETOFPATCHES Valids, double* Distance);
244
LPPATCH cdecl cmsxPCollFindPrimary(LPMEASUREMENT m, SETOFPATCHES Valids, int Channel, double* Distance);
248
246
/* Multiple linear regression stuff ---------------------------------------- */
251
249
/* A measurement of error */
255
254
double SSE; /* The error sum of squares */
256
255
double MSE; /* The error mean sum of squares */
293
291
/* Levenberg-Marquardt ---------------------------------------------------------------------- */
295
293
LCMSHANDLE cdecl cmsxLevenbergMarquardtInit(LPSAMPLEDCURVE x, LPSAMPLEDCURVE y, double sig,
298
void (*funcs)(double, double[], double*, double[], int)
295
void (*funcs)(double, double[], double*, double[], int));
301
297
double cdecl cmsxLevenbergMarquardtAlamda(LCMSHANDLE hMRQ);
302
298
double cdecl cmsxLevenbergMarquardtChiSq(LCMSHANDLE hMRQ);
307
303
/* Convex hull geometric routines ------------------------------------------------------------ */
309
305
LCMSHANDLE cdecl cmsxHullInit(void);
310
void cdecl cmsxHullDone(LCMSHANDLE hHull);
311
BOOL cdecl cmsxHullAddPoint(LCMSHANDLE hHull, int x, int y, int z);
312
BOOL cdecl cmsxHullComputeHull(LCMSHANDLE hHull);
313
char cdecl cmsxHullCheckpoint(LCMSHANDLE hHull, int x, int y, int z);
306
void cdecl cmsxHullDone(LCMSHANDLE hHull);
307
BOOL cdecl cmsxHullAddPoint(LCMSHANDLE hHull, int x, int y, int z);
308
BOOL cdecl cmsxHullComputeHull(LCMSHANDLE hHull);
309
char cdecl cmsxHullCheckpoint(LCMSHANDLE hHull, int x, int y, int z);
314
310
BOOL cdecl cmsxHullDumpVRML(LCMSHANDLE hHull, const char* fname);
317
313
/* Linearization ---------------------------------------------------------------------------- */
320
#define MEDIUM_REFLECTIVE_D50 0 /* Used for scanner targets */
321
#define MEDIUM_TRANSMISSIVE 1 /* Used for monitors & projectors */
323
void cdecl cmsxComputeLinearizationTables(LPMEASUREMENT m,
326
int nResultingPoints,
330
void cdecl cmsxCompleteLabOfPatches(LPMEASUREMENT m, SETOFPATCHES Valids, int Medium);
316
#define MEDIUM_REFLECTIVE_D50 0 /* Used for scanner targets */
317
#define MEDIUM_TRANSMISSIVE 1 /* Used for monitors & projectors */
319
void cdecl cmsxComputeLinearizationTables(LPMEASUREMENT m, int ColorSpace,
320
LPGAMMATABLE Lin[3], int nResultingPoints, int Medium);
322
void cdecl cmsxCompleteLabOfPatches(LPMEASUREMENT m, SETOFPATCHES Valids, int Medium);
331
323
LPGAMMATABLE cdecl cmsxEstimateGamma(LPSAMPLEDCURVE X, LPSAMPLEDCURVE Y, int nResultingPoints);
333
325
void cdecl cmsxApplyLinearizationTable(double In[3], LPGAMMATABLE Gamma[3], double Out[3]);
334
326
void cdecl cmsxApplyLinearizationGamma(WORD In[3], LPGAMMATABLE Gamma[3], WORD Out[3]);
342
334
/* Matrix shaper profiler API ------------------------------------------------------------- */
345
BOOL cdecl cmsxComputeMatrixShaper(const char* ReferenceSheet,
337
BOOL cdecl cmsxComputeMatrixShaper(const char* ReferenceSheet,
346
338
const char* MeasurementSheet,
348
340
LPGAMMATABLE TransferCurves[3],
349
341
LPcmsCIEXYZ WhitePoint,
350
342
LPcmsCIEXYZ BlackPoint,
358
350
typedef int (* cmsxGAUGER)(const char *Label, int nMin, int nMax, int Pos);
359
351
typedef int (* cmsxPRINTF)(const char *Frm, ...);
364
357
char ReferenceSheet[MAX_PATH];
381
374
cmsCIExyYTRIPLE Primaries; /* The primaries */
382
375
LPGAMMATABLE Gamma[3]; /* Gamma curves */
385
cmsHPROFILE hProfile; /* handle to profile */
378
cmsHPROFILE hProfile; /* handle to profile */
387
380
icProfileClassSignature DeviceClass;
388
381
icColorSpaceSignature ColorSpace;
390
383
int PCSType; /* PT_XYZ or PT_Lab */
391
384
int CLUTPoints; /* Final CLUT resolution */
392
int ProfileVerbosityLevel; /* 0=minimum, 1=additional, 2=Verbose, 3=Any suitable */
385
int ProfileVerbosityLevel; /* 0=minimum, 1=additional, 2=Verbose, 3=Any suitable */
396
389
MEASUREMENT m; /* Contains list of available patches */
401
LCMSHANDLE hRGBHull; /* Contains bobbin of valid RGB values */
404
BOOL lUseCIECAM97s; /* Use CIECAM97s for chromatic adaptation? */
406
cmsViewingConditions device; /* Viewing condition of source */
394
LCMSHANDLE hRGBHull; /* Contains bobbin of valid RGB values */
397
BOOL lUseCIECAM97s; /* Use CIECAM97s for chromatic adaptation? */
399
cmsViewingConditions device; /* Viewing condition of source */
407
400
cmsViewingConditions PCS; /* Viewing condition of PCS */
409
402
LCMSHANDLE hDevice; /* CIECAM97s models used for adaptation */
410
403
LCMSHANDLE hPCS; /* and viewing conditions */
413
405
} PROFILERCOMMONDATA,FAR* LPPROFILERCOMMONDATA;
416
408
/* Shared routines */
428
420
/* Monitor profiler API ------------------------------------------------------------------- */
432
425
PROFILERCOMMONDATA hdr;
435
427
LPGAMMATABLE Prelinearization[3]; /* Canonic gamma */
436
428
LPGAMMATABLE ReverseTables[3]; /* Reverse (direct) gamma */
437
429
LPGAMMATABLE PreLab[3];
438
430
LPGAMMATABLE PreLabRev[3];
441
432
MAT3 PrimariesMatrix;
442
433
MAT3 PrimariesMatrixRev;
445
435
} MONITORPROFILERDATA,FAR* LPMONITORPROFILERDATA;
453
443
/* Scanner profiler API ------------------------------------------------------------------- */
458
449
PROFILERCOMMONDATA hdr;
460
LPGAMMATABLE Prelinearization[3];
462
LPMATN HiTerms; /* Regression matrix of many terms */
463
LPMATN LoTerms; /* Low order regression matrix used for extrapolation */
465
BOOL lLocalConvergenceExtrapolation;
451
LPGAMMATABLE Prelinearization[3];
453
LPMATN HiTerms; /* Regression matrix of many terms */
454
LPMATN LoTerms; /* Low order regression matrix used for extrapolation */
456
BOOL lLocalConvergenceExtrapolation;
468
459
} SCANNERPROFILERDATA,FAR* LPSCANNERPROFILERDATA;
473
462
BOOL cdecl cmsxScannerProfilerInit(LPSCANNERPROFILERDATA sys);
474
463
BOOL cdecl cmsxScannerProfilerDo(LPSCANNERPROFILERDATA sys);