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 |
|
|
64 |
< |
extern char *malloc(); |
64 |
> |
static gethfunc tabputs; |
65 |
|
|
66 |
|
|
67 |
< |
tabputs(s) /* print line preceded by a tab */ |
68 |
< |
char *s; |
67 |
> |
static int |
68 |
> |
tabputs( /* print line preceded by a tab */ |
69 |
> |
char *s, |
70 |
> |
void *p |
71 |
> |
) |
72 |
|
{ |
73 |
|
char fmt[32]; |
74 |
|
|
75 |
< |
if (isformat(s)) { |
76 |
< |
formatval(fmt, s); |
77 |
< |
wrongformat = strcmp(fmt, COLRFMT); |
75 |
> |
if (isheadid(s)) |
76 |
> |
return(0); |
77 |
> |
if (formatval(fmt, s)) { |
78 |
> |
if (globmatch(ourfmt, fmt)) { |
79 |
> |
wrongformat = 0; |
80 |
> |
strcpy(ourfmt, fmt); |
81 |
> |
} else |
82 |
> |
wrongformat = 1; |
83 |
|
} else { |
84 |
|
putc('\t', stdout); |
85 |
|
fputs(s, stdout); |
86 |
|
} |
87 |
+ |
return(0); |
88 |
|
} |
89 |
|
|
90 |
|
|
98 |
|
int xsgn, ysgn; |
99 |
|
char *thislabel; |
100 |
|
int an; |
101 |
< |
#ifdef MSDOS |
102 |
< |
extern int _fmode; |
103 |
< |
_fmode = O_BINARY; |
96 |
< |
setmode(fileno(stdin), O_BINARY); |
97 |
< |
setmode(fileno(stdout), O_BINARY); |
98 |
< |
#endif |
101 |
> |
SET_DEFAULT_BINARY(); |
102 |
> |
SET_FILE_BINARY(stdin); |
103 |
> |
SET_FILE_BINARY(stdout); |
104 |
|
progname = argv[0]; |
105 |
|
|
106 |
|
for (an = 1; an < argc && argv[an][0] == '-'; an++) |
148 |
|
goto userr; |
149 |
|
} |
150 |
|
dofiles: |
151 |
+ |
newheader("RADIANCE", stdout); |
152 |
+ |
fputnow(stdout); |
153 |
|
for (nfile = 0; an < argc; nfile++) { |
154 |
|
if (nfile >= MAXFILE) |
155 |
|
goto toomany; |
227 |
|
printf("%s:\n", input[nfile].name); |
228 |
|
getheader(input[nfile].fp, tabputs, NULL); |
229 |
|
if (wrongformat) { |
230 |
< |
fprintf(stderr, "%s: not a Radiance picture\n", |
230 |
> |
fprintf(stderr, "%s: incompatible input format\n", |
231 |
|
input[nfile].name); |
232 |
|
quit(1); |
233 |
|
} |
294 |
|
ymax = ysiz; |
295 |
|
/* add new header info. */ |
296 |
|
printargs(argc, argv, stdout); |
297 |
< |
fputformat(COLRFMT, stdout); |
297 |
> |
if (strcmp(ourfmt, PICFMT)) |
298 |
> |
fputformat(ourfmt, stdout); /* print format if known */ |
299 |
|
putchar('\n'); |
300 |
|
fprtresolu(xsiz, ysiz, stdout); |
301 |
|
|
387 |
|
|
388 |
|
j = 4; /* check exponents first! */ |
389 |
|
while (j--) |
390 |
< |
if (i = c1[j] - c2[j]) |
390 |
> |
if ( (i = c1[j] - c2[j]) ) |
391 |
|
return(i); |
392 |
|
return(0); |
393 |
|
} |
398 |
|
char *s; |
399 |
|
int *xp, *yp; |
400 |
|
{ |
401 |
< |
char com[128]; |
401 |
> |
char com[PATH_MAX]; |
402 |
|
FILE *fp; |
403 |
|
|
404 |
|
sprintf(com, "psign -s -.15 -a 2 -x %d -y %d '%.90s'", *xp, *yp, s); |
415 |
|
} |
416 |
|
|
417 |
|
|
418 |
+ |
void |
419 |
|
quit(code) /* exit gracefully */ |
420 |
|
int code; |
421 |
|
{ |