1 |
– |
/* Copyright (c) 1993 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 |
|
* pcompos.c - program to composite pictures. |
6 |
|
* |
8 |
|
*/ |
9 |
|
|
10 |
|
#include <stdio.h> |
14 |
– |
|
11 |
|
#include <math.h> |
12 |
+ |
#include <time.h> |
13 |
+ |
#include <string.h> |
14 |
|
|
15 |
< |
#ifdef MSDOS |
18 |
< |
#include <fcntl.h> |
19 |
< |
#endif |
15 |
> |
#include "copyright.h" |
16 |
|
|
17 |
+ |
#include "platform.h" |
18 |
+ |
#include "rtprocess.h" |
19 |
|
#include "color.h" |
22 |
– |
|
20 |
|
#include "resolu.h" |
21 |
|
|
22 |
|
#define MAXFILE 64 |
39 |
|
|
40 |
|
int checkthresh = 0; /* check threshold value */ |
41 |
|
|
42 |
+ |
char StandardInput[] = "<stdin>"; |
43 |
|
char Command[] = "<Command>"; |
44 |
|
char Label[] = "<Label>"; |
45 |
|
|
56 |
|
|
57 |
|
int nfile; /* number of files */ |
58 |
|
|
59 |
+ |
char ourfmt[LPICFMT+1] = PICFMT; |
60 |
|
int wrongformat = 0; |
61 |
|
|
62 |
< |
FILE *popen(), *lblopen(); |
62 |
> |
FILE *lblopen(); |
63 |
> |
void quit(); |
64 |
|
|
65 |
< |
extern char *malloc(); |
65 |
> |
static gethfunc tabputs; |
66 |
|
|
67 |
|
|
68 |
< |
tabputs(s) /* print line preceded by a tab */ |
69 |
< |
char *s; |
68 |
> |
static int |
69 |
> |
tabputs( /* print line preceded by a tab */ |
70 |
> |
char *s, |
71 |
> |
void *p |
72 |
> |
) |
73 |
|
{ |
74 |
|
char fmt[32]; |
75 |
|
|
76 |
< |
if (isformat(s)) { |
77 |
< |
formatval(fmt, s); |
78 |
< |
wrongformat = strcmp(fmt, COLRFMT); |
76 |
> |
if (isheadid(s)) |
77 |
> |
return(0); |
78 |
> |
if (formatval(fmt, s)) { |
79 |
> |
if (globmatch(ourfmt, fmt)) { |
80 |
> |
wrongformat = 0; |
81 |
> |
strcpy(ourfmt, fmt); |
82 |
> |
} else |
83 |
> |
wrongformat = 1; |
84 |
|
} else { |
85 |
|
putc('\t', stdout); |
86 |
|
fputs(s, stdout); |
87 |
|
} |
88 |
+ |
return(0); |
89 |
|
} |
90 |
|
|
91 |
|
|
99 |
|
int xsgn, ysgn; |
100 |
|
char *thislabel; |
101 |
|
int an; |
102 |
< |
#ifdef MSDOS |
103 |
< |
extern int _fmode; |
104 |
< |
_fmode = O_BINARY; |
96 |
< |
setmode(fileno(stdin), O_BINARY); |
97 |
< |
setmode(fileno(stdout), O_BINARY); |
98 |
< |
#endif |
102 |
> |
SET_DEFAULT_BINARY(); |
103 |
> |
SET_FILE_BINARY(stdin); |
104 |
> |
SET_FILE_BINARY(stdout); |
105 |
|
progname = argv[0]; |
106 |
|
|
107 |
|
for (an = 1; an < argc && argv[an][0] == '-'; an++) |
149 |
|
goto userr; |
150 |
|
} |
151 |
|
dofiles: |
152 |
+ |
newheader("RADIANCE", stdout); |
153 |
+ |
fputnow(stdout); |
154 |
|
for (nfile = 0; an < argc; nfile++) { |
155 |
|
if (nfile >= MAXFILE) |
156 |
|
goto toomany; |
208 |
|
if (autolabel && thislabel == NULL) |
209 |
|
thislabel = argv[an]; |
210 |
|
if (!strcmp(argv[an], "-")) { |
211 |
< |
input[nfile].name = "<stdin>"; |
211 |
> |
input[nfile].name = StandardInput; |
212 |
|
input[nfile].fp = stdin; |
213 |
|
} else { |
214 |
|
if (argv[an][0] == '!') { |
228 |
|
printf("%s:\n", input[nfile].name); |
229 |
|
getheader(input[nfile].fp, tabputs, NULL); |
230 |
|
if (wrongformat) { |
231 |
< |
fprintf(stderr, "%s: not a Radiance picture\n", |
231 |
> |
fprintf(stderr, "%s: incompatible input format\n", |
232 |
|
input[nfile].name); |
233 |
|
quit(1); |
234 |
|
} |
295 |
|
ymax = ysiz; |
296 |
|
/* add new header info. */ |
297 |
|
printargs(argc, argv, stdout); |
298 |
< |
fputformat(COLRFMT, stdout); |
298 |
> |
if (strcmp(ourfmt, PICFMT)) |
299 |
> |
fputformat(ourfmt, stdout); /* print format if known */ |
300 |
|
putchar('\n'); |
301 |
|
fprtresolu(xsiz, ysiz, stdout); |
302 |
|
|
373 |
|
quit(1); |
374 |
|
} |
375 |
|
} |
376 |
+ |
/* read remainders from streams */ |
377 |
+ |
for (i = 0; i < nfile; i++) |
378 |
+ |
if (input[i].name[0] == '<') |
379 |
+ |
while (getc(input[i].fp) != EOF) |
380 |
+ |
; |
381 |
|
return; |
382 |
|
memerr: |
383 |
|
perror(progname); |
393 |
|
|
394 |
|
j = 4; /* check exponents first! */ |
395 |
|
while (j--) |
396 |
< |
if (i = c1[j] - c2[j]) |
396 |
> |
if ( (i = c1[j] - c2[j]) ) |
397 |
|
return(i); |
398 |
|
return(0); |
399 |
|
} |
404 |
|
char *s; |
405 |
|
int *xp, *yp; |
406 |
|
{ |
407 |
< |
char com[128]; |
407 |
> |
char com[PATH_MAX]; |
408 |
|
FILE *fp; |
409 |
|
|
410 |
|
sprintf(com, "psign -s -.15 -a 2 -x %d -y %d '%.90s'", *xp, *yp, s); |
421 |
|
} |
422 |
|
|
423 |
|
|
424 |
+ |
void |
425 |
|
quit(code) /* exit gracefully */ |
426 |
|
int code; |
427 |
|
{ |