65 |
|
exit(1); |
66 |
|
} |
67 |
|
if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { |
68 |
< |
fprintf(stderr, "can't open output \"%s\"\n", |
68 |
> |
fprintf(stderr, "%s: can't open output \"%s\"\n", |
69 |
|
progname, argv[i+1]); |
70 |
|
exit(1); |
71 |
|
} |
78 |
|
/* get their image resolution */ |
79 |
|
xmax = getint(4, stdin); |
80 |
|
ymax = getint(4, stdin); |
81 |
+ |
if (feof(stdin)) |
82 |
+ |
quiterr("empty input file"); |
83 |
|
/* put our header */ |
84 |
|
printargs(i, argv, stdout); |
85 |
|
fputformat(COLRFMT, stdout); |
129 |
|
quiterr("out of memory in avs2ra"); |
130 |
|
/* convert image */ |
131 |
|
for (y = ymax-1; y >= 0; y--) { |
132 |
< |
(void)getc(stdin); /* toss alpha */ |
133 |
< |
scanout[x][RED] = getc(stdin); |
134 |
< |
scanout[x][GRN] = getc(stdin); |
135 |
< |
scanout[x][BLU] = getc(stdin); |
136 |
< |
if (feof(stdin) || ferror(stdin)) |
132 |
> |
for (x = 0; x < xmax; x++) { |
133 |
> |
(void)getc(stdin); /* toss alpha */ |
134 |
> |
scanout[x][RED] = getc(stdin); |
135 |
> |
scanout[x][GRN] = getc(stdin); |
136 |
> |
scanout[x][BLU] = getc(stdin); |
137 |
> |
} |
138 |
> |
if (feof(stdin) | ferror(stdin)) |
139 |
|
quiterr("error reading AVS image"); |
140 |
|
/* undo gamma */ |
141 |
|
gambs_colrs(scanout, xmax); |