23 |
|
|
24 |
|
#include "color.h" |
25 |
|
|
26 |
+ |
#include "resolu.h" |
27 |
+ |
|
28 |
|
#include "xraster.h" |
29 |
|
|
30 |
|
#include "view.h" |
37 |
|
|
38 |
|
#define FONTNAME "9x15" /* text font we'll use */ |
39 |
|
|
40 |
< |
#define CTRL(c) ('c'-'@') |
40 |
> |
#define CTRL(c) ((c)-'@') |
41 |
|
|
42 |
|
#define BORWIDTH 5 /* border width */ |
43 |
|
#define BARHEIGHT 25 /* menu bar size */ |
90 |
|
|
91 |
|
extern char *malloc(), *calloc(); |
92 |
|
|
93 |
< |
extern double atof(), pow(), log(); |
93 |
> |
extern double pow(), log(); |
94 |
|
|
95 |
|
|
96 |
|
main(argc, argv) |
97 |
|
int argc; |
98 |
|
char *argv[]; |
99 |
|
{ |
100 |
+ |
extern char *getenv(); |
101 |
+ |
char *gv; |
102 |
|
int headline(); |
103 |
|
int i; |
104 |
|
|
105 |
|
progname = argv[0]; |
106 |
+ |
if ((gv = getenv("DISPLAY_GAMMA")) != NULL) |
107 |
+ |
gamcor = atof(gv); |
108 |
|
|
109 |
|
for (i = 1; i < argc; i++) |
110 |
|
if (argv[i][0] == '-') |
174 |
|
headline(s) /* get relevant info from header */ |
175 |
|
char *s; |
176 |
|
{ |
171 |
– |
static char *altname[] = {"rview","rpict",VIEWSTR,NULL}; |
172 |
– |
register char **an; |
177 |
|
char fmt[32]; |
178 |
|
|
179 |
|
if (isexpos(s)) |
181 |
|
else if (isformat(s)) { |
182 |
|
formatval(fmt, s); |
183 |
|
wrongformat = strcmp(fmt, COLRFMT); |
184 |
< |
} else |
185 |
< |
for (an = altname; *an != NULL; an++) |
182 |
< |
if (!strncmp(*an, s, strlen(*an))) { |
183 |
< |
if (sscanview(&ourview, s+strlen(*an)) > 0) |
184 |
< |
gotview++; |
185 |
< |
return; |
186 |
< |
} |
184 |
> |
} else if (isview(s) && sscanview(&ourview, s) > 0) |
185 |
> |
gotview++; |
186 |
|
} |
187 |
|
|
188 |
|
|
364 |
|
return(0); |
365 |
|
switch (*cp) { /* interpret command */ |
366 |
|
case 'q': |
367 |
< |
case CTRL(D): /* quit */ |
367 |
> |
case CTRL('D'): /* quit */ |
368 |
|
quit(0); |
369 |
|
case '\n': |
370 |
|
case '\r': |
378 |
|
sprintf(buf, "%.3f", intens(cval)/exposure); |
379 |
|
break; |
380 |
|
case 'l': /* luminance */ |
381 |
< |
sprintf(buf, "%.0fn", luminance(cval)/exposure); |
381 |
> |
sprintf(buf, "%.0fL", luminance(cval)/exposure); |
382 |
|
break; |
383 |
|
case 'c': /* color */ |
384 |
|
comp = pow(2.0, (double)scale); |
434 |
|
free_raster(ourras); |
435 |
|
getras(); |
436 |
|
/* fall through */ |
437 |
< |
case CTRL(R): /* redraw */ |
438 |
< |
case CTRL(L): |
437 |
> |
case CTRL('R'): /* redraw */ |
438 |
> |
case CTRL('L'): |
439 |
|
unmap_rcolors(ourras); |
440 |
|
XClear(wind); |
441 |
|
return(redraw(0, 0, width, height)); |
547 |
|
{ |
548 |
|
register unsigned short *dp; |
549 |
|
register int x, err; |
550 |
< |
int y; |
550 |
> |
int y, errp; |
551 |
|
rgbpixel *inl; |
552 |
|
short *cerr; |
553 |
|
|
561 |
|
for (x = 0; x < xmax; x++) { |
562 |
|
if (!(x&0xf)) |
563 |
|
*++dp = 0; |
564 |
+ |
errp = err; |
565 |
|
err += rgb_bright(&inl[x]) + cerr[x]; |
566 |
|
if (err > 127) |
567 |
|
err -= 255; |
568 |
|
else |
569 |
|
*dp |= 1<<(x&0xf); |
570 |
< |
cerr[x] = err >>= 1; |
570 |
> |
err /= 3; |
571 |
> |
cerr[x] = err + errp; |
572 |
|
} |
573 |
|
} |
574 |
|
free((char *)inl); |
644 |
|
if (fseek(fin, scanpos[y], 0) == -1) |
645 |
|
quiterr("fseek error"); |
646 |
|
cury = y; |
647 |
< |
} else if (scanpos != NULL) |
647 |
> |
} else if (scanpos != NULL && scanpos[y] == -1) |
648 |
|
scanpos[y] = ftell(fin); |
649 |
|
|
650 |
|
if (freadcolrs(scanline, xmax, fin) < 0) |