75 |
|
quiterr("incompatible format"); |
76 |
|
/* put header */ |
77 |
|
printargs(i, argv, stdout); |
78 |
+ |
fputformat(COLRFMT, stdout); |
79 |
|
putchar('\n'); |
80 |
|
fputresolu(YMAJOR|YDECR, xmax, ymax, stdout); |
81 |
|
/* convert file */ |
82 |
|
pr2ra(); |
83 |
|
} else { |
84 |
< |
/* discard input header */ |
85 |
< |
getheader(stdin, NULL); |
86 |
< |
/* get resolution */ |
87 |
< |
if (fgetresolu(&xmax, &ymax, stdin) != (YMAJOR|YDECR)) |
87 |
< |
quiterr("bad picture size"); |
84 |
> |
/* get header info. */ |
85 |
> |
if (checkheader(stdin, COLRFMT, NULL) < 0 || |
86 |
> |
fgetresolu(&xmax, &ymax, stdin) != (YMAJOR|YDECR)) |
87 |
> |
quiterr("bad picture format"); |
88 |
|
/* write rasterfile header */ |
89 |
|
head.ras_magic = RAS_MAGIC; |
90 |
|
head.ras_width = xmax; |
129 |
|
/* convert image */ |
130 |
|
for (y = ymax-1; y >= 0; y--) { |
131 |
|
for (x = 0; x < xmax; x++) { |
132 |
– |
scanout[x][RED] = getc(stdin); |
133 |
– |
scanout[x][GRN] = getc(stdin); |
132 |
|
scanout[x][BLU] = getc(stdin); |
133 |
+ |
scanout[x][GRN] = getc(stdin); |
134 |
+ |
scanout[x][RED] = getc(stdin); |
135 |
|
} |
136 |
|
if (feof(stdin) || ferror(stdin)) |
137 |
|
quiterr("error reading rasterfile"); |
159 |
|
quiterr("error reading Radiance picture"); |
160 |
|
colrs_gambs(scanin, xmax); |
161 |
|
for (x = 0; x < xmax; x++) { |
162 |
– |
putc(scanin[x][RED], stdout); |
163 |
– |
putc(scanin[x][GRN], stdout); |
162 |
|
putc(scanin[x][BLU], stdout); |
163 |
+ |
putc(scanin[x][GRN], stdout); |
164 |
+ |
putc(scanin[x][RED], stdout); |
165 |
|
} |
166 |
|
if (ferror(stdout)) |
167 |
|
quiterr("error writing rasterfile"); |