| 1 |
< |
/* Copyright (c) 1993 Regents of the University of California */ |
| 1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
| 74 |
|
int yoff = 0; /* y image offset */ |
| 75 |
|
|
| 76 |
|
int parent = 0; /* number of children, -1 if child */ |
| 77 |
+ |
int sequential = 0; /* display images in sequence */ |
| 78 |
|
|
| 79 |
|
VIEW ourview = STDVIEW; /* image view parameters */ |
| 80 |
|
int gotview = 0; /* got parameters from file */ |
| 114 |
|
|
| 115 |
|
char errmsg[128]; |
| 116 |
|
|
| 117 |
< |
extern BYTE clrtab[256][3]; /* global color map */ |
| 117 |
> |
BYTE clrtab[256][3]; /* global color map */ |
| 118 |
|
|
| 119 |
|
extern long ftell(); |
| 120 |
|
|
| 148 |
|
greyscale = !greyscale; |
| 149 |
|
break; |
| 150 |
|
case 'm': |
| 151 |
+ |
greyscale = 1; |
| 152 |
|
maxcolors = 2; |
| 153 |
|
break; |
| 154 |
|
case 'd': |
| 160 |
|
case 'f': |
| 161 |
|
fast = !fast; |
| 162 |
|
break; |
| 163 |
+ |
case 's': |
| 164 |
+ |
sequential = !sequential; |
| 165 |
+ |
break; |
| 166 |
|
case 'e': |
| 167 |
|
if (argv[i+1][0] != '+' && argv[i+1][0] != '-') |
| 168 |
|
goto userr; |
| 219 |
|
|
| 220 |
|
init(argc, argv); /* get file and open window */ |
| 221 |
|
|
| 217 |
– |
if (parent < 0) { |
| 218 |
– |
kill(getppid(), SIGCONT); /* signal parent if child */ |
| 219 |
– |
sigrecv--; |
| 220 |
– |
} |
| 222 |
|
for ( ; ; ) |
| 223 |
|
getevent(); /* main loop */ |
| 224 |
|
userr: |
| 225 |
|
fprintf(stderr, |
| 226 |
< |
"Usage: %s [-di disp][[-ge] spec][-b][-m][-d][-f][-c nclrs][-e +/-stops][-g gamcor] pic ..\n", |
| 226 |
> |
"Usage: %s [-di disp][[-ge] spec][-b][-m][-d][-f][-c nclrs][-e +/-stops][-g gamcor][-s] pic ..\n", |
| 227 |
|
progname); |
| 228 |
|
exit(1); |
| 229 |
|
} |
| 277 |
|
if (gamstr == NULL) /* get it from the X server */ |
| 278 |
|
gamstr = XGetDefault(thedisplay, "radiance", "gamma"); |
| 279 |
|
if (gamstr == NULL) /* get it from the environment */ |
| 280 |
< |
gamstr = getenv("GAMMA"); |
| 280 |
> |
gamstr = getenv("DISPLAY_GAMMA"); |
| 281 |
|
if (gamstr != NULL) |
| 282 |
|
gamcor = atof(gamstr); |
| 283 |
|
/* get best visual for default screen */ |
| 306 |
|
} |
| 307 |
|
} |
| 308 |
|
/* open window */ |
| 309 |
+ |
i = CWEventMask|CWCursor|CWBackPixel|CWBorderPixel; |
| 310 |
|
ourwinattr.border_pixel = ourwhite; |
| 311 |
|
ourwinattr.background_pixel = ourblack; |
| 312 |
< |
ourwinattr.colormap = XCreateColormap(thedisplay, ourroot, |
| 313 |
< |
ourvis.visual, AllocNone); |
| 312 |
> |
if (ourvis.visual != DefaultVisual(thedisplay,ourscreen)) { |
| 313 |
> |
ourwinattr.colormap = newcmap(thedisplay, ourscreen, ourvis.visual); |
| 314 |
> |
i |= CWColormap; |
| 315 |
> |
} |
| 316 |
|
ourwinattr.event_mask = ExposureMask|KeyPressMask|ButtonPressMask| |
| 317 |
|
ButtonReleaseMask|ButtonMotionMask|StructureNotifyMask; |
| 318 |
|
ourwinattr.cursor = XCreateFontCursor(thedisplay, XC_diamond_cross); |
| 319 |
|
wind = XCreateWindow(thedisplay, ourroot, xszhints.x, xszhints.y, |
| 320 |
|
xszhints.width, xszhints.height, BORWIDTH, |
| 321 |
< |
ourvis.depth, InputOutput, ourvis.visual, CWEventMask| |
| 322 |
< |
CWCursor|CWBackPixel|CWBorderPixel|CWColormap, &ourwinattr); |
| 321 |
> |
ourvis.depth, InputOutput, ourvis.visual, |
| 322 |
> |
i, &ourwinattr); |
| 323 |
|
if (wind == 0) |
| 324 |
|
quiterr("cannot create window"); |
| 325 |
|
width = xmax; |
| 357 |
|
XSetWMProtocols(thedisplay, wind, &closedownAtom, 1); |
| 358 |
|
|
| 359 |
|
XMapWindow(thedisplay, wind); |
| 356 |
– |
return; |
| 360 |
|
} /* end of init */ |
| 361 |
|
|
| 362 |
|
|
| 369 |
|
if (es = err != NULL) |
| 370 |
|
fprintf(stderr, "%s: %s: %s\n", progname, |
| 371 |
|
fname==NULL?"<stdin>":fname, err); |
| 372 |
< |
if (parent > 0 & wind != 0) { |
| 373 |
< |
XDestroyWindow(thedisplay, wind); |
| 374 |
< |
XFlush(thedisplay); |
| 372 |
< |
} else if (parent < 0 & sigrecv == 0) |
| 372 |
> |
if (thedisplay != NULL) |
| 373 |
> |
XCloseDisplay(thedisplay); |
| 374 |
> |
if (parent < 0 & sigrecv == 0) |
| 375 |
|
kill(getppid(), SIGCONT); |
| 376 |
|
while (parent > 0 && wait(&cs) != -1) { /* wait for any children */ |
| 377 |
|
if (es == 0) |
| 565 |
|
map_rcolors(ourras, wind); |
| 566 |
|
if (fast) |
| 567 |
|
make_rpixmap(ourras, wind); |
| 568 |
+ |
if (!sequential & parent < 0 & sigrecv == 0) { |
| 569 |
+ |
kill(getppid(), SIGCONT); |
| 570 |
+ |
sigrecv--; |
| 571 |
+ |
} |
| 572 |
|
break; |
| 573 |
|
case UnmapNotify: |
| 574 |
|
if (!fast) |
| 1006 |
|
/* set gamma correction */ |
| 1007 |
|
setcolrgam(gamcor); |
| 1008 |
|
/* make histogram */ |
| 1009 |
< |
new_histo(); |
| 1009 |
> |
if (new_histo((long)xmax*ymax) == -1) |
| 1010 |
> |
quiterr("cannot initialize histogram"); |
| 1011 |
|
for (y = 0; y < ymax; y++) { |
| 1012 |
|
if (getscan(y) < 0) |
| 1013 |
|
break; |