20 |
|
|
21 |
|
char *mbcalfile = NULL; /* macbethcal mapping file */ |
22 |
|
|
23 |
< |
static struct mbc mbcond; /* macbethcal conditioning struct */ |
23 |
> |
static struct mbc { |
24 |
> |
float xa[3][6], ya[3][6]; |
25 |
> |
COLORMAT cmat; |
26 |
> |
} mbcond; /* macbethcal conditioning struct */ |
27 |
|
|
28 |
|
static COLOR *scanbuf; /* scanline processing buffer */ |
29 |
|
static int nread; /* number of scanlines processed */ |
60 |
|
nextscan() /* read and condition next scanline */ |
61 |
|
{ |
62 |
|
if (nread >= numscans(&inpres)) { |
63 |
< |
#ifdef DEBUG |
64 |
< |
fputs("done\n", stderr); |
62 |
< |
#endif |
63 |
< |
return(NULL); |
63 |
> |
free((char *)scanbuf); |
64 |
> |
return(scanbuf = NULL); |
65 |
|
} |
66 |
< |
if (freadscan(scanbuf, scanlen(&inpres), infp) < 0) { |
66 |
> |
if (what2do&DO_ACUITY) |
67 |
> |
acuscan(scanbuf, nread); |
68 |
> |
else if (freadscan(scanbuf, scanlen(&inpres), infp) < 0) { |
69 |
|
fprintf(stderr, "%s: %s: scanline read error\n", |
70 |
|
progname, infn); |
71 |
|
exit(1); |
72 |
|
} |
70 |
– |
nread++; |
73 |
|
if (what2do&DO_VEIL) /* add veiling */ |
74 |
< |
addveil(scanbuf, nread-1); |
74 |
> |
addveil(scanbuf, nread); |
75 |
|
if (what2do&DO_COLOR) /* scotopic color loss */ |
76 |
|
scotscan(scanbuf, scanlen(&inpres)); |
77 |
|
if (what2do&DO_LINEAR) /* map luminances */ |
82 |
|
mbscan(scanbuf, scanlen(&inpres), &mbcond); |
83 |
|
else if (lumf == cielum | inprims != outprims) |
84 |
|
matscan(scanbuf, scanlen(&inpres), mbcond.cmat); |
85 |
+ |
nread++; |
86 |
|
return(scanbuf); |
87 |
|
} |
88 |
|
|
97 |
|
comprgb2rgbmat(mbcond.cmat, inprims, outprims); |
98 |
|
else |
99 |
|
compxyz2rgbmat(mbcond.cmat, outprims); |
100 |
+ |
if (what2do&DO_ACUITY) |
101 |
+ |
initacuity(); |
102 |
|
scanbuf = (COLOR *)malloc(scanlen(&inpres)*sizeof(COLOR)); |
103 |
|
if (scanbuf == NULL) |
104 |
|
syserror("malloc"); |
105 |
|
nread = 0; |
101 |
– |
#ifdef DEBUG |
102 |
– |
fprintf(stderr, "%s: processing image...", progname); |
103 |
– |
#endif |
106 |
|
return(nextscan()); |
107 |
|
} |
108 |
|
|
140 |
|
register int i, j; |
141 |
|
|
142 |
|
while (len--) { |
143 |
+ |
colortrans(sl[0], mb->cmat, sl[0]); |
144 |
|
for (i = 0; i < 3; i++) { |
145 |
|
d = colval(sl[0],i); |
146 |
|
for (j = 0; j < 4 && mb->xa[i][j+1] <= d; j++) |
149 |
|
(d - mb->xa[i][j])*mb->ya[i][j+1] ) / |
150 |
|
(mb->xa[i][j+1] - mb->xa[i][j]); |
151 |
|
} |
149 |
– |
colortrans(sl[0], mb->cmat, sl[0]); |
152 |
|
sl++; |
153 |
|
} |
154 |
|
} |
216 |
|
inpflags |= 040; |
217 |
|
else if (!(inpflags & 0100) && |
218 |
|
sscanf(buf, |
219 |
< |
"ro = %f*rn + %f*gn + %f*bn", |
219 |
> |
"r = %f*r1 + %f*g1 + %f*b1", |
220 |
|
&mb->cmat[0][0], &mb->cmat[0][1], |
221 |
|
&mb->cmat[0][2]) == 3) |
222 |
|
inpflags |= 0100; |
223 |
|
else if (!(inpflags & 0200) && |
224 |
|
sscanf(buf, |
225 |
< |
"go = %f*rn + %f*gn + %f*bn", |
225 |
> |
"g = %f*r1 + %f*g1 + %f*b1", |
226 |
|
&mb->cmat[1][0], &mb->cmat[1][1], |
227 |
|
&mb->cmat[1][2]) == 3) |
228 |
|
inpflags |= 0200; |
229 |
|
else if (!(inpflags & 0400) && |
230 |
|
sscanf(buf, |
231 |
< |
"bo = %f*rn + %f*gn + %f*bn", |
231 |
> |
"b = %f*r1 + %f*g1 + %f*b1", |
232 |
|
&mb->cmat[2][0], &mb->cmat[2][1], |
233 |
|
&mb->cmat[2][2]) == 3) |
234 |
|
inpflags |= 0400; |