1 |
< |
/* Copyright (c) 1997 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
4 |
> |
static char SCCSid[] = "$SunId$ SGI"; |
5 |
|
#endif |
6 |
|
|
7 |
|
/* |
34 |
|
char *progname; |
35 |
|
|
36 |
|
|
37 |
+ |
int |
38 |
|
headline(s) /* process header line */ |
39 |
|
char *s; |
40 |
|
{ |
47 |
|
rgbinp = 0; |
48 |
|
else |
49 |
|
rgbinp = -2; |
50 |
< |
return; /* don't echo */ |
50 |
> |
return(0); /* don't echo */ |
51 |
|
} |
52 |
|
if (isprims(s)) { /* get input primaries */ |
53 |
|
primsval(inprims, s); |
54 |
< |
return; /* don't echo */ |
54 |
> |
return(0); /* don't echo */ |
55 |
|
} |
56 |
|
/* should I grok colcorr also? */ |
57 |
< |
fputs(s, stdout); |
57 |
> |
return(fputs(s, stdout)); |
58 |
|
} |
59 |
|
|
60 |
|
|
126 |
|
if (rgbinp == -1) |
127 |
|
rgbinp = !rgbout; |
128 |
|
printargs(argc, argv, stdout); /* add to header */ |
128 |
– |
if (expcomp < 0.99 || expcomp > 1.01) |
129 |
– |
fputexpos(expcomp, stdout); |
129 |
|
convert(); /* convert picture */ |
130 |
|
exit(0); |
131 |
|
userr: |
153 |
|
COLORMAT xfm; |
154 |
|
register COLOR *scanin; |
155 |
|
register COLR *scanout; |
156 |
+ |
double ourexp = expcomp; |
157 |
|
int y; |
158 |
|
register int x; |
159 |
|
/* compute transform */ |
160 |
|
if (rgbout) { |
161 |
– |
double mult; |
161 |
|
if (rgbinp) { /* RGBE -> RGBE */ |
162 |
|
comprgb2rgbmat(xfm, inprims, outprims); |
164 |
– |
mult = expcomp; |
163 |
|
} else { /* XYZE -> RGBE */ |
164 |
|
compxyz2rgbmat(xfm, outprims); |
165 |
< |
mult = expcomp/WHTEFFICACY; |
165 |
> |
ourexp *= WHTEFFICACY; |
166 |
|
} |
169 |
– |
for (y = 0; y < 3; y++) |
170 |
– |
for (x = 0; x < 3; x++) |
171 |
– |
xfm[y][x] *= mult; |
167 |
|
} else { |
168 |
|
if (rgbinp) { /* RGBE -> XYZE */ |
169 |
|
comprgb2xyzmat(xfm, inprims); |
170 |
< |
for (y = 0; y < 3; y++) |
176 |
< |
for (x = 0; x < 3; x++) |
177 |
< |
xfm[y][x] *= WHTEFFICACY*expcomp; |
170 |
> |
ourexp /= WHTEFFICACY; |
171 |
|
} else { /* XYZE -> XYZE */ |
172 |
|
for (y = 0; y < 3; y++) |
173 |
|
for (x = 0; x < 3; x++) |
174 |
< |
xfm[y][x] = x==y ? expcomp : 0.; |
174 |
> |
xfm[y][x] = x==y ? 1. : 0.; |
175 |
|
} |
176 |
|
} |
177 |
+ |
for (y = 0; y < 3; y++) |
178 |
+ |
for (x = 0; x < 3; x++) |
179 |
+ |
xfm[y][x] *= expcomp; |
180 |
|
/* get input resolution */ |
181 |
|
if ((order = fgetresolu(&xmax, &ymax, stdin)) < 0) |
182 |
|
quiterr("bad picture format"); |
183 |
|
/* complete output header */ |
184 |
+ |
if (ourexp < 0.99 || ourexp > 1.01) |
185 |
+ |
fputexpos(ourexp, stdout); |
186 |
|
if (rgbout) { |
187 |
|
fputprims(outprims, stdout); |
188 |
|
fputformat(COLRFMT, stdout); |