69 |
|
quiterr("bad raster format"); |
70 |
|
xmax = head.ras_width; |
71 |
|
ymax = head.ras_height; |
72 |
< |
if (head.ras_type != RT_STANDARD || |
73 |
< |
head.ras_maptype != RMT_NONE || |
74 |
< |
head.ras_depth != 24) |
72 |
> |
if ((head.ras_type != RT_STANDARD |
73 |
> |
&& head.ras_type != RT_FORMAT_RGB) |
74 |
> |
|| head.ras_maptype != RMT_NONE |
75 |
> |
|| head.ras_depth != 24) |
76 |
|
quiterr("incompatible format"); |
77 |
|
/* put header */ |
78 |
|
printargs(i, argv, stdout); |
80 |
|
putchar('\n'); |
81 |
|
fputresolu(YMAJOR|YDECR, xmax, ymax, stdout); |
82 |
|
/* convert file */ |
83 |
< |
pr2ra(); |
83 |
> |
pr2ra(head.ras_type); |
84 |
|
} else { |
85 |
|
/* get header info. */ |
86 |
|
if (checkheader(stdin, COLRFMT, NULL) < 0 || |
118 |
|
} |
119 |
|
|
120 |
|
|
121 |
< |
pr2ra() /* convert 24-bit scanlines to Radiance picture */ |
121 |
> |
pr2ra(rf) /* convert 24-bit scanlines to Radiance picture */ |
122 |
> |
int rf; |
123 |
|
{ |
124 |
|
COLR *scanout; |
125 |
|
register int x; |
130 |
|
quiterr("out of memory in pr2ra"); |
131 |
|
/* convert image */ |
132 |
|
for (y = ymax-1; y >= 0; y--) { |
133 |
< |
for (x = 0; x < xmax; x++) { |
134 |
< |
scanout[x][BLU] = getc(stdin); |
135 |
< |
scanout[x][GRN] = getc(stdin); |
136 |
< |
scanout[x][RED] = getc(stdin); |
137 |
< |
} |
133 |
> |
for (x = 0; x < xmax; x++) |
134 |
> |
if (rf == RT_FORMAT_RGB) { |
135 |
> |
scanout[x][RED] = getc(stdin); |
136 |
> |
scanout[x][GRN] = getc(stdin); |
137 |
> |
scanout[x][BLU] = getc(stdin); |
138 |
> |
} else { |
139 |
> |
scanout[x][BLU] = getc(stdin); |
140 |
> |
scanout[x][GRN] = getc(stdin); |
141 |
> |
scanout[x][RED] = getc(stdin); |
142 |
> |
} |
143 |
|
if (feof(stdin) || ferror(stdin)) |
144 |
|
quiterr("error reading rasterfile"); |
145 |
|
gambs_colrs(scanout, xmax); |