| 43 |
|
#define ourroot RootWindow(thedisplay,ourscreen) |
| 44 |
|
#define ourgc DefaultGC(thedisplay,ourscreen) |
| 45 |
|
|
| 46 |
+ |
#define revline(x0,y0,x1,y1) XDrawLine(thedisplay,wind,revgc,x0,y0,x1,y1) |
| 47 |
+ |
|
| 48 |
|
#define redraw(x,y,w,h) patch_raster(wind,(x)-xoff,(y)-yoff,x,y,w,h,ourras) |
| 49 |
|
|
| 50 |
|
double gamcor = 2.2; /* gamma correction */ |
| 77 |
|
|
| 78 |
|
double exposure = 1.0; /* exposure compensation used */ |
| 79 |
|
|
| 80 |
+ |
GC revgc; /* graphics context with GXinvert */ |
| 81 |
+ |
|
| 82 |
|
XRASTER *ourras; /* our stored image */ |
| 83 |
|
unsigned char *ourdata; /* our image data */ |
| 84 |
|
|
| 226 |
|
CWBackPixel|CWBorderPixel, &ourwinattr); |
| 227 |
|
if (wind == 0) |
| 228 |
|
quiterr("can't create window"); |
| 229 |
+ |
width = xmax; |
| 230 |
+ |
height = ymax; |
| 231 |
|
fontid = XLoadFont(thedisplay, FONTNAME); |
| 232 |
|
if (fontid == 0) |
| 233 |
|
quiterr("can't get font"); |
| 234 |
|
XSetFont(thedisplay, ourgc, fontid); |
| 235 |
+ |
revgc = XCreateGC(thedisplay, wind, 0, 0); |
| 236 |
+ |
XSetFunction(thedisplay, revgc, GXinvert); |
| 237 |
|
XStoreName(thedisplay, wind, fname == NULL ? progname : fname); |
| 238 |
|
XDefineCursor(thedisplay, wind, XCreateFontCursor(thedisplay, |
| 239 |
|
XC_diamond_cross)); |
| 493 |
|
XButtonReleasedEvent b; |
| 494 |
|
XPointerMovedEvent m; |
| 495 |
|
} e; |
| 496 |
< |
int nxo, nyo; |
| 496 |
> |
int mxo, myo; |
| 497 |
|
|
| 498 |
|
XMaskEvent(thedisplay, ButtonReleaseMask|ButtonMotionMask, &e.u); |
| 499 |
|
while (e.u.type == MotionNotify) { |
| 500 |
< |
nxo = xoff + e.m.x - ebut->x; |
| 501 |
< |
nyo = yoff + e.m.y - ebut->y; |
| 502 |
< |
revbox(nxo, nyo, nxo+xmax, nyo+ymax); |
| 500 |
> |
mxo = e.m.x; |
| 501 |
> |
myo = e.m.y; |
| 502 |
> |
revline(ebut->x, ebut->y, mxo, myo); |
| 503 |
> |
revbox(xoff+mxo-ebut->x, yoff+myo-ebut->y, |
| 504 |
> |
xoff+mxo-ebut->x+xmax, yoff+myo-ebut->y+ymax); |
| 505 |
|
XMaskEvent(thedisplay,ButtonReleaseMask|ButtonMotionMask,&e.u); |
| 506 |
< |
revbox(nxo, nyo, nxo+xmax, nyo+ymax); |
| 506 |
> |
revline(ebut->x, ebut->y, mxo, myo); |
| 507 |
> |
revbox(xoff+mxo-ebut->x, yoff+myo-ebut->y, |
| 508 |
> |
xoff+mxo-ebut->x+xmax, yoff+myo-ebut->y+ymax); |
| 509 |
|
} |
| 510 |
|
xoff += e.b.x - ebut->x; |
| 511 |
|
yoff += e.b.y - ebut->y; |
| 549 |
|
revbox(x0, y0, x1, y1) /* draw box with reversed lines */ |
| 550 |
|
int x0, y0, x1, y1; |
| 551 |
|
{ |
| 552 |
< |
static GC mygc = 0; |
| 553 |
< |
|
| 554 |
< |
if (mygc == 0) { |
| 555 |
< |
mygc = XCreateGC(thedisplay, wind, 0, 0); |
| 556 |
< |
XSetFunction(thedisplay, mygc, GXinvert); |
| 545 |
< |
} |
| 546 |
< |
XDrawLine(thedisplay, wind, mygc, x0, y0, x1, y0); |
| 547 |
< |
XDrawLine(thedisplay, wind, mygc, x0, y1, x1, y1); |
| 548 |
< |
XDrawLine(thedisplay, wind, mygc, x0, y0, x0, y1); |
| 549 |
< |
XDrawLine(thedisplay, wind, mygc, x1, y0, x1, y1); |
| 550 |
< |
} /* end of revbox */ |
| 552 |
> |
revline(x0, y0, x1, y0); |
| 553 |
> |
revline(x0, y1, x1, y1); |
| 554 |
> |
revline(x0, y0, x0, y1); |
| 555 |
> |
revline(x1, y0, x1, y1); |
| 556 |
> |
} |
| 557 |
|
|
| 558 |
|
|
| 559 |
|
avgbox(clr) /* average color over current box */ |