1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
/*
* Argyll Color Management System
*
* Plot the L in vs. L out for a path through the
* input device space, for a given link.
*
* We are assuming RGB device input space !!!!
*
* Author: Graeme W. Gill
* Date: 2002/1/28
* Version: 1.00
*
* Copyright 2002 Graeme W. Gill
*
* This material is licenced under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 :-
* see the License.txt file for licencing details.
*/
/* TTBD:
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>
#include "copyright.h"
#include "aconfig.h"
#include "numlib.h"
#include "icc.h"
#include "xicc.h"
#include "plot.h"
#include "ui.h"
#define PRES 100
static double start[13][4] = {
{ 0.0, 0.0, 0.0, 0.0},
{ 0.0, 0.0, 0.0, 0.0},
{ 0.0, 0.0, 0.0, 0.0},
{ 0.0, 0.0, 0.0, 0.0},
{ 0.0, 0.0, 0.0, 0.0},
{ 0.0, 0.0, 0.0, 0.0},
{ 0.0, 0.0, 0.0, 0.0},
{ 1.0, 0.0, 0.0, 0.0},
{ 0.0, 1.0, 0.0, 0.0},
{ 0.0, 0.0, 1.0, 0.0},
{ 0.0, 1.0, 1.0, 0.0},
{ 1.0, 0.0, 1.0, 0.0},
{ 1.0, 1.0, 0.0, 0.0}
};
static double end[13][4] = {
{ 1.0, 0.0, 0.0, 0.0},
{ 0.0, 1.0, 0.0, 0.0},
{ 0.0, 0.0, 1.0, 0.0},
{ 0.0, 1.0, 1.0, 0.0},
{ 1.0, 0.0, 1.0, 0.0},
{ 1.0, 1.0, 0.0, 0.0},
{ 1.0, 1.0, 1.0, 0.0},
{ 1.0, 1.0, 1.0, 0.0},
{ 1.0, 1.0, 1.0, 0.0},
{ 1.0, 1.0, 1.0, 0.0},
{ 1.0, 1.0, 1.0, 0.0},
{ 1.0, 1.0, 1.0, 0.0},
{ 1.0, 1.0, 1.0, 0.0}
};
static char *name[13] = {
"Black - Red", "Black - Green", "Black - Blue",
"Black - Cyan", "Black - Magenta", "Black - Yellow",
"Grey",
"Red - White", "Green - White", "Blue - White",
"Cyan - White", "Magenta - White", "Yellow - White",
};
#define USE_JAB /* Assume CRT in (2), print out (0) */
/* ---------------------------------------- */
void usage(void) {
fprintf(stderr,"Plot device space path L in/out curve from an ICC link file, Version %s\n",ARGYLL_VERSION_STR);
fprintf(stderr,"Author: Graeme W. Gill\n");
fprintf(stderr,"usage: pathplot inprof linkprof outprof\n");
fprintf(stderr," -v verbose\n");
exit(1);
}
int
main(
int argc,
char *argv[]
) {
int fa, nfa; /* argument we're looking at */
int verb = 0;
char in_name[100];
char link_name[100];
char out_name[100];
icmFile *in_fp, *link_fp, *out_fp;
icc *in_icco, *link_icco, *out_icco;
xicc *in_xicco, *out_xicco;
icmLuBase *link_lu;
icxLuBase *in_lu, *out_lu;
icColorSpaceSignature pcsor; /* PCS to use */
icxViewCond ivc[1], ovc[1];
int rv = 0;
error_program = argv[0];
if (argc < 4)
usage();
/* Process the arguments */
for(fa = 1;fa < argc;fa++) {
nfa = fa; /* skip to nfa if next argument is used */
if (argv[fa][0] == '-') { /* Look for any flags */
char *na = NULL; /* next argument after flag, null if none */
if (argv[fa][2] != '\000')
na = &argv[fa][2]; /* next is directly after flag */
else {
if ((fa+1) < argc) {
if (argv[fa+1][0] != '-') {
nfa = fa + 1;
na = argv[nfa]; /* next is seperate non-flag argument */
}
}
}
/* Verbosity */
if (argv[fa][1] == 'v' || argv[fa][1] == 'V') {
verb = 1;
}
else if (argv[fa][1] == '?')
usage();
else
usage();
}
else
break;
}
if (fa >= argc || argv[fa][0] == '-') usage();
strcpy(in_name,argv[fa++]);
if (fa >= argc || argv[fa][0] == '-') usage();
strcpy(link_name,argv[fa++]);
if (fa >= argc || argv[fa][0] == '-') usage();
strcpy(out_name,argv[fa++]);
/* Open up the files for reading */
if ((in_fp = new_icmFileStd_name(in_name,"r")) == NULL)
error ("Read: Can't open file '%s'",in_name);
if ((in_icco = new_icc()) == NULL)
error ("Read: Creation of ICC object failed");
if ((rv = in_icco->read(in_icco,in_fp,0)) != 0)
error ("Read: %d, %s",rv,in_icco->err);
if ((in_xicco = new_xicc(in_icco)) == NULL)
error ("Creation of input profile xicc failed");
if ((link_fp = new_icmFileStd_name(link_name,"r")) == NULL)
error ("Read: Can't open file '%s'",link_name);
if ((link_icco = new_icc()) == NULL)
error ("Read: Creation of ICC object failed");
if ((rv = link_icco->read(link_icco,link_fp,0)) != 0)
error ("Read: %d, %s",rv,link_icco->err);
if ((out_fp = new_icmFileStd_name(out_name,"r")) == NULL)
error ("Read: Can't open file '%s'",out_name);
if ((out_icco = new_icc()) == NULL)
error ("Read: Creation of ICC object failed");
if ((rv = out_icco->read(out_icco,out_fp,0)) != 0)
error ("Read: %d, %s",rv,out_icco->err);
if ((out_xicco = new_xicc(out_icco)) == NULL)
error ("Creation of output profile xicc failed");
#ifdef USE_JAB
pcsor = icxSigJabData; /* Use CIECAM as PCS */
if (xicc_enum_viewcond(in_xicco, ivc, -2, "mt", 0, NULL) == -999) /* Set input at monitor in typical */
error ("%d, %s",in_xicco->errc, in_xicco->err);
if (xicc_enum_viewcond(out_xicco, ovc, -2, "pp", 0, NULL) == -999) /* Set output at practical reflection print */
error ("%d, %s",out_xicco->errc, out_xicco->err);
#else
pcsor = icSigLabData; /* Default use Lab as PCS */
#endif /* !USE_JAB */
/* Device to PCS conversion object */
if ((in_lu = in_xicco->get_luobj(in_xicco, ICX_CLIP_NEAREST, icmFwd, icAbsoluteColorimetric, pcsor, icmLuOrdNorm, ivc, NULL)) == NULL) {
if ((in_lu = in_xicco->get_luobj(in_xicco, ICX_CLIP_NEAREST, icmBwd, icmDefaultIntent, pcsor, icmLuOrdNorm, ivc, NULL)) == NULL)
error ("%d, %s",in_xicco->errc, in_xicco->err);
}
/* Get a Device to Device conversion object */
if ((link_lu = link_icco->get_luobj(link_icco, icmFwd, icmDefaultIntent, pcsor, icmLuOrdNorm)) == NULL)
error ("%d, %s",link_icco->errc, link_icco->err);
/* Get a Device to PCS conversion object */
if ((out_lu = out_xicco->get_luobj(out_xicco, ICX_CLIP_NEAREST, icmFwd, icAbsoluteColorimetric, pcsor, icmLuOrdNorm, ovc, NULL)) == NULL) {
if ((out_lu = out_xicco->get_luobj(out_xicco, ICX_CLIP_NEAREST, icmFwd, icmDefaultIntent, pcsor, icmLuOrdNorm, ovc, NULL)) == NULL)
error ("%d, %s",out_xicco->errc, out_xicco->err);
}
{
double xx[PRES], yy[PRES];
int k, i, j;
double tt[10], tt2[10];
for (k = 0; k < 13; k++) {
printf("Doing %s\n",name[k]);
for (i = 0; i < PRES; i++) {
double frac = i/(PRES-1.0);
for (j = 0; j < 4; j++)
tt[j] = (end[k][j] - start[k][j]) * frac + start[k][j];
if (verb)
printf(" %f %f %f -> ",tt[0],tt[1],tt[2]);
/* input device space to PCS */
if ((rv = in_lu->lookup(in_lu, tt2, tt)) > 1)
error ("%d, %s",in_icco->errc,in_icco->err);
xx[i] = tt2[0]; /* L value */
/* input device space to output device space */
if ((rv = link_lu->lookup(link_lu, tt, tt)) > 1)
error ("%d, %s",link_icco->errc,link_icco->err);
/* output device space to PCS */
if ((rv = out_lu->lookup(out_lu, tt, tt)) > 1)
error ("%d, %s",out_icco->errc,out_icco->err);
yy[i] = tt[0]; /* L value */
if (verb)
printf("%f %f %f\n",tt[0],tt[1],tt[2]);
}
if (do_plot(xx,yy,NULL,NULL,PRES) < 0)
error("do_plot returned -1!\n");
}
}
/* Done with lookup objects */
in_lu->del(in_lu);
link_lu->del(link_lu);
out_lu->del(out_lu);
in_icco->del(in_icco);
in_fp->del(in_fp);
link_icco->del(link_icco);
link_fp->del(link_fp);
out_icco->del(out_icco);
out_fp->del(out_fp);
return 0;
}
|