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) { |
150 |
< |
ourview.hresolu = xmax; |
151 |
< |
ourview.vresolu = ymax; |
147 |
> |
if (gotview) |
148 |
|
if (setview(&ourview) != NULL) |
149 |
|
gotview = 0; |
150 |
< |
} |
150 |
> |
|
151 |
|
if ((scanline = (COLR *)malloc(xmax*sizeof(COLR))) == NULL) |
152 |
|
quiterr("out of memory"); |
153 |
|
|
343 |
|
int x, y; |
344 |
|
int w, h; |
345 |
|
{ |
346 |
< |
if (map_rcolors(ourras) == NULL) { |
346 |
> |
if (ourras->ncolors && map_rcolors(ourras) == NULL) { |
347 |
|
fprintf(stderr, "%s: cannot allocate colors\n", progname); |
348 |
|
return(-1); |
349 |
|
} |
415 |
|
if (avgbox(cval) == -1) |
416 |
|
return(-1); |
417 |
|
n = log(.5/bright(cval))/.69315 - scale; /* truncate */ |
418 |
< |
if (n == 0) { |
423 |
< |
XFeep(0); |
418 |
> |
if (n == 0) |
419 |
|
return(0); |
425 |
– |
} |
420 |
|
scale_rcolors(ourras, pow(2.0, (double)n)); |
421 |
|
scale += n; |
422 |
|
sprintf(buf, "%+d", scale); |
427 |
|
getras(); |
428 |
|
/* fall through */ |
429 |
|
case CTRL(R): /* redraw */ |
430 |
+ |
case CTRL(L): |
431 |
|
XClear(wind); |
432 |
|
return(redraw(0, 0, width, height)); |
433 |
|
case ' ': /* clear */ |
687 |
|
} |
688 |
|
|
689 |
|
|
690 |
< |
picreadcm(map) /* do gamcor correction */ |
690 |
> |
picreadcm(map) /* do gamma correction */ |
691 |
|
colormap map; |
692 |
|
{ |
693 |
|
extern double pow(); |