1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Combine picture files according to calcomp functions. |
6 |
|
* |
7 |
|
* 1/4/89 |
8 |
|
*/ |
9 |
|
|
10 |
< |
#include "standard.h" |
11 |
< |
|
10 |
> |
#include "platform.h" |
11 |
> |
#include "rtprocess.h" |
12 |
> |
#include "rterror.h" |
13 |
|
#include "color.h" |
16 |
– |
|
17 |
– |
#include "resolu.h" |
18 |
– |
|
14 |
|
#include "calcomp.h" |
20 |
– |
|
15 |
|
#include "view.h" |
16 |
|
|
17 |
|
#define MAXINP 32 /* maximum number of input files */ |
18 |
< |
#define WINSIZ 17 /* scanline window size */ |
18 |
> |
#define WINSIZ 64 /* scanline window size */ |
19 |
|
#define MIDSCN ((WINSIZ-1)/2+1) |
20 |
|
|
21 |
|
struct { |
33 |
|
|
34 |
|
char ourfmt[LPICFMT+1] = PICFMT; /* input picture format */ |
35 |
|
|
36 |
+ |
char StandardInput[] = "<stdin>"; |
37 |
|
char Command[] = "<Command>"; |
38 |
|
char vcolin[3][4] = {"ri", "gi", "bi"}; |
39 |
|
char vcolout[3][4] = {"ro", "go", "bo"}; |
71 |
|
int wrongformat = 0; |
72 |
|
int gotview; |
73 |
|
|
79 |
– |
FILE *popen(); |
74 |
|
|
75 |
|
extern char *emalloc(); |
76 |
|
|
77 |
+ |
static gethfunc tabputs; |
78 |
|
|
79 |
|
main(argc, argv) |
80 |
|
int argc; |
83 |
|
int original; |
84 |
|
double f; |
85 |
|
int a, i; |
86 |
< |
#ifdef MSDOS |
87 |
< |
extern int _fmode; |
88 |
< |
_fmode = O_BINARY; |
94 |
< |
setmode(fileno(stdin), O_BINARY); |
95 |
< |
setmode(fileno(stdout), O_BINARY); |
96 |
< |
#endif |
86 |
> |
SET_DEFAULT_BINARY(); |
87 |
> |
SET_FILE_BINARY(stdin); |
88 |
> |
SET_FILE_BINARY(stdout); |
89 |
|
progname = argv[0]; |
90 |
|
/* scan options */ |
91 |
|
for (a = 1; a < argc; a++) { |
106 |
|
break; |
107 |
|
} |
108 |
|
newheader("RADIANCE", stdout); /* start header */ |
109 |
+ |
fputnow(stdout); |
110 |
|
/* process files */ |
111 |
|
for (nfiles = 0; nfiles < MAXINP; nfiles++) { |
112 |
|
setcolor(input[nfiles].coef, 1.0, 1.0, 1.0); |
113 |
|
setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); |
114 |
< |
copystruct(&input[nfiles].vw, &stdview); |
114 |
> |
input[nfiles].vw = stdview; |
115 |
|
input[nfiles].pa = 1.0; |
116 |
|
} |
117 |
|
nfiles = 0; |
125 |
|
if (argv[a][0] == '-') |
126 |
|
switch (argv[a][1]) { |
127 |
|
case '\0': |
128 |
< |
input[nfiles].name = "<stdin>"; |
128 |
> |
input[nfiles].name = StandardInput; |
129 |
|
input[nfiles].fp = stdin; |
130 |
|
break; |
131 |
|
case 'o': |
164 |
|
colval(input[nfiles].expos,GRN); |
165 |
|
colval(input[nfiles].coef,BLU) /= |
166 |
|
colval(input[nfiles].expos,BLU); |
167 |
+ |
setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); |
168 |
|
} |
169 |
|
nfiles++; |
170 |
|
original = 0; |
221 |
|
} |
222 |
|
|
223 |
|
|
224 |
< |
tputs(s) /* put out string preceded by a tab */ |
225 |
< |
char *s; |
224 |
> |
static int |
225 |
> |
tabputs( /* put out string preceded by a tab */ |
226 |
> |
char *s, |
227 |
> |
void *p |
228 |
> |
) |
229 |
|
{ |
230 |
|
char fmt[32]; |
231 |
|
double d; |
232 |
|
COLOR ctmp; |
233 |
|
|
234 |
|
if (isheadid(s)) /* header id */ |
235 |
< |
return; /* don't echo */ |
235 |
> |
return(0); /* don't echo */ |
236 |
|
if (formatval(fmt, s)) { /* check format */ |
237 |
|
if (globmatch(ourfmt, fmt)) { |
238 |
|
wrongformat = 0; |
239 |
|
strcpy(ourfmt, fmt); |
240 |
|
} else |
241 |
< |
wrongformat = 1; |
242 |
< |
return; /* don't echo */ |
241 |
> |
wrongformat = globmatch(PICFMT, fmt) ? 1 : -1; |
242 |
> |
return(0); /* don't echo */ |
243 |
|
} |
244 |
|
if (isexpos(s)) { /* exposure */ |
245 |
|
d = exposval(s); |
253 |
|
gotview++; |
254 |
|
/* echo line */ |
255 |
|
putchar('\t'); |
256 |
< |
fputs(s, stdout); |
256 |
> |
return(fputs(s, stdout)); |
257 |
|
} |
258 |
|
|
259 |
|
|
264 |
|
gotview = 0; |
265 |
|
fputs(input[nfiles].name, stdout); |
266 |
|
fputs(":\n", stdout); |
267 |
< |
getheader(input[nfiles].fp, tputs, NULL); |
268 |
< |
if (wrongformat) { |
267 |
> |
getheader(input[nfiles].fp, tabputs, NULL); |
268 |
> |
if (wrongformat < 0) { |
269 |
|
eputs(input[nfiles].name); |
270 |
< |
eputs(": not in Radiance picture format\n"); |
270 |
> |
eputs(": not a Radiance picture\n"); |
271 |
|
quit(1); |
272 |
|
} |
273 |
+ |
if (wrongformat > 0) { |
274 |
+ |
wputs(input[nfiles].name); |
275 |
+ |
wputs(": warning -- incompatible picture format\n"); |
276 |
+ |
} |
277 |
|
if (!gotview || setview(&input[nfiles].vw) != NULL) |
278 |
|
input[nfiles].vw.type = 0; |
279 |
|
if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) { |
317 |
|
|
318 |
|
init() /* perform final setup */ |
319 |
|
{ |
320 |
< |
double l_colin(), l_expos(), l_pixaspect(), l_ray(), l_psize(); |
320 |
> |
double l_colin(char *), l_expos(char *), l_pixaspect(char *), |
321 |
> |
l_ray(char *), l_psize(char *); |
322 |
|
register int i; |
323 |
|
/* define constants */ |
324 |
|
varset("PI", ':', PI); |
399 |
|
quit(1); |
400 |
|
} |
401 |
|
} |
402 |
< |
efree(scanout); |
402 |
> |
efree((char *)scanout); |
403 |
|
} |
404 |
|
|
405 |
|
|
452 |
|
|
453 |
|
|
454 |
|
double |
455 |
< |
l_pixaspect() /* return pixel aspect ratio */ |
455 |
> |
l_pixaspect(char *nm) /* return pixel aspect ratio */ |
456 |
|
{ |
457 |
|
register int fn; |
458 |
|
|
524 |
|
static unsigned long ltick[MAXINP]; |
525 |
|
static FVECT lorg[MAXINP], ldir[MAXINP]; |
526 |
|
static double ldist[MAXINP]; |
527 |
< |
FLOAT loc[2]; |
527 |
> |
RREAL loc[2]; |
528 |
|
int fn; |
529 |
|
register int i; |
530 |
|
|
533 |
|
errno = EDOM; |
534 |
|
return(0.0); |
535 |
|
} |
536 |
< |
if (ltick[fn] < eclock) { /* need to compute? */ |
536 |
> |
if (ltick[fn] != eclock) { /* need to compute? */ |
537 |
|
lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0; |
538 |
|
ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0; |
539 |
+ |
ldist[fn] = -1.0; |
540 |
|
if (input[fn].vw.type == 0) |
541 |
|
errno = EDOM; |
542 |
|
else { |
557 |
|
|
558 |
|
|
559 |
|
double |
560 |
< |
l_psize() /* compute pixel size in steradians */ |
560 |
> |
l_psize(char *nm) /* compute pixel size in steradians */ |
561 |
|
{ |
562 |
|
static unsigned long ltick[MAXINP]; |
563 |
|
static double psize[MAXINP]; |
564 |
|
FVECT dir0, org, dirx, diry; |
565 |
< |
FLOAT locx[2], locy[2]; |
565 |
> |
RREAL locx[2], locy[2]; |
566 |
|
double d; |
567 |
|
int fn; |
568 |
|
register int i; |
573 |
|
return(0.0); |
574 |
|
} |
575 |
|
fn = d - .5; |
576 |
< |
if (ltick[fn] < eclock) { /* need to compute? */ |
576 |
> |
if (ltick[fn] != eclock) { /* need to compute? */ |
577 |
|
psize[fn] = 0.0; |
578 |
|
if (input[fn].vw.type == 0) |
579 |
|
errno = EDOM; |
593 |
|
diry[i] -= dir0[i]; |
594 |
|
} |
595 |
|
fcross(dir0, dirx, diry); |
596 |
< |
psize[fn] = 0.5 * sqrt(DOT(dir0,dir0)); |
596 |
> |
psize[fn] = sqrt(DOT(dir0,dir0)); |
597 |
|
} |
598 |
|
} |
599 |
|
ltick[fn] = eclock; |
602 |
|
} |
603 |
|
|
604 |
|
|
605 |
< |
wputs(msg) |
606 |
< |
char *msg; |
605 |
> |
extern void |
606 |
> |
wputs(char *msg) |
607 |
|
{ |
608 |
|
if (!nowarn) |
609 |
|
eputs(msg); |
610 |
|
} |
611 |
|
|
612 |
|
|
613 |
< |
eputs(msg) |
614 |
< |
char *msg; |
613 |
> |
extern void |
614 |
> |
eputs(char *msg) |
615 |
|
{ |
616 |
|
fputs(msg, stderr); |
617 |
|
} |
618 |
|
|
619 |
|
|
620 |
< |
quit(code) /* exit gracefully */ |
621 |
< |
int code; |
620 |
> |
extern void |
621 |
> |
quit(int code) /* exit gracefully */ |
622 |
|
{ |
623 |
|
register int i; |
624 |
|
/* close input files */ |