38 |
|
static void getmbcalfile(char *fn, struct mbc *mb); |
39 |
|
|
40 |
|
|
41 |
< |
extern double |
41 |
> |
double |
42 |
|
rgblum( /* compute (scotopic) luminance of RGB color */ |
43 |
|
COLOR clr, |
44 |
|
int scotopic |
53 |
|
} |
54 |
|
|
55 |
|
|
56 |
< |
extern double |
56 |
> |
double |
57 |
|
cielum( /* compute (scotopic) luminance of CIE color */ |
58 |
|
COLOR xyz, |
59 |
|
int scotopic |
67 |
|
} |
68 |
|
|
69 |
|
|
70 |
< |
extern COLOR * |
70 |
> |
COLOR * |
71 |
|
nextscan(void) /* read and condition next scanline */ |
72 |
|
{ |
73 |
|
if (nread >= numscans(&inpres)) { |
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
< |
extern COLOR * |
105 |
> |
COLOR * |
106 |
|
firstscan(void) /* return first processed scanline */ |
107 |
|
{ |
108 |
|
if (mbcalfile != NULL) /* load macbethcal file */ |
115 |
|
comprgb2rgbWBmat(mbcond.cmat, inprims, outprims); |
116 |
|
else |
117 |
|
compxyz2rgbWBmat(mbcond.cmat, outprims); |
118 |
< |
if (what2do&DO_ACUITY && !initacuity()) { |
119 |
< |
fprintf(stderr, "%s: warning - cannot initialize acuity pass\n", |
120 |
< |
progname); |
121 |
< |
what2do &= ~DO_ACUITY; |
122 |
< |
} |
118 |
> |
if (what2do&DO_ACUITY) |
119 |
> |
initacuity(); |
120 |
|
scanbuf = (COLOR *)malloc(scanlen(&inpres)*sizeof(COLOR)); |
121 |
|
if (scanbuf == NULL) |
122 |
|
syserror("malloc"); |
127 |
|
|
128 |
|
static void |
129 |
|
sfscan( /* apply scalefactor to scanline */ |
130 |
< |
register COLOR *sl, |
130 |
> |
COLOR *sl, |
131 |
|
int len, |
132 |
|
double sf |
133 |
|
) |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
+ |
static double |
143 |
+ |
greypoint( /* compute gamut mapping grey target */ |
144 |
+ |
COLOR col |
145 |
+ |
) |
146 |
+ |
{ |
147 |
+ |
COLOR gryc; |
148 |
+ |
int i; |
149 |
+ |
/* improves saturated color rendering */ |
150 |
+ |
copycolor(gryc, col); |
151 |
+ |
for (i = 3; i--; ) |
152 |
+ |
if (gryc[i] > 1) |
153 |
+ |
gryc[i] = 1; |
154 |
+ |
else if (gryc[i] < 0) |
155 |
+ |
gryc[i] = 0; |
156 |
+ |
return(bright(gryc)); |
157 |
+ |
} |
158 |
+ |
|
159 |
+ |
|
160 |
|
static void |
161 |
|
matscan( /* apply color matrix to scaline */ |
162 |
< |
register COLOR *sl, |
162 |
> |
COLOR *sl, |
163 |
|
int len, |
164 |
|
COLORMAT mat |
165 |
|
) |
166 |
|
{ |
167 |
|
while (len--) { |
168 |
|
colortrans(sl[0], mat, sl[0]); |
169 |
< |
clipgamut(sl[0], bright(sl[0]), CGAMUT, cblack, cwhite); |
169 |
> |
clipgamut(sl[0], greypoint(sl[0]), CGAMUT, cblack, cwhite); |
170 |
|
sl++; |
171 |
|
} |
172 |
|
} |
176 |
|
mbscan( /* apply macbethcal adj. to scaline */ |
177 |
|
COLOR *sl, |
178 |
|
int len, |
179 |
< |
register struct mbc *mb |
179 |
> |
struct mbc *mb |
180 |
|
) |
181 |
|
{ |
182 |
|
double d; |
183 |
< |
register int i, j; |
183 |
> |
int i, j; |
184 |
|
|
185 |
|
while (len--) { |
186 |
|
colortrans(sl[0], mb->cmat, sl[0]); |
187 |
< |
clipgamut(sl[0], bright(sl[0]), CGAMUT, mb->cmin, mb->cmax); |
187 |
> |
clipgamut(sl[0], greypoint(sl[0]), CGAMUT, mb->cmin, mb->cmax); |
188 |
|
for (i = 0; i < 3; i++) { |
189 |
|
d = colval(sl[0],i); |
190 |
|
for (j = 0; j < 4 && mb->xa[i][j+1] <= d; j++) |
216 |
|
progname, cwarpfile); |
217 |
|
exit(1); |
218 |
|
} |
219 |
< |
clipgamut(sl[0], bright(sl[0]), CGAMUT, cblack, cwhite); |
219 |
> |
clipgamut(sl[0], greypoint(sl[0]), CGAMUT, cblack, cwhite); |
220 |
|
sl++; |
221 |
|
} |
222 |
|
} |
225 |
|
static void |
226 |
|
getmbcalfile( /* load macbethcal file */ |
227 |
|
char *fn, |
228 |
< |
register struct mbc *mb |
228 |
> |
struct mbc *mb |
229 |
|
) |
230 |
|
{ |
231 |
|
char buf[128]; |
232 |
|
FILE *fp; |
233 |
|
int inpflags = 0; |
234 |
< |
register int i; |
234 |
> |
int i; |
235 |
|
|
236 |
|
if ((fp = fopen(fn, "r")) == NULL) |
237 |
|
syserror(fn); |