| 15 |
|
#include "color.h" |
| 16 |
|
|
| 17 |
|
|
| 18 |
< |
#define MAXFILE 16 |
| 18 |
> |
#define MAXFILE 32 |
| 19 |
|
|
| 20 |
|
/* output picture size */ |
| 21 |
|
int xsiz = 0; |
| 43 |
|
|
| 44 |
|
int nfile; /* number of files */ |
| 45 |
|
|
| 46 |
+ |
int wrongformat = 0; |
| 47 |
|
|
| 48 |
+ |
|
| 49 |
|
tabputs(s) /* print line preceded by a tab */ |
| 50 |
|
char *s; |
| 51 |
|
{ |
| 52 |
< |
putc('\t', stdout); |
| 53 |
< |
fputs(s, stdout); |
| 52 |
> |
char fmt[32]; |
| 53 |
> |
|
| 54 |
> |
if (isformat(s)) { |
| 55 |
> |
formatval(fmt, s); |
| 56 |
> |
wrongformat = strcmp(fmt, COLRFMT); |
| 57 |
> |
} else { |
| 58 |
> |
putc('\t', stdout); |
| 59 |
> |
fputs(s, stdout); |
| 60 |
> |
} |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
|
| 132 |
|
} else { |
| 133 |
|
input[nfile].name = argv[an]; |
| 134 |
|
if ((input[nfile].fp = fopen(argv[an], "r")) == NULL) { |
| 135 |
< |
fprintf(stderr, "%s: cannot open\n", argv[an]); |
| 135 |
> |
perror(argv[an]); |
| 136 |
|
quit(1); |
| 137 |
|
} |
| 138 |
|
} |
| 139 |
|
an++; |
| 140 |
|
/* get header */ |
| 141 |
|
printf("%s:\n", input[nfile].name); |
| 142 |
< |
getheader(input[nfile].fp, tabputs); |
| 142 |
> |
getheader(input[nfile].fp, tabputs, NULL); |
| 143 |
> |
if (wrongformat) { |
| 144 |
> |
fprintf(stderr, "%s: not a Radiance picture\n", |
| 145 |
> |
input[nfile].name); |
| 146 |
> |
quit(1); |
| 147 |
> |
} |
| 148 |
|
/* get picture size */ |
| 149 |
< |
if (fscanf(input[nfile].fp, "-Y %d +X %d\n", |
| 150 |
< |
&input[nfile].yres, &input[nfile].xres) != 2) { |
| 149 |
> |
if (fgetresolu(&input[nfile].xres, &input[nfile].yres, |
| 150 |
> |
input[nfile].fp) != (YMAJOR|YDECR)) { |
| 151 |
|
fprintf(stderr, "%s: bad picture size\n", |
| 152 |
|
input[nfile].name); |
| 153 |
|
quit(1); |
| 169 |
|
ysiz = ymax; |
| 170 |
|
/* add new header info. */ |
| 171 |
|
printargs(argc, argv, stdout); |
| 172 |
+ |
fputformat(COLRFMT, stdout); |
| 173 |
|
printf("\n-Y %d +X %d\n", ysiz, xsiz); |
| 174 |
|
|
| 175 |
|
compos(); |
| 188 |
|
int y; |
| 189 |
|
register int x, i; |
| 190 |
|
|
| 191 |
< |
scanin = (COLR *)malloc((xmax-xmin)*sizeof(COLR)) - xmin; |
| 177 |
< |
scanin = (COLR *)malloc((xmax-xmin)*sizeof(COLR)) - xmin; |
| 191 |
> |
scanin = (COLR *)malloc((xmax-xmin)*sizeof(COLR)); |
| 192 |
|
if (scanin == NULL) |
| 193 |
|
goto memerr; |
| 194 |
|
scanin -= xmin; |
| 232 |
|
if (y >= ysiz) |
| 233 |
|
continue; |
| 234 |
|
if (fwritecolrs(scanout, xsiz, stdout) < 0) { |
| 235 |
< |
fprintf(stderr, "%s: write error\n", progname); |
| 235 |
> |
perror(progname); |
| 236 |
|
quit(1); |
| 237 |
|
} |
| 238 |
|
} |
| 239 |
|
return; |
| 240 |
|
memerr: |
| 241 |
< |
fprintf(stderr, "%s: out of memory\n", progname); |
| 241 |
> |
perror(progname); |
| 242 |
|
quit(1); |
| 243 |
|
} |
| 244 |
|
|