58 |
|
#define byte(b) putc(b, stdout) |
59 |
|
#define flush() fflush(stdout) |
60 |
|
|
61 |
< |
#define GAMMA 2.0 /* gamma value used in correction */ |
61 |
> |
#define GAMMA 2.5 /* gamma value used in correction */ |
62 |
|
|
63 |
|
#define MINCOLOR 8 /* start of device color table */ |
64 |
|
|
105 |
|
int argc; |
106 |
|
char *argv[]; |
107 |
|
{ |
108 |
< |
int onintr(); |
109 |
< |
double atof(); |
108 |
> |
int onintr(), checkhead(); |
109 |
|
char sbuf[256]; |
110 |
|
register int i; |
111 |
|
|
140 |
|
quitmsg(errmsg); |
141 |
|
} |
142 |
|
/* get header */ |
143 |
< |
while (fgets(sbuf, sizeof(sbuf), fin) != NULL && sbuf[0] != '\n') |
145 |
< |
if (!strncmp(sbuf, "EXPOSURE=", 9)) |
146 |
< |
exposure *= atof(sbuf+9); |
147 |
< |
|
143 |
> |
getheader(fin, checkhead); |
144 |
|
/* get picture dimensions */ |
145 |
< |
if (fgets(sbuf, sizeof(sbuf), fin) == NULL || |
150 |
< |
sscanf(sbuf, "-Y %d +X %d\n", &ymax, &xmax) != 2) |
145 |
> |
if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) |
146 |
|
quitmsg("bad picture size"); |
147 |
|
if (xmax > NCOLS || ymax > NROWS) |
148 |
|
quitmsg("resolution mismatch"); |
166 |
|
} |
167 |
|
|
168 |
|
|
169 |
+ |
checkhead(line) /* deal with line from header */ |
170 |
+ |
char *line; |
171 |
+ |
{ |
172 |
+ |
if (isexpos(line)) |
173 |
+ |
exposure *= exposval(line); |
174 |
+ |
} |
175 |
+ |
|
176 |
+ |
|
177 |
|
init() /* initialize terminal */ |
178 |
|
{ |
179 |
|
struct sgttyb flags; |
396 |
|
int y; |
397 |
|
register rgbpixel *l3; |
398 |
|
{ |
399 |
< |
register BYTE *l4; |
400 |
< |
register int shift, c; |
398 |
< |
int i; |
399 |
< |
|
399 |
> |
register int i; |
400 |
> |
/* read scanline */ |
401 |
|
getscan(y); |
402 |
|
/* convert scanline */ |
403 |
< |
for (l4=scanline[0], i=xmax; i--; l4+=4, l3++) { |
404 |
< |
shift = l4[EXP] - COLXS; |
405 |
< |
if (shift >= 8) { |
406 |
< |
l3->r = l3->g = l3->b = 255; |
407 |
< |
} else if (shift <= -8) { |
407 |
< |
l3->r = l3->g = l3->b = 0; |
408 |
< |
} else if (shift > 0) { |
409 |
< |
c = l4[RED] << shift; |
410 |
< |
l3->r = c > 255 ? 255 : c; |
411 |
< |
c = l4[GRN] << shift; |
412 |
< |
l3->g = c > 255 ? 255 : c; |
413 |
< |
c = l4[BLU] << shift; |
414 |
< |
l3->b = c > 255 ? 255 : c; |
415 |
< |
} else if (shift < 0) { |
416 |
< |
l3->r = l4[RED] >> -shift; |
417 |
< |
l3->g = l4[GRN] >> -shift; |
418 |
< |
l3->b = l4[BLU] >> -shift; |
419 |
< |
} else { |
420 |
< |
l3->r = l4[RED]; |
421 |
< |
l3->g = l4[GRN]; |
422 |
< |
l3->b = l4[BLU]; |
423 |
< |
} |
403 |
> |
normcolrs(scanline, xmax); |
404 |
> |
for (i = 0; i < xmax; i++) { |
405 |
> |
l3[i].r = scanline[i][RED]; |
406 |
> |
l3[i].g = scanline[i][GRN]; |
407 |
> |
l3[i].b = scanline[i][BLU]; |
408 |
|
} |
409 |
|
} |
410 |
|
|