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 */ |
127 |
|
} |
128 |
|
break; |
129 |
|
case 'x': /* x resolution */ |
130 |
+ |
case 'X': /* x resolution */ |
131 |
|
resolution = 0; |
132 |
|
if (argv[i][0] == '-') |
133 |
|
picres.or |= XDECR; |
134 |
|
picres.xr = atoi(argv[++i]); |
135 |
|
break; |
136 |
|
case 'y': /* y resolution */ |
137 |
+ |
case 'Y': /* y resolution */ |
138 |
|
resolution = 0; |
139 |
|
if (argv[i][0] == '-') |
140 |
|
picres.or |= YDECR; |
178 |
|
set_io(); |
179 |
|
|
180 |
|
if (reverse) { |
181 |
+ |
#ifdef MSDOS |
182 |
+ |
setmode(fileno(stdout), O_BINARY); |
183 |
+ |
if (format != 'a' && format != 'i') |
184 |
+ |
setmode(fileno(fin), O_BINARY); |
185 |
+ |
#endif |
186 |
|
/* get header */ |
187 |
|
if (header && checkheader(fin, fmtid, stdout) < 0) { |
188 |
|
fprintf(stderr, "%s: wrong input format\n", progname); |
201 |
|
fputsresolu(&picres, stdout); /* always put resolution */ |
202 |
|
valtopix(); |
203 |
|
} else { |
204 |
+ |
#ifdef MSDOS |
205 |
+ |
setmode(fileno(fin), O_BINARY); |
206 |
+ |
if (format != 'a' && format != 'i') |
207 |
+ |
setmode(fileno(stdout), O_BINARY); |
208 |
+ |
#endif |
209 |
|
/* get header */ |
210 |
|
getheader(fin, checkhead, NULL); |
211 |
|
if (wrongformat) { |
256 |
|
|
257 |
|
pixtoval() /* convert picture to values */ |
258 |
|
{ |
259 |
< |
register COLOR *scanln; |
259 |
> |
register COLOR *scanln; |
260 |
|
int dogamma; |
261 |
|
COLOR lastc; |
262 |
|
FLOAT hv[2]; |
311 |
|
valtopix() /* convert values to a pixel file */ |
312 |
|
{ |
313 |
|
int dogamma; |
314 |
< |
register COLOR *scanln; |
314 |
> |
register COLOR *scanln; |
315 |
|
int y; |
316 |
|
register int x; |
317 |
|
|
355 |
|
COLOR col; |
356 |
|
FILE *fp; |
357 |
|
{ |
358 |
< |
double vd[3]; |
358 |
> |
double vd[3]; |
359 |
|
|
360 |
|
if (fscanf(fp, "%lf %lf %lf", &vd[0], &vd[1], &vd[2]) != 3) |
361 |
|
return(-1); |
368 |
|
COLOR col; |
369 |
|
FILE *fp; |
370 |
|
{ |
371 |
< |
double vd[3]; |
371 |
> |
double vd[3]; |
372 |
|
|
373 |
|
if (fread((char *)vd, sizeof(double), 3, fp) != 3) |
374 |
|
return(-1); |
422 |
|
COLOR col; |
423 |
|
FILE *fp; |
424 |
|
{ |
425 |
< |
double vd; |
425 |
> |
double vd; |
426 |
|
|
427 |
|
if (fscanf(fp, "%lf", &vd) != 1) |
428 |
|
return(-1); |
435 |
|
COLOR col; |
436 |
|
FILE *fp; |
437 |
|
{ |
438 |
< |
double vd; |
438 |
> |
double vd; |
439 |
|
|
440 |
|
if (fread((char *)&vd, sizeof(double), 1, fp) != 1) |
441 |
|
return(-1); |
462 |
|
FILE *fp; |
463 |
|
{ |
464 |
|
int vi; |
465 |
< |
double d; |
465 |
> |
double d; |
466 |
|
|
467 |
|
if (fscanf(fp, "%d", &vi) != 1) |
468 |
|
return(-1); |
477 |
|
FILE *fp; |
478 |
|
{ |
479 |
|
BYTE vb; |
480 |
< |
double d; |
480 |
> |
double d; |
481 |
|
|
482 |
|
if (fread((char *)&vb, sizeof(BYTE), 1, fp) != 1) |
483 |
|
return(-1); |
519 |
|
COLOR col; |
520 |
|
FILE *fp; |
521 |
|
{ |
522 |
< |
double vd[3]; |
522 |
> |
double vd[3]; |
523 |
|
|
524 |
|
vd[0] = colval(col,ord[0]); |
525 |
|
vd[1] = colval(col,ord[1]); |
589 |
|
COLOR col; |
590 |
|
FILE *fp; |
591 |
|
{ |
592 |
< |
double vd; |
592 |
> |
double vd; |
593 |
|
|
594 |
|
vd = bright(col); |
595 |
|
fwrite((char *)&vd, sizeof(double), 1, fp); |