1 |
< |
/* Copyright (c) 1991 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
16 |
|
|
17 |
|
#include "resolu.h" |
18 |
|
|
19 |
< |
#define min(a,b) ((a)<(b)?(a):(b)) |
19 |
> |
#define min(a,b) ((a)<(b)?(a):(b)) |
20 |
|
|
21 |
< |
RESOLU picres; /* resolution of picture */ |
21 |
> |
RESOLU picres; /* resolution of picture */ |
22 |
|
|
23 |
|
int uniq = 0; /* print only unique values? */ |
24 |
|
|
39 |
|
|
40 |
|
int wrongformat = 0; /* wrong input format? */ |
41 |
|
|
42 |
< |
double gamcor = 1.0; /* gamma correction */ |
42 |
> |
double gamcor = 1.0; /* gamma correction */ |
43 |
|
|
44 |
|
int ord[3] = {RED, GRN, BLU}; /* RGB ordering */ |
45 |
|
int rord[4]; /* reverse ordering */ |
176 |
|
set_io(); |
177 |
|
|
178 |
|
if (reverse) { |
179 |
+ |
#ifdef MSDOS |
180 |
+ |
setmode(fileno(stdout), O_BINARY); |
181 |
+ |
if (format != 'a' && format != 'i') |
182 |
+ |
setmode(fileno(fin), O_BINARY); |
183 |
+ |
#endif |
184 |
|
/* get header */ |
185 |
|
if (header && checkheader(fin, fmtid, stdout) < 0) { |
186 |
|
fprintf(stderr, "%s: wrong input format\n", progname); |
199 |
|
fputsresolu(&picres, stdout); /* always put resolution */ |
200 |
|
valtopix(); |
201 |
|
} else { |
202 |
+ |
#ifdef MSDOS |
203 |
+ |
setmode(fileno(fin), O_BINARY); |
204 |
+ |
if (format != 'a' && format != 'i') |
205 |
+ |
setmode(fileno(stdout), O_BINARY); |
206 |
+ |
#endif |
207 |
|
/* get header */ |
208 |
|
getheader(fin, checkhead, NULL); |
209 |
|
if (wrongformat) { |
254 |
|
|
255 |
|
pixtoval() /* convert picture to values */ |
256 |
|
{ |
257 |
< |
register COLOR *scanln; |
257 |
> |
register COLOR *scanln; |
258 |
|
int dogamma; |
259 |
|
COLOR lastc; |
260 |
|
FLOAT hv[2]; |
309 |
|
valtopix() /* convert values to a pixel file */ |
310 |
|
{ |
311 |
|
int dogamma; |
312 |
< |
register COLOR *scanln; |
312 |
> |
register COLOR *scanln; |
313 |
|
int y; |
314 |
|
register int x; |
315 |
|
|
353 |
|
COLOR col; |
354 |
|
FILE *fp; |
355 |
|
{ |
356 |
< |
double vd[3]; |
356 |
> |
double vd[3]; |
357 |
|
|
358 |
|
if (fscanf(fp, "%lf %lf %lf", &vd[0], &vd[1], &vd[2]) != 3) |
359 |
|
return(-1); |
366 |
|
COLOR col; |
367 |
|
FILE *fp; |
368 |
|
{ |
369 |
< |
double vd[3]; |
369 |
> |
double vd[3]; |
370 |
|
|
371 |
|
if (fread((char *)vd, sizeof(double), 3, fp) != 3) |
372 |
|
return(-1); |
420 |
|
COLOR col; |
421 |
|
FILE *fp; |
422 |
|
{ |
423 |
< |
double vd; |
423 |
> |
double vd; |
424 |
|
|
425 |
|
if (fscanf(fp, "%lf", &vd) != 1) |
426 |
|
return(-1); |
433 |
|
COLOR col; |
434 |
|
FILE *fp; |
435 |
|
{ |
436 |
< |
double vd; |
436 |
> |
double vd; |
437 |
|
|
438 |
|
if (fread((char *)&vd, sizeof(double), 1, fp) != 1) |
439 |
|
return(-1); |
460 |
|
FILE *fp; |
461 |
|
{ |
462 |
|
int vi; |
463 |
< |
double d; |
463 |
> |
double d; |
464 |
|
|
465 |
|
if (fscanf(fp, "%d", &vi) != 1) |
466 |
|
return(-1); |
475 |
|
FILE *fp; |
476 |
|
{ |
477 |
|
BYTE vb; |
478 |
< |
double d; |
478 |
> |
double d; |
479 |
|
|
480 |
|
if (fread((char *)&vb, sizeof(BYTE), 1, fp) != 1) |
481 |
|
return(-1); |
517 |
|
COLOR col; |
518 |
|
FILE *fp; |
519 |
|
{ |
520 |
< |
double vd[3]; |
520 |
> |
double vd[3]; |
521 |
|
|
522 |
|
vd[0] = colval(col,ord[0]); |
523 |
|
vd[1] = colval(col,ord[1]); |
587 |
|
COLOR col; |
588 |
|
FILE *fp; |
589 |
|
{ |
590 |
< |
double vd; |
590 |
> |
double vd; |
591 |
|
|
592 |
|
vd = bright(col); |
593 |
|
fwrite((char *)&vd, sizeof(double), 1, fp); |