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"; |
10 |
|
|
11 |
|
#include <stdio.h> |
12 |
|
|
13 |
+ |
#ifdef MSDOS |
14 |
+ |
#include <fcntl.h> |
15 |
+ |
#endif |
16 |
+ |
|
17 |
+ |
#include <math.h> |
18 |
+ |
|
19 |
|
#include <ctype.h> |
20 |
|
|
21 |
|
#include "color.h" |
22 |
|
|
23 |
|
#include "resolu.h" |
24 |
|
|
19 |
– |
extern double pow(); |
25 |
|
|
26 |
+ |
extern char *malloc(); |
27 |
+ |
|
28 |
|
int agryscan(), bgryscan(), aclrscan(), bclrscan(); |
29 |
|
|
30 |
|
int bradj = 0; /* brightness adjustment */ |
40 |
|
int argc; |
41 |
|
char *argv[]; |
42 |
|
{ |
43 |
< |
double gamma = 2.2; |
43 |
> |
char inpbuf[2]; |
44 |
> |
double gamcor = 2.2; |
45 |
|
int binflag = 1; |
46 |
|
int reverse = 0; |
47 |
|
int ptype; |
53 |
|
if (argv[i][0] == '-') |
54 |
|
switch (argv[i][1]) { |
55 |
|
case 'g': |
56 |
< |
gamma = atof(argv[++i]); |
56 |
> |
gamcor = atof(argv[++i]); |
57 |
|
break; |
58 |
|
case 'e': |
59 |
|
if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
80 |
|
exit(1); |
81 |
|
} |
82 |
|
if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) { |
83 |
< |
fprintf(stderr, "can't open output \"%s\"\n", |
83 |
> |
fprintf(stderr, "%s: can't open output \"%s\"\n", |
84 |
|
progname, argv[i+1]); |
85 |
|
exit(1); |
86 |
|
} |
87 |
< |
setcolrgam(gamma); |
87 |
> |
setcolrgam(gamcor); |
88 |
|
if (reverse) { |
89 |
|
/* get header */ |
90 |
< |
if (getc(stdin) != 'P') |
90 |
> |
if (read(fileno(stdin), inpbuf, 2) != 2 || inpbuf[0] != 'P') |
91 |
|
quiterr("input not a Poskanzer Pixmap"); |
92 |
< |
ptype = getc(stdin); |
92 |
> |
ptype = inpbuf[1]; |
93 |
> |
#ifdef MSDOS |
94 |
> |
if (ptype > 4) |
95 |
> |
setmode(fileno(stdin), O_BINARY); |
96 |
> |
setmode(fileno(stdout), O_BINARY); |
97 |
> |
#endif |
98 |
|
xmax = scanint(stdin); |
99 |
|
ymax = scanint(stdin); |
100 |
|
maxval = scanint(stdin); |
101 |
|
/* put header */ |
102 |
+ |
newheader("RADIANCE", stdout); |
103 |
|
printargs(i, argv, stdout); |
104 |
|
fputformat(COLRFMT, stdout); |
105 |
|
putchar('\n'); |
122 |
|
quiterr("unsupported Pixmap type"); |
123 |
|
} |
124 |
|
} else { |
125 |
+ |
#ifdef MSDOS |
126 |
+ |
setmode(fileno(stdin), O_BINARY); |
127 |
+ |
if (binflag) |
128 |
+ |
setmode(fileno(stdout), O_BINARY); |
129 |
+ |
#endif |
130 |
|
/* get header info. */ |
131 |
|
if (checkheader(stdin, COLRFMT, NULL) < 0 || |
132 |
|
fgetresolu(&xmax, &ymax, stdin) < 0) |
161 |
|
int (*getscan)(); |
162 |
|
{ |
163 |
|
COLR *scanout; |
145 |
– |
register int x; |
164 |
|
int y; |
165 |
|
/* allocate scanline */ |
166 |
|
scanout = (COLR *)malloc(xmax*sizeof(COLR)); |