29 |
|
FILE *fp; /* stream pointer */ |
30 |
|
COLOR *scan[WINSIZ]; /* input scanline window */ |
31 |
|
COLOR coef; /* coefficient */ |
32 |
+ |
COLOR expos; /* recorded exposure */ |
33 |
|
} input[MAXINP]; /* input pictures */ |
34 |
|
|
35 |
|
int nfiles; /* number of input files */ |
38 |
|
char *vcolout[3] = {"ro", "go", "bo"}; |
39 |
|
char vbrtin[] = "li"; |
40 |
|
char vbrtout[] = "lo"; |
41 |
< |
char *vcolcoef[3] = {"rc", "gc", "bc"}; |
42 |
< |
char vbrtcoef[] = "lc"; |
41 |
> |
char *vcolexp[3] = {"re", "ge", "be"}; |
42 |
> |
char vbrtexp[] = "le"; |
43 |
|
|
44 |
|
#define vnfiles "nfiles" |
45 |
|
#define vxres "xres" |
77 |
|
case 'w': |
78 |
|
nowarn = !nowarn; |
79 |
|
continue; |
79 |
– |
case 'o': |
80 |
– |
original = !original; |
81 |
– |
continue; |
80 |
|
case 'f': |
81 |
|
case 'e': |
82 |
|
a++; |
85 |
|
break; |
86 |
|
} |
87 |
|
/* process files */ |
88 |
< |
for (nfiles = 0; nfiles < MAXINP; nfiles++) |
88 |
> |
for (nfiles = 0; nfiles < MAXINP; nfiles++) { |
89 |
|
setcolor(input[nfiles].coef, 1.0, 1.0, 1.0); |
90 |
+ |
setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); |
91 |
+ |
} |
92 |
|
nfiles = 0; |
93 |
|
for ( ; a < argc; a++) { |
94 |
|
if (nfiles >= MAXINP) { |
102 |
|
input[nfiles].name = "<stdin>"; |
103 |
|
input[nfiles].fp = stdin; |
104 |
|
break; |
105 |
+ |
case 'o': |
106 |
+ |
original++; |
107 |
+ |
break; |
108 |
|
case 's': |
109 |
|
f = atof(argv[++a]); |
110 |
|
scalecolor(input[nfiles].coef, f); |
126 |
|
} |
127 |
|
} |
128 |
|
checkfile(); |
129 |
+ |
original = 0; |
130 |
|
nfiles++; |
131 |
|
} |
132 |
|
init(); /* set constant expressions */ |
139 |
|
a++; |
140 |
|
continue; |
141 |
|
case 'w': |
138 |
– |
case 'o': |
142 |
|
continue; |
143 |
|
case 'f': |
144 |
|
fcompile(argv[++a]); |
176 |
|
if (isformat(s)) { /* check format */ |
177 |
|
formatval(fmt, s); |
178 |
|
wrongformat = strcmp(fmt, COLRFMT); |
179 |
< |
} else if (original && isexpos(s)) { /* exposure */ |
180 |
< |
d = 1.0/exposval(s); |
181 |
< |
scalecolor(input[nfiles].coef, d); |
182 |
< |
} else if (original && iscolcor(s)) { /* color correction */ |
179 |
> |
return; /* don't echo */ |
180 |
> |
} |
181 |
> |
if (isexpos(s)) { /* exposure */ |
182 |
> |
d = exposval(s); |
183 |
> |
scalecolor(input[nfiles].expos, d); |
184 |
> |
if (original) |
185 |
> |
scalecolor(input[nfiles].coef, 1.0/d); |
186 |
> |
} else if (iscolcor(s)) { /* color correction */ |
187 |
|
colcorval(ctmp, s); |
188 |
< |
colval(input[nfiles].coef,RED) /= colval(ctmp,RED); |
189 |
< |
colval(input[nfiles].coef,GRN) /= colval(ctmp,GRN); |
190 |
< |
colval(input[nfiles].coef,BLU) /= colval(ctmp,BLU); |
191 |
< |
} else { /* echo unaffected line */ |
192 |
< |
putchar('\t'); |
193 |
< |
fputs(s, stdout); |
188 |
> |
multcolor(input[nfiles].expos, ctmp); |
189 |
> |
if (original) { |
190 |
> |
colval(input[nfiles].coef,RED) /= colval(ctmp,RED); |
191 |
> |
colval(input[nfiles].coef,GRN) /= colval(ctmp,GRN); |
192 |
> |
colval(input[nfiles].coef,BLU) /= colval(ctmp,BLU); |
193 |
> |
} |
194 |
|
} |
195 |
+ |
/* echo line */ |
196 |
+ |
putchar('\t'); |
197 |
+ |
fputs(s, stdout); |
198 |
|
} |
199 |
|
|
200 |
|
|
231 |
|
|
232 |
|
init() /* perform final setup */ |
233 |
|
{ |
234 |
< |
double l_colin(), l_coef(); |
234 |
> |
double l_colin(), l_expos(); |
235 |
|
register int i; |
236 |
|
/* prime input */ |
237 |
|
for (ypos = yres+(MIDSCN-1); ypos >= yres; ypos--) |
242 |
|
varset(vyres, ':', (double)yres); |
243 |
|
/* set functions */ |
244 |
|
for (i = 0; i < 3; i++) { |
245 |
< |
funset(vcolcoef[i], 1, ':', l_coef); |
245 |
> |
funset(vcolexp[i], 1, ':', l_expos); |
246 |
|
funset(vcolin[i], 1, '=', l_colin); |
247 |
|
} |
248 |
< |
funset(vbrtcoef, 1, ':', l_coef); |
248 |
> |
funset(vbrtexp, 1, ':', l_expos); |
249 |
|
funset(vbrtin, 1, '=', l_colin); |
250 |
|
} |
251 |
|
|
329 |
|
|
330 |
|
|
331 |
|
double |
332 |
< |
l_coef(nam) /* return picture coefficients */ |
332 |
> |
l_expos(nam) /* return picture exposure */ |
333 |
|
register char *nam; |
334 |
|
{ |
335 |
|
register int fn, n; |
343 |
|
errno = EDOM; |
344 |
|
return(0.0); |
345 |
|
} |
346 |
< |
if (nam == vbrtcoef) |
347 |
< |
return(bright(input[fn].coef)); |
346 |
> |
if (nam == vbrtexp) |
347 |
> |
return(bright(input[fn].expos)); |
348 |
|
n = 3; |
349 |
|
while (n--) |
350 |
< |
if (nam == vcolcoef[n]) |
351 |
< |
return(colval(input[fn].coef,n)); |
352 |
< |
eputs("Bad call to l_coef()!\n"); |
350 |
> |
if (nam == vcolexp[n]) |
351 |
> |
return(colval(input[fn].expos,n)); |
352 |
> |
eputs("Bad call to l_expos()!\n"); |
353 |
|
quit(1); |
354 |
|
} |
355 |
|
|