| 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)) { |
| 393 |
|
quit(1); |
| 394 |
|
} |
| 395 |
|
} |
| 396 |
< |
efree(scanout); |
| 396 |
> |
efree((char *)scanout); |
| 397 |
|
} |
| 398 |
|
|
| 399 |
|
|
| 518 |
|
static unsigned long ltick[MAXINP]; |
| 519 |
|
static FVECT lorg[MAXINP], ldir[MAXINP]; |
| 520 |
|
static double ldist[MAXINP]; |
| 521 |
< |
FLOAT loc[2]; |
| 521 |
> |
RREAL loc[2]; |
| 522 |
|
int fn; |
| 523 |
|
register int i; |
| 524 |
|
|
| 527 |
|
errno = EDOM; |
| 528 |
|
return(0.0); |
| 529 |
|
} |
| 530 |
< |
if (ltick[fn] < eclock) { /* need to compute? */ |
| 530 |
> |
if (ltick[fn] != eclock) { /* need to compute? */ |
| 531 |
|
lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0; |
| 532 |
|
ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0; |
| 533 |
+ |
ldist[fn] = -1.0; |
| 534 |
|
if (input[fn].vw.type == 0) |
| 535 |
|
errno = EDOM; |
| 536 |
|
else { |
| 556 |
|
static unsigned long ltick[MAXINP]; |
| 557 |
|
static double psize[MAXINP]; |
| 558 |
|
FVECT dir0, org, dirx, diry; |
| 559 |
< |
FLOAT locx[2], locy[2]; |
| 559 |
> |
RREAL locx[2], locy[2]; |
| 560 |
|
double d; |
| 561 |
|
int fn; |
| 562 |
|
register int i; |
| 567 |
|
return(0.0); |
| 568 |
|
} |
| 569 |
|
fn = d - .5; |
| 570 |
< |
if (ltick[fn] < eclock) { /* need to compute? */ |
| 570 |
> |
if (ltick[fn] != eclock) { /* need to compute? */ |
| 571 |
|
psize[fn] = 0.0; |
| 572 |
|
if (input[fn].vw.type == 0) |
| 573 |
|
errno = EDOM; |
| 587 |
|
diry[i] -= dir0[i]; |
| 588 |
|
} |
| 589 |
|
fcross(dir0, dirx, diry); |
| 590 |
< |
psize[fn] = 0.5 * sqrt(DOT(dir0,dir0)); |
| 590 |
> |
psize[fn] = sqrt(DOT(dir0,dir0)); |
| 591 |
|
} |
| 592 |
|
} |
| 593 |
|
ltick[fn] = eclock; |
| 596 |
|
} |
| 597 |
|
|
| 598 |
|
|
| 599 |
+ |
void |
| 600 |
|
wputs(msg) |
| 601 |
|
char *msg; |
| 602 |
|
{ |
| 605 |
|
} |
| 606 |
|
|
| 607 |
|
|
| 608 |
+ |
void |
| 609 |
|
eputs(msg) |
| 610 |
|
char *msg; |
| 611 |
|
{ |
| 613 |
|
} |
| 614 |
|
|
| 615 |
|
|
| 616 |
+ |
void |
| 617 |
|
quit(code) /* exit gracefully */ |
| 618 |
|
int code; |
| 619 |
|
{ |