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