1 |
– |
/* Copyright (c) 1986 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* aedimage.c - RADIANCE driver for AED 512 terminal. |
6 |
|
* |
10 |
|
|
11 |
|
#include <stdio.h> |
12 |
|
|
13 |
+ |
#include <math.h> |
14 |
+ |
|
15 |
|
#include <signal.h> |
16 |
|
|
17 |
|
#include <sys/ioctl.h> |
96 |
|
extern long ftell(); |
97 |
|
long scanpos[NROWS]; |
98 |
|
|
100 |
– |
extern double atof(); |
99 |
|
double exposure = 1.0; |
100 |
+ |
int wrong_fmt = 0; |
101 |
|
|
102 |
|
|
103 |
|
main(argc, argv) |
139 |
|
quitmsg(errmsg); |
140 |
|
} |
141 |
|
/* get header */ |
142 |
< |
getheader(fin, checkhead); |
142 |
> |
getheader(fin, checkhead, NULL); |
143 |
> |
if (wrong_fmt) |
144 |
> |
quitmsg("input must be a Radiance picture"); |
145 |
|
/* get picture dimensions */ |
146 |
< |
if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) |
146 |
> |
if (fgetresolu(&xmax, &ymax, fin) < 0) |
147 |
|
quitmsg("bad picture size"); |
148 |
|
if (xmax > NCOLS || ymax > NROWS) |
149 |
|
quitmsg("resolution mismatch"); |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
+ |
int |
171 |
|
checkhead(line) /* deal with line from header */ |
172 |
|
char *line; |
173 |
|
{ |
174 |
+ |
char fmt[32]; |
175 |
+ |
|
176 |
|
if (isexpos(line)) |
177 |
|
exposure *= exposval(line); |
178 |
+ |
else if (isformat(line)) { |
179 |
+ |
formatval(fmt, line); |
180 |
+ |
wrong_fmt = strcmp(fmt, COLRFMT); |
181 |
+ |
} |
182 |
+ |
return(0); |
183 |
|
} |
184 |
|
|
185 |
|
|
244 |
|
} |
245 |
|
|
246 |
|
|
247 |
+ |
void |
248 |
|
eputs(s) |
249 |
|
char *s; |
250 |
|
{ |
252 |
|
} |
253 |
|
|
254 |
|
|
255 |
+ |
void |
256 |
|
quit(status) |
257 |
|
int status; |
258 |
|
{ |
326 |
|
break; |
327 |
|
case 'l': |
328 |
|
case 'L': |
329 |
< |
printf("%-3gL", bright(cval)*683.0/exposure); |
329 |
> |
printf("%-3gL", luminance(cval)/exposure); |
330 |
|
break; |
331 |
|
case 'c': |
332 |
|
case 'C': |
411 |
|
/* read scanline */ |
412 |
|
getscan(y); |
413 |
|
/* convert scanline */ |
414 |
< |
normcolrs(scanline, xmax); |
414 |
> |
normcolrs(scanline, xmax, 0); |
415 |
|
for (i = 0; i < xmax; i++) { |
416 |
|
l3[i].r = scanline[i][RED]; |
417 |
|
l3[i].g = scanline[i][GRN]; |
522 |
|
picreadcm(map) /* do gamma correction */ |
523 |
|
colormap map; |
524 |
|
{ |
514 |
– |
extern double pow(); |
525 |
|
register int i, val; |
526 |
|
|
527 |
|
for (i = 0; i < 256; i++) { |
528 |
< |
val = pow(i/256.0, 1.0/GAMMA) * 256.0; |
528 |
> |
val = pow((i+0.5)/256.0, 1.0/GAMMA) * 256.0; |
529 |
|
map[0][i] = map[1][i] = map[2][i] = val; |
530 |
|
} |
531 |
|
} |