7 |
|
* 4/23/86 |
8 |
|
*/ |
9 |
|
|
10 |
– |
#include "standard.h" |
11 |
– |
|
12 |
– |
#include "color.h" |
13 |
– |
|
10 |
|
#include <time.h> |
11 |
|
|
12 |
+ |
#include "standard.h" |
13 |
+ |
#include "platform.h" |
14 |
+ |
#include "color.h" |
15 |
|
#include "resolu.h" |
16 |
|
|
18 |
– |
typedef unsigned short uint16; /* sizeof (uint16) must == 2 */ |
19 |
– |
|
17 |
|
#define min(a,b) ((a)<(b)?(a):(b)) |
18 |
|
|
19 |
|
/* what to put out (also RED, GRN, BLU) */ |
20 |
|
#define ALL 3 |
21 |
|
#define BRIGHT 4 |
22 |
|
|
26 |
– |
#define brightonly (putprim==BRIGHT) |
27 |
– |
|
23 |
|
RESOLU picres; /* resolution of picture */ |
24 |
|
|
25 |
|
int uniq = 0; /* print only unique values? */ |
214 |
|
break; |
215 |
|
/* recognize special formats */ |
216 |
|
if (dataonly && format == 'b') |
217 |
< |
if (brightonly) |
223 |
< |
fmtid = "8-bit_grey"; |
224 |
< |
else |
217 |
> |
if (putprim == ALL) |
218 |
|
fmtid = "24-bit_rgb"; |
226 |
– |
if (dataonly && format == 'w') |
227 |
– |
if (brightonly) |
228 |
– |
fmtid = "16-bit_grey"; |
219 |
|
else |
220 |
+ |
fmtid = "8-bit_grey"; |
221 |
+ |
if (dataonly && format == 'w') |
222 |
+ |
if (putprim == ALL) |
223 |
|
fmtid = "48-bit_rgb"; |
224 |
+ |
else |
225 |
+ |
fmtid = "16-bit_grey"; |
226 |
|
/* assign reverse ordering */ |
227 |
|
rord[ord[0]] = 0; |
228 |
|
rord[ord[1]] = 1; |
236 |
|
progname, argv[i]); |
237 |
|
quit(1); |
238 |
|
} |
239 |
< |
if (reverse && !brightonly && i == argc-3) { |
239 |
> |
if (reverse && putprim != BRIGHT && i == argc-3) { |
240 |
|
if ((fin2 = fopen(argv[i+1], "r")) == NULL) { |
241 |
|
fprintf(stderr, "%s: can't open file \"%s\"\n", |
242 |
|
progname, argv[i+1]); |
250 |
|
interleave = -1; |
251 |
|
} else if (i != argc-1) |
252 |
|
fin = NULL; |
253 |
< |
if (reverse && !brightonly && !interleave) { |
253 |
> |
if (reverse && putprim != BRIGHT && !interleave) { |
254 |
|
fin2 = fopen(argv[i], "r"); |
255 |
|
fin3 = fopen(argv[i], "r"); |
256 |
|
} |
268 |
|
} |
269 |
|
|
270 |
|
if (reverse) { |
271 |
< |
#ifdef MSDOS |
272 |
< |
setmode(fileno(stdout), O_BINARY); |
271 |
> |
#ifdef _WIN32 |
272 |
> |
SET_FILE_BINARY(stdout); |
273 |
|
if (format != 'a' && format != 'i') |
274 |
< |
setmode(fileno(fin), O_BINARY); |
274 |
> |
SET_FILE_BINARY(fin); |
275 |
|
#endif |
276 |
|
/* get header */ |
277 |
|
if (header) { |
316 |
|
fputsresolu(&picres, stdout); /* always put resolution */ |
317 |
|
valtopix(); |
318 |
|
} else { |
319 |
< |
#ifdef MSDOS |
320 |
< |
setmode(fileno(fin), O_BINARY); |
319 |
> |
#ifdef _WIN32 |
320 |
> |
SET_FILE_BINARY(fin); |
321 |
|
if (format != 'a' && format != 'i') |
322 |
< |
setmode(fileno(stdout), O_BINARY); |
322 |
> |
SET_FILE_BINARY(stdout); |
323 |
|
#endif |
324 |
|
/* get header */ |
325 |
|
getheader(fin, checkhead, NULL); |
389 |
|
register COLOR *scanln; |
390 |
|
int dogamma; |
391 |
|
COLOR lastc; |
392 |
< |
FLOAT hv[2]; |
392 |
> |
RREAL hv[2]; |
393 |
|
int startprim, endprim; |
394 |
|
long startpos; |
395 |
|
int y; |