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 |
55 |
|
|
56 |
|
int nfile; /* number of files */ |
57 |
|
|
58 |
+ |
char ourfmt[LPICFMT+1] = PICFMT; |
59 |
|
int wrongformat = 0; |
60 |
|
|
61 |
< |
FILE *popen(), *lblopen(); |
61 |
> |
FILE *lblopen(); |
62 |
> |
void quit(); |
63 |
|
|
65 |
– |
extern char *malloc(); |
64 |
|
|
67 |
– |
|
65 |
|
tabputs(s) /* print line preceded by a tab */ |
66 |
|
char *s; |
67 |
|
{ |
68 |
|
char fmt[32]; |
69 |
|
|
70 |
< |
if (isformat(s)) { |
71 |
< |
formatval(fmt, s); |
72 |
< |
wrongformat = strcmp(fmt, COLRFMT); |
70 |
> |
if (isheadid(s)) |
71 |
> |
return(0); |
72 |
> |
if (formatval(fmt, s)) { |
73 |
> |
if (globmatch(ourfmt, fmt)) { |
74 |
> |
wrongformat = 0; |
75 |
> |
strcpy(ourfmt, fmt); |
76 |
> |
} else |
77 |
> |
wrongformat = 1; |
78 |
|
} else { |
79 |
|
putc('\t', stdout); |
80 |
|
fputs(s, stdout); |
81 |
|
} |
82 |
+ |
return(0); |
83 |
|
} |
84 |
|
|
85 |
|
|
93 |
|
int xsgn, ysgn; |
94 |
|
char *thislabel; |
95 |
|
int an; |
96 |
< |
#ifdef MSDOS |
97 |
< |
extern int _fmode; |
98 |
< |
_fmode = O_BINARY; |
96 |
< |
setmode(fileno(stdin), O_BINARY); |
97 |
< |
setmode(fileno(stdout), O_BINARY); |
98 |
< |
#endif |
96 |
> |
SET_DEFAULT_BINARY(); |
97 |
> |
SET_FILE_BINARY(stdin); |
98 |
> |
SET_FILE_BINARY(stdout); |
99 |
|
progname = argv[0]; |
100 |
|
|
101 |
|
for (an = 1; an < argc && argv[an][0] == '-'; an++) |
143 |
|
goto userr; |
144 |
|
} |
145 |
|
dofiles: |
146 |
+ |
newheader("RADIANCE", stdout); |
147 |
+ |
fputnow(stdout); |
148 |
|
for (nfile = 0; an < argc; nfile++) { |
149 |
|
if (nfile >= MAXFILE) |
150 |
|
goto toomany; |
222 |
|
printf("%s:\n", input[nfile].name); |
223 |
|
getheader(input[nfile].fp, tabputs, NULL); |
224 |
|
if (wrongformat) { |
225 |
< |
fprintf(stderr, "%s: not a Radiance picture\n", |
225 |
> |
fprintf(stderr, "%s: incompatible input format\n", |
226 |
|
input[nfile].name); |
227 |
|
quit(1); |
228 |
|
} |
289 |
|
ymax = ysiz; |
290 |
|
/* add new header info. */ |
291 |
|
printargs(argc, argv, stdout); |
292 |
< |
fputformat(COLRFMT, stdout); |
292 |
> |
if (strcmp(ourfmt, PICFMT)) |
293 |
> |
fputformat(ourfmt, stdout); /* print format if known */ |
294 |
|
putchar('\n'); |
295 |
|
fprtresolu(xsiz, ysiz, stdout); |
296 |
|
|
382 |
|
|
383 |
|
j = 4; /* check exponents first! */ |
384 |
|
while (j--) |
385 |
< |
if (i = c1[j] - c2[j]) |
385 |
> |
if ( (i = c1[j] - c2[j]) ) |
386 |
|
return(i); |
387 |
|
return(0); |
388 |
|
} |
393 |
|
char *s; |
394 |
|
int *xp, *yp; |
395 |
|
{ |
396 |
< |
char com[128]; |
396 |
> |
char com[PATH_MAX]; |
397 |
|
FILE *fp; |
398 |
|
|
399 |
|
sprintf(com, "psign -s -.15 -a 2 -x %d -y %d '%.90s'", *xp, *yp, s); |
410 |
|
} |
411 |
|
|
412 |
|
|
413 |
+ |
void |
414 |
|
quit(code) /* exit gracefully */ |
415 |
|
int code; |
416 |
|
{ |