| 56 |
|
#define redraw(x,y,w,h) patch_raster(wind,(x)-xoff,(y)-yoff,x,y,w,h,ourras) |
| 57 |
|
|
| 58 |
|
double gamcor = 2.2; /* gamma correction */ |
| 59 |
+ |
char *gamstr = NULL; /* gamma value override */ |
| 60 |
|
|
| 61 |
|
int dither = 1; /* dither colors? */ |
| 62 |
|
int fast = 0; /* keep picture in Pixmap? */ |
| 113 |
|
|
| 114 |
|
char errmsg[128]; |
| 115 |
|
|
| 116 |
< |
extern BYTE clrtab[256][3]; /* global color map */ |
| 116 |
> |
BYTE clrtab[256][3]; /* global color map */ |
| 117 |
|
|
| 118 |
|
extern long ftell(); |
| 119 |
|
|
| 120 |
+ |
extern char *getenv(); |
| 121 |
+ |
|
| 122 |
|
Display *thedisplay; |
| 123 |
|
Atom closedownAtom, wmProtocolsAtom; |
| 124 |
|
|
| 131 |
|
int argc; |
| 132 |
|
char *argv[]; |
| 133 |
|
{ |
| 131 |
– |
extern char *getenv(); |
| 132 |
– |
char *gv; |
| 134 |
|
int headline(); |
| 135 |
|
int i; |
| 136 |
|
int pid; |
| 137 |
|
|
| 138 |
|
progname = argv[0]; |
| 138 |
– |
if ((gv = getenv("GAMMA")) != NULL) |
| 139 |
– |
gamcor = atof(gv); |
| 139 |
|
|
| 140 |
|
for (i = 1; i < argc; i++) |
| 141 |
|
if (argv[i][0] == '-') |
| 167 |
|
if (argv[i][2] == 'e') |
| 168 |
|
geometry = argv[++i]; |
| 169 |
|
else |
| 170 |
< |
gamcor = atof(argv[++i]); |
| 170 |
> |
gamstr = argv[++i]; |
| 171 |
|
break; |
| 172 |
|
default: |
| 173 |
|
goto userr; |
| 222 |
|
getevent(); /* main loop */ |
| 223 |
|
userr: |
| 224 |
|
fprintf(stderr, |
| 225 |
< |
"Usage: %s [-di disp][[-ge] spec][-b][-m][-d][-f][-c nclrs][-e +/-stops] pic ..\n", |
| 225 |
> |
"Usage: %s [-di disp][[-ge] spec][-b][-m][-d][-f][-c nclrs][-e +/-stops][-g gamcor] pic ..\n", |
| 226 |
|
progname); |
| 227 |
|
exit(1); |
| 228 |
|
} |
| 272 |
|
name += i+1; |
| 273 |
|
if ((thedisplay = XOpenDisplay(dispname)) == NULL) |
| 274 |
|
quiterr("cannot open display"); |
| 275 |
+ |
/* set gamma value */ |
| 276 |
+ |
if (gamstr == NULL) /* get it from the X server */ |
| 277 |
+ |
gamstr = XGetDefault(thedisplay, "radiance", "gamma"); |
| 278 |
+ |
if (gamstr == NULL) /* get it from the environment */ |
| 279 |
+ |
gamstr = getenv("DISPLAY_GAMMA"); |
| 280 |
+ |
if (gamstr != NULL) |
| 281 |
+ |
gamcor = atof(gamstr); |
| 282 |
|
/* get best visual for default screen */ |
| 283 |
|
getbestvis(); |
| 284 |
|
/* store image */ |
| 366 |
|
if (es = err != NULL) |
| 367 |
|
fprintf(stderr, "%s: %s: %s\n", progname, |
| 368 |
|
fname==NULL?"<stdin>":fname, err); |
| 369 |
< |
if (parent > 0 & wind != 0) { |
| 370 |
< |
XDestroyWindow(thedisplay, wind); |
| 371 |
< |
XFlush(thedisplay); |
| 366 |
< |
} else if (parent < 0 & sigrecv == 0) |
| 369 |
> |
if (thedisplay != NULL) |
| 370 |
> |
XCloseDisplay(thedisplay); |
| 371 |
> |
if (parent < 0 & sigrecv == 0) |
| 372 |
|
kill(getppid(), SIGCONT); |
| 373 |
|
while (parent > 0 && wait(&cs) != -1) { /* wait for any children */ |
| 374 |
|
if (es == 0) |
| 677 |
|
case '@': /* adaptation level */ |
| 678 |
|
if (avgbox(cval) == -1) |
| 679 |
|
return(-1); |
| 680 |
< |
comp = com=='@' |
| 681 |
< |
? 106./pow(1.219+pow(luminance(cval)/exposure,.4),2.5)/exposure |
| 682 |
< |
: .5/bright(cval) ; |
| 680 |
> |
comp = bright(cval); |
| 681 |
> |
if (comp < 1e-20) { |
| 682 |
> |
XBell(thedisplay, 0); |
| 683 |
> |
return(-1); |
| 684 |
> |
} |
| 685 |
> |
if (com == '@') |
| 686 |
> |
comp = 106./exposure/ |
| 687 |
> |
pow(1.219+pow(comp*WHTEFFICACY/exposure,.4),2.5); |
| 688 |
> |
else |
| 689 |
> |
comp = .5/comp; |
| 690 |
|
comp = log(comp)/.69315 - scale; |
| 691 |
|
n = comp < 0 ? comp-.5 : comp+.5 ; /* round */ |
| 692 |
|
if (n == 0) |
| 947 |
|
colrs_gambs(scanline, xmax); |
| 948 |
|
if (ourras->image->blue_mask & 1) |
| 949 |
|
for (x = 0; x < xmax; x++) |
| 950 |
< |
*dp++ = scanline[x][RED] << 16 | |
| 951 |
< |
scanline[x][GRN] << 8 | |
| 952 |
< |
scanline[x][BLU] ; |
| 950 |
> |
*dp++ = (unsigned int4)scanline[x][RED] << 16 | |
| 951 |
> |
(unsigned int4)scanline[x][GRN] << 8 | |
| 952 |
> |
(unsigned int4)scanline[x][BLU] ; |
| 953 |
|
else |
| 954 |
|
for (x = 0; x < xmax; x++) |
| 955 |
< |
*dp++ = scanline[x][RED] | |
| 956 |
< |
scanline[x][GRN] << 8 | |
| 957 |
< |
scanline[x][BLU] << 16 ; |
| 955 |
> |
*dp++ = (unsigned int4)scanline[x][RED] | |
| 956 |
> |
(unsigned int4)scanline[x][GRN] << 8 | |
| 957 |
> |
(unsigned int4)scanline[x][BLU] << 16 ; |
| 958 |
|
} |
| 959 |
|
} |
| 960 |
|
|
| 999 |
|
/* set gamma correction */ |
| 1000 |
|
setcolrgam(gamcor); |
| 1001 |
|
/* make histogram */ |
| 1002 |
< |
new_histo(); |
| 1002 |
> |
if (new_histo((long)xmax*ymax) == -1) |
| 1003 |
> |
quiterr("cannot initialize histogram"); |
| 1004 |
|
for (y = 0; y < ymax; y++) { |
| 1005 |
|
if (getscan(y) < 0) |
| 1006 |
|
break; |