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 |
|
* |
8 |
|
*/ |
9 |
|
|
10 |
|
#include "standard.h" |
11 |
< |
|
11 |
> |
#include "platform.h" |
12 |
|
#include "color.h" |
16 |
– |
|
17 |
– |
#include "resolu.h" |
18 |
– |
|
13 |
|
#include "calcomp.h" |
20 |
– |
|
14 |
|
#include "view.h" |
15 |
|
|
16 |
|
#define MAXINP 32 /* maximum number of input files */ |
17 |
< |
#define WINSIZ 17 /* scanline window size */ |
17 |
> |
#define WINSIZ 64 /* scanline window size */ |
18 |
|
#define MIDSCN ((WINSIZ-1)/2+1) |
19 |
|
|
20 |
|
struct { |
81 |
|
int original; |
82 |
|
double f; |
83 |
|
int a, i; |
84 |
< |
#ifdef MSDOS |
85 |
< |
extern int _fmode; |
86 |
< |
_fmode = O_BINARY; |
94 |
< |
setmode(fileno(stdin), O_BINARY); |
95 |
< |
setmode(fileno(stdout), O_BINARY); |
96 |
< |
#endif |
84 |
> |
SET_DEFAULT_BINARY(); |
85 |
> |
SET_FILE_BINARY(stdin); |
86 |
> |
SET_FILE_BINARY(stdout); |
87 |
|
progname = argv[0]; |
88 |
|
/* scan options */ |
89 |
|
for (a = 1; a < argc; a++) { |
104 |
|
break; |
105 |
|
} |
106 |
|
newheader("RADIANCE", stdout); /* start header */ |
107 |
+ |
fputnow(stdout); |
108 |
|
/* process files */ |
109 |
|
for (nfiles = 0; nfiles < MAXINP; nfiles++) { |
110 |
|
setcolor(input[nfiles].coef, 1.0, 1.0, 1.0); |
111 |
|
setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); |
112 |
< |
copystruct(&input[nfiles].vw, &stdview); |
112 |
> |
input[nfiles].vw = stdview; |
113 |
|
input[nfiles].pa = 1.0; |
114 |
|
} |
115 |
|
nfiles = 0; |
162 |
|
colval(input[nfiles].expos,GRN); |
163 |
|
colval(input[nfiles].coef,BLU) /= |
164 |
|
colval(input[nfiles].expos,BLU); |
165 |
+ |
setcolor(input[nfiles].expos, 1.0, 1.0, 1.0); |
166 |
|
} |
167 |
|
nfiles++; |
168 |
|
original = 0; |
219 |
|
} |
220 |
|
|
221 |
|
|
222 |
< |
tputs(s) /* put out string preceded by a tab */ |
222 |
> |
tabputs(s) /* put out string preceded by a tab */ |
223 |
|
char *s; |
224 |
|
{ |
225 |
|
char fmt[32]; |
227 |
|
COLOR ctmp; |
228 |
|
|
229 |
|
if (isheadid(s)) /* header id */ |
230 |
< |
return; /* don't echo */ |
230 |
> |
return(0); /* don't echo */ |
231 |
|
if (formatval(fmt, s)) { /* check format */ |
232 |
|
if (globmatch(ourfmt, fmt)) { |
233 |
|
wrongformat = 0; |
234 |
|
strcpy(ourfmt, fmt); |
235 |
|
} else |
236 |
< |
wrongformat = 1; |
237 |
< |
return; /* don't echo */ |
236 |
> |
wrongformat = globmatch(PICFMT, fmt) ? 1 : -1; |
237 |
> |
return(0); /* don't echo */ |
238 |
|
} |
239 |
|
if (isexpos(s)) { /* exposure */ |
240 |
|
d = exposval(s); |
248 |
|
gotview++; |
249 |
|
/* echo line */ |
250 |
|
putchar('\t'); |
251 |
< |
fputs(s, stdout); |
251 |
> |
return(fputs(s, stdout)); |
252 |
|
} |
253 |
|
|
254 |
|
|
259 |
|
gotview = 0; |
260 |
|
fputs(input[nfiles].name, stdout); |
261 |
|
fputs(":\n", stdout); |
262 |
< |
getheader(input[nfiles].fp, tputs, NULL); |
263 |
< |
if (wrongformat) { |
262 |
> |
getheader(input[nfiles].fp, tabputs, NULL); |
263 |
> |
if (wrongformat < 0) { |
264 |
|
eputs(input[nfiles].name); |
265 |
< |
eputs(": not in Radiance picture format\n"); |
265 |
> |
eputs(": not a Radiance picture\n"); |
266 |
|
quit(1); |
267 |
|
} |
268 |
+ |
if (wrongformat > 0) { |
269 |
+ |
wputs(input[nfiles].name); |
270 |
+ |
wputs(": warning -- incompatible picture format\n"); |
271 |
+ |
} |
272 |
|
if (!gotview || setview(&input[nfiles].vw) != NULL) |
273 |
|
input[nfiles].vw.type = 0; |
274 |
|
if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) { |
312 |
|
|
313 |
|
init() /* perform final setup */ |
314 |
|
{ |
315 |
< |
double l_colin(), l_expos(), l_pixaspect(), l_ray(), l_psize(); |
315 |
> |
double l_colin(char *), l_expos(char *), l_pixaspect(char *), |
316 |
> |
l_ray(char *), l_psize(char *); |
317 |
|
register int i; |
318 |
|
/* define constants */ |
319 |
|
varset("PI", ':', PI); |
394 |
|
quit(1); |
395 |
|
} |
396 |
|
} |
397 |
< |
efree(scanout); |
397 |
> |
efree((char *)scanout); |
398 |
|
} |
399 |
|
|
400 |
|
|
447 |
|
|
448 |
|
|
449 |
|
double |
450 |
< |
l_pixaspect() /* return pixel aspect ratio */ |
450 |
> |
l_pixaspect(char *nm) /* return pixel aspect ratio */ |
451 |
|
{ |
452 |
|
register int fn; |
453 |
|
|
519 |
|
static unsigned long ltick[MAXINP]; |
520 |
|
static FVECT lorg[MAXINP], ldir[MAXINP]; |
521 |
|
static double ldist[MAXINP]; |
522 |
< |
FLOAT loc[2]; |
522 |
> |
RREAL loc[2]; |
523 |
|
int fn; |
524 |
|
register int i; |
525 |
|
|
528 |
|
errno = EDOM; |
529 |
|
return(0.0); |
530 |
|
} |
531 |
< |
if (ltick[fn] < eclock) { /* need to compute? */ |
531 |
> |
if (ltick[fn] != eclock) { /* need to compute? */ |
532 |
|
lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0; |
533 |
|
ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0; |
534 |
+ |
ldist[fn] = -1.0; |
535 |
|
if (input[fn].vw.type == 0) |
536 |
|
errno = EDOM; |
537 |
|
else { |
552 |
|
|
553 |
|
|
554 |
|
double |
555 |
< |
l_psize() /* compute pixel size in steradians */ |
555 |
> |
l_psize(char *nm) /* compute pixel size in steradians */ |
556 |
|
{ |
557 |
|
static unsigned long ltick[MAXINP]; |
558 |
|
static double psize[MAXINP]; |
559 |
|
FVECT dir0, org, dirx, diry; |
560 |
< |
FLOAT locx[2], locy[2]; |
560 |
> |
RREAL locx[2], locy[2]; |
561 |
|
double d; |
562 |
|
int fn; |
563 |
|
register int i; |
568 |
|
return(0.0); |
569 |
|
} |
570 |
|
fn = d - .5; |
571 |
< |
if (ltick[fn] < eclock) { /* need to compute? */ |
571 |
> |
if (ltick[fn] != eclock) { /* need to compute? */ |
572 |
|
psize[fn] = 0.0; |
573 |
|
if (input[fn].vw.type == 0) |
574 |
|
errno = EDOM; |
588 |
|
diry[i] -= dir0[i]; |
589 |
|
} |
590 |
|
fcross(dir0, dirx, diry); |
591 |
< |
psize[fn] = 0.5 * sqrt(DOT(dir0,dir0)); |
591 |
> |
psize[fn] = sqrt(DOT(dir0,dir0)); |
592 |
|
} |
593 |
|
} |
594 |
|
ltick[fn] = eclock; |
597 |
|
} |
598 |
|
|
599 |
|
|
600 |
+ |
void |
601 |
|
wputs(msg) |
602 |
|
char *msg; |
603 |
|
{ |
606 |
|
} |
607 |
|
|
608 |
|
|
609 |
+ |
void |
610 |
|
eputs(msg) |
611 |
|
char *msg; |
612 |
|
{ |
614 |
|
} |
615 |
|
|
616 |
|
|
617 |
+ |
void |
618 |
|
quit(code) /* exit gracefully */ |
619 |
|
int code; |
620 |
|
{ |