| 38 |
|
#define BORWIDTH 5 /* border width */ |
| 39 |
|
#define BARHEIGHT 25 /* menu bar size */ |
| 40 |
|
|
| 41 |
< |
double gamcor = 2.0; /* gamma correction */ |
| 41 |
> |
double gamcor = 2.2; /* gamma correction */ |
| 42 |
|
|
| 43 |
|
XRASTER *ourras = NULL; /* our stored raster image */ |
| 44 |
|
|
| 137 |
|
sprintf(errmsg, "can't open file \"%s\"", fname); |
| 138 |
|
quiterr(errmsg); |
| 139 |
|
} |
| 140 |
< |
} else |
| 141 |
< |
goto userr; |
| 142 |
< |
|
| 140 |
> |
} |
| 141 |
|
/* get header */ |
| 142 |
|
getheader(fin, headline); |
| 143 |
|
/* get picture dimensions */ |
| 144 |
< |
if (fscanf(fin, "-Y %d +X %d\n", &ymax, &xmax) != 2) |
| 144 |
> |
if (fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR)) |
| 145 |
|
quiterr("bad picture size"); |
| 146 |
|
/* set view parameters */ |
| 147 |
|
if (gotview) { |
| 345 |
|
int x, y; |
| 346 |
|
int w, h; |
| 347 |
|
{ |
| 348 |
< |
if (map_rcolors(ourras) == NULL) { |
| 348 |
> |
if (ourras->ncolors && map_rcolors(ourras) == NULL) { |
| 349 |
|
fprintf(stderr, "%s: cannot allocate colors\n", progname); |
| 350 |
|
return(-1); |
| 351 |
|
} |
| 417 |
|
if (avgbox(cval) == -1) |
| 418 |
|
return(-1); |
| 419 |
|
n = log(.5/bright(cval))/.69315 - scale; /* truncate */ |
| 420 |
< |
if (n == 0) { |
| 423 |
< |
XFeep(0); |
| 420 |
> |
if (n == 0) |
| 421 |
|
return(0); |
| 425 |
– |
} |
| 422 |
|
scale_rcolors(ourras, pow(2.0, (double)n)); |
| 423 |
|
scale += n; |
| 424 |
|
sprintf(buf, "%+d", scale); |
| 429 |
|
getras(); |
| 430 |
|
/* fall through */ |
| 431 |
|
case CTRL(R): /* redraw */ |
| 432 |
+ |
case CTRL(L): |
| 433 |
|
XClear(wind); |
| 434 |
|
return(redraw(0, 0, width, height)); |
| 435 |
|
case ' ': /* clear */ |
| 648 |
|
int y; |
| 649 |
|
register rgbpixel *l3; |
| 650 |
|
{ |
| 651 |
< |
register BYTE *l4; |
| 652 |
< |
register int shift, c; |
| 656 |
< |
int i; |
| 657 |
< |
|
| 651 |
> |
register int i; |
| 652 |
> |
/* read scanline */ |
| 653 |
|
if (getscan(y) < 0) |
| 654 |
|
quiterr("cannot seek for picreadline"); |
| 655 |
|
/* convert scanline */ |
| 656 |
< |
for (l4=scanline[0], i=xmax; i--; l4+=4, l3++) { |
| 657 |
< |
shift = l4[EXP] - COLXS + scale; |
| 658 |
< |
if (shift >= 8) { |
| 659 |
< |
l3->r = l3->g = l3->b = 255; |
| 660 |
< |
} else if (shift <= -8) { |
| 666 |
< |
l3->r = l3->g = l3->b = 0; |
| 667 |
< |
} else if (shift > 0) { |
| 668 |
< |
c = l4[RED] << shift; |
| 669 |
< |
l3->r = c > 255 ? 255 : c; |
| 670 |
< |
c = l4[GRN] << shift; |
| 671 |
< |
l3->g = c > 255 ? 255 : c; |
| 672 |
< |
c = l4[BLU] << shift; |
| 673 |
< |
l3->b = c > 255 ? 255 : c; |
| 674 |
< |
} else if (shift < 0) { |
| 675 |
< |
l3->r = l4[RED] >> -shift; |
| 676 |
< |
l3->g = l4[GRN] >> -shift; |
| 677 |
< |
l3->b = l4[BLU] >> -shift; |
| 678 |
< |
} else { |
| 679 |
< |
l3->r = l4[RED]; |
| 680 |
< |
l3->g = l4[GRN]; |
| 681 |
< |
l3->b = l4[BLU]; |
| 682 |
< |
} |
| 656 |
> |
normcolrs(scanline, xmax); |
| 657 |
> |
for (i = 0; i < xmax; i++) { |
| 658 |
> |
l3[i].r = scanline[i][RED]; |
| 659 |
> |
l3[i].g = scanline[i][GRN]; |
| 660 |
> |
l3[i].b = scanline[i][BLU]; |
| 661 |
|
} |
| 662 |
|
} |
| 663 |
|
|
| 670 |
|
} |
| 671 |
|
|
| 672 |
|
|
| 673 |
< |
picreadcm(map) /* do gamcor correction */ |
| 673 |
> |
picreadcm(map) /* do gamma correction */ |
| 674 |
|
colormap map; |
| 675 |
|
{ |
| 676 |
|
extern double pow(); |