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? */ |
213 |
|
else |
214 |
|
break; |
215 |
|
/* recognize special formats */ |
216 |
< |
if (dataonly && format == 'b') |
217 |
< |
if (brightonly) |
223 |
< |
fmtid = "8-bit_grey"; |
224 |
< |
else |
216 |
> |
if (dataonly && format == 'b') { |
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 |
+ |
} |
222 |
+ |
if (dataonly && format == 'w') { |
223 |
+ |
if (putprim == ALL) |
224 |
|
fmtid = "48-bit_rgb"; |
225 |
+ |
else |
226 |
+ |
fmtid = "16-bit_grey"; |
227 |
+ |
} |
228 |
|
/* assign reverse ordering */ |
229 |
|
rord[ord[0]] = 0; |
230 |
|
rord[ord[1]] = 1; |
238 |
|
progname, argv[i]); |
239 |
|
quit(1); |
240 |
|
} |
241 |
< |
if (reverse && !brightonly && i == argc-3) { |
241 |
> |
if (reverse && putprim != BRIGHT && i == argc-3) { |
242 |
|
if ((fin2 = fopen(argv[i+1], "r")) == NULL) { |
243 |
|
fprintf(stderr, "%s: can't open file \"%s\"\n", |
244 |
|
progname, argv[i+1]); |
252 |
|
interleave = -1; |
253 |
|
} else if (i != argc-1) |
254 |
|
fin = NULL; |
255 |
< |
if (reverse && !brightonly && !interleave) { |
255 |
> |
if (reverse && putprim != BRIGHT && !interleave) { |
256 |
|
fin2 = fopen(argv[i], "r"); |
257 |
|
fin3 = fopen(argv[i], "r"); |
258 |
|
} |
270 |
|
} |
271 |
|
|
272 |
|
if (reverse) { |
273 |
< |
#ifdef MSDOS |
274 |
< |
setmode(fileno(stdout), O_BINARY); |
273 |
> |
#ifdef _WIN32 |
274 |
> |
SET_FILE_BINARY(stdout); |
275 |
|
if (format != 'a' && format != 'i') |
276 |
< |
setmode(fileno(fin), O_BINARY); |
276 |
> |
SET_FILE_BINARY(fin); |
277 |
|
#endif |
278 |
|
/* get header */ |
279 |
|
if (header) { |
318 |
|
fputsresolu(&picres, stdout); /* always put resolution */ |
319 |
|
valtopix(); |
320 |
|
} else { |
321 |
< |
#ifdef MSDOS |
322 |
< |
setmode(fileno(fin), O_BINARY); |
321 |
> |
#ifdef _WIN32 |
322 |
> |
SET_FILE_BINARY(fin); |
323 |
|
if (format != 'a' && format != 'i') |
324 |
< |
setmode(fileno(stdout), O_BINARY); |
324 |
> |
SET_FILE_BINARY(stdout); |
325 |
|
#endif |
326 |
|
/* get header */ |
327 |
|
getheader(fin, checkhead, NULL); |
391 |
|
register COLOR *scanln; |
392 |
|
int dogamma; |
393 |
|
COLOR lastc; |
394 |
< |
FLOAT hv[2]; |
394 |
> |
RREAL hv[2]; |
395 |
|
int startprim, endprim; |
396 |
|
long startpos; |
397 |
|
int y; |
423 |
|
quit(1); |
424 |
|
} |
425 |
|
for (x = 0; x < scanlen(&picres); x++) { |
426 |
< |
if (uniq) |
426 |
> |
if (uniq) { |
427 |
|
if ( colval(scanln[x],RED) == |
428 |
|
colval(lastc,RED) && |
429 |
|
colval(scanln[x],GRN) == |
433 |
|
continue; |
434 |
|
else |
435 |
|
copycolor(lastc, scanln[x]); |
436 |
+ |
} |
437 |
|
if (doexposure) |
438 |
|
multcolor(scanln[x], exposure); |
439 |
|
if (dogamma) |