104 |
|
putchar('\n'); |
105 |
|
fprtresolu(xmax, ymax, stdout); |
106 |
|
/* convert file */ |
107 |
< |
pr2ra(head.ras_type); |
107 |
> |
pr2ra(head.ras_type, head.ras_length/ymax - xmax*3); |
108 |
|
} else { |
109 |
|
/* get header info. */ |
110 |
|
if (checkheader(stdin, COLRFMT, NULL) < 0 || |
112 |
|
quiterr("bad picture format"); |
113 |
|
/* write rasterfile header */ |
114 |
|
head.ras_magic = RAS_MAGIC; |
115 |
< |
head.ras_width = xmax; |
115 |
> |
head.ras_width = xmax + (xmax&1); |
116 |
|
head.ras_height = ymax; |
117 |
|
head.ras_depth = 24; |
118 |
< |
head.ras_length = xmax*ymax*3; |
118 |
> |
head.ras_length = head.ras_width*head.ras_height*3; |
119 |
|
head.ras_maptype = RMT_NONE; |
120 |
|
head.ras_maplength = 0; |
121 |
|
fwrite((char *)&head, sizeof(head), 1, stdout); |
122 |
|
/* convert file */ |
123 |
< |
ra2pr(head.ras_type); |
123 |
> |
ra2pr(head.ras_type, head.ras_length/ymax - xmax*3); |
124 |
|
} |
125 |
|
exit(0); |
126 |
|
userr: |
141 |
|
} |
142 |
|
|
143 |
|
|
144 |
< |
pr2ra(rf) /* convert 24-bit scanlines to Radiance picture */ |
144 |
> |
pr2ra(rf, pad) /* convert 24-bit scanlines to Radiance picture */ |
145 |
|
int rf; |
146 |
+ |
int pad; |
147 |
|
{ |
148 |
|
COLR *scanout; |
149 |
|
register int x; |
166 |
|
scanout[x][GRN] = getc(stdin); |
167 |
|
scanout[x][RED] = getc(stdin); |
168 |
|
} |
169 |
+ |
for (x = pad; x--; getc(stdin)); |
170 |
|
if (feof(stdin) || ferror(stdin)) |
171 |
|
quiterr("error reading rasterfile"); |
172 |
|
gambs_colrs(scanout, xmax); |
180 |
|
} |
181 |
|
|
182 |
|
|
183 |
< |
ra2pr(rf) /* convert Radiance scanlines to 24-bit rasterfile */ |
184 |
< |
int rf; |
183 |
> |
ra2pr(rf, pad) /* convert Radiance scanlines to 24-bit rasterfile */ |
184 |
> |
int rf; |
185 |
> |
int pad; |
186 |
|
{ |
187 |
+ |
int ord[3]; |
188 |
|
COLR *scanin; |
189 |
|
register int x; |
190 |
|
int y; |
192 |
|
scanin = (COLR *)malloc(xmax*sizeof(COLR)); |
193 |
|
if (scanin == NULL) |
194 |
|
quiterr("out of memory in ra2pr"); |
195 |
+ |
if (rf == RT_FORMAT_RGB) { |
196 |
+ |
ord[0] = RED; ord[1] = GRN; ord[2] = BLU; |
197 |
+ |
} else { |
198 |
+ |
ord[0] = BLU; ord[1] = GRN; ord[2] = RED; |
199 |
+ |
} |
200 |
|
/* convert image */ |
201 |
|
for (y = ymax-1; y >= 0; y--) { |
202 |
|
if (freadcolrs(scanin, xmax, stdin) < 0) |
216 |
|
putc(scanin[x][GRN], stdout); |
217 |
|
putc(scanin[x][RED], stdout); |
218 |
|
} |
219 |
+ |
for (x = 0; x < pad; x++) |
220 |
+ |
putc(scanin[xmax-1][ord[x%3]], stdout); |
221 |
|
if (ferror(stdout)) |
222 |
|
quiterr("error writing rasterfile"); |
223 |
|
} |