15 |
|
#include "color.h" |
16 |
|
|
17 |
|
|
18 |
< |
#define MAXFILE 16 |
18 |
> |
#define MAXFILE 32 |
19 |
|
|
20 |
|
/* output picture size */ |
21 |
|
int xsiz = 0; |
123 |
|
} else { |
124 |
|
input[nfile].name = argv[an]; |
125 |
|
if ((input[nfile].fp = fopen(argv[an], "r")) == NULL) { |
126 |
< |
fprintf(stderr, "%s: cannot open\n", argv[an]); |
126 |
> |
perror(argv[an]); |
127 |
|
quit(1); |
128 |
|
} |
129 |
|
} |
132 |
|
printf("%s:\n", input[nfile].name); |
133 |
|
getheader(input[nfile].fp, tabputs); |
134 |
|
/* get picture size */ |
135 |
< |
if (fscanf(input[nfile].fp, "-Y %d +X %d\n", |
136 |
< |
&input[nfile].yres, &input[nfile].xres) != 2) { |
135 |
> |
if (fgetresolu(&input[nfile].xres, &input[nfile].yres, |
136 |
> |
input[nfile].fp) != (YMAJOR|YDECR)) { |
137 |
|
fprintf(stderr, "%s: bad picture size\n", |
138 |
|
input[nfile].name); |
139 |
|
quit(1); |
173 |
|
int y; |
174 |
|
register int x, i; |
175 |
|
|
176 |
< |
scanin = (COLR *)malloc((xmax-xmin)*sizeof(COLR)) - xmin; |
177 |
< |
scanin = (COLR *)malloc((xmax-xmin)*sizeof(COLR)) - xmin; |
176 |
> |
scanin = (COLR *)malloc((xmax-xmin)*sizeof(COLR)); |
177 |
|
if (scanin == NULL) |
178 |
|
goto memerr; |
179 |
|
scanin -= xmin; |
217 |
|
if (y >= ysiz) |
218 |
|
continue; |
219 |
|
if (fwritecolrs(scanout, xsiz, stdout) < 0) { |
220 |
< |
fprintf(stderr, "%s: write error\n", progname); |
220 |
> |
perror(progname); |
221 |
|
quit(1); |
222 |
|
} |
223 |
|
} |
224 |
|
return; |
225 |
|
memerr: |
226 |
< |
fprintf(stderr, "%s: out of memory\n", progname); |
226 |
> |
perror(progname); |
227 |
|
quit(1); |
228 |
|
} |
229 |
|
|