| 137 |
|
default: |
| 138 |
|
goto userr; |
| 139 |
|
} |
| 140 |
+ |
else if (argv[i][0] == '=') |
| 141 |
+ |
geometry = argv[i]; |
| 142 |
|
else |
| 143 |
|
break; |
| 144 |
|
|
| 145 |
< |
if (argc-i == 1) { |
| 145 |
> |
if (i == argc-1) { |
| 146 |
|
fname = argv[i]; |
| 147 |
|
fin = fopen(fname, "r"); |
| 148 |
|
if (fin == NULL) { |
| 149 |
|
sprintf(errmsg, "can't open file \"%s\"", fname); |
| 150 |
|
quiterr(errmsg); |
| 151 |
|
} |
| 152 |
< |
} |
| 152 |
> |
} else if (i != argc) |
| 153 |
> |
goto userr; |
| 154 |
|
/* get header */ |
| 155 |
|
getheader(fin, headline); |
| 156 |
|
/* get picture dimensions */ |
| 226 |
|
bzero((char *)&oursizhints, sizeof(oursizhints)); |
| 227 |
|
i = XParseGeometry(geometry, &oursizhints.x, &oursizhints.y, |
| 228 |
|
&oursizhints.width, &oursizhints.height); |
| 229 |
< |
if (i & (XValue|YValue) == (XValue|YValue)) { |
| 229 |
> |
if ((i&(WidthValue|HeightValue)) == (WidthValue|HeightValue)) |
| 230 |
> |
oursizhints.flags |= USSize; |
| 231 |
> |
else { |
| 232 |
> |
oursizhints.width = xmax; |
| 233 |
> |
oursizhints.height = ymax; |
| 234 |
> |
oursizhints.flags |= PSize; |
| 235 |
> |
} |
| 236 |
> |
if ((i&(XValue|YValue)) == (XValue|YValue)) { |
| 237 |
|
oursizhints.flags |= USPosition; |
| 238 |
|
if (i & XNegative) |
| 239 |
< |
oursizhints.x += DisplayWidth(thedisplay,ourscreen)-1; |
| 239 |
> |
oursizhints.x += DisplayWidth(thedisplay, |
| 240 |
> |
ourscreen)-1-oursizhints.width-2*BORWIDTH; |
| 241 |
|
if (i & YNegative) |
| 242 |
< |
oursizhints.y += DisplayHeight(thedisplay,ourscreen)-1; |
| 242 |
> |
oursizhints.y += DisplayHeight(thedisplay, |
| 243 |
> |
ourscreen)-1-oursizhints.height-2*BORWIDTH; |
| 244 |
|
} |
| 233 |
– |
if (i & (WidthValue|HeightValue) == (WidthValue|HeightValue)) |
| 234 |
– |
oursizhints.flags |= USSize; |
| 245 |
|
XSetNormalHints(thedisplay, wind, &oursizhints); |
| 246 |
|
} |
| 247 |
|
/* store image */ |
| 284 |
|
getras() /* get raster file */ |
| 285 |
|
{ |
| 286 |
|
colormap ourmap; |
| 277 |
– |
unsigned char rmap[256], gmap[256], bmap[256]; |
| 287 |
|
XVisualInfo vinfo; |
| 279 |
– |
register int i; |
| 288 |
|
|
| 289 |
|
if (maxcolors <= 2) { /* monochrome */ |
| 290 |
|
ourdata = (unsigned char *)malloc(ymax*((xmax+7)/8)); |
| 316 |
|
biq(dither,maxcolors,1,ourmap); |
| 317 |
|
else |
| 318 |
|
ciq(dither,maxcolors,1,ourmap); |
| 319 |
< |
for (i = 0; i < 256; i++) { |
| 312 |
< |
rmap[i] = ourmap[0][i]; |
| 313 |
< |
gmap[i] = ourmap[1][i]; |
| 314 |
< |
bmap[i] = ourmap[2][i]; |
| 315 |
< |
} |
| 316 |
< |
if (init_rcolors(ourras, rmap, gmap, bmap) == 0) |
| 319 |
> |
if (init_rcolors(ourras, ourmap[0], ourmap[1], ourmap[2]) == 0) |
| 320 |
|
goto fail; |
| 321 |
|
} |
| 322 |
|
return; |
| 405 |
|
colval(cval,BLU)*comp); |
| 406 |
|
break; |
| 407 |
|
} |
| 408 |
< |
XDrawImageString(thedisplay, wind, ourgc, box.xmin, box.ymin, |
| 409 |
< |
buf, strlen(buf)); |
| 408 |
> |
XDrawImageString(thedisplay, wind, ourgc, |
| 409 |
> |
box.xmin, box.ymin+box.ysiz, buf, strlen(buf)); |
| 410 |
|
return(0); |
| 411 |
|
case 'i': /* identify (contour) */ |
| 412 |
|
if (ourras->pixels == NULL) |
| 446 |
|
scale_rcolors(ourras, pow(2.0, (double)n)); |
| 447 |
|
scale += n; |
| 448 |
|
sprintf(buf, "%+d", scale); |
| 449 |
< |
XDrawImageString(thedisplay, wind, ourgc, box.xmin, box.ymin, |
| 450 |
< |
buf, strlen(buf)); |
| 449 |
> |
XDrawImageString(thedisplay, wind, ourgc, |
| 450 |
> |
box.xmin, box.ymin+box.ysiz, buf, strlen(buf)); |
| 451 |
|
XFlush(thedisplay); |
| 452 |
|
free(ourdata); |
| 453 |
|
free_raster(ourras); |
| 476 |
|
XButtonPressedEvent *ebut; |
| 477 |
|
{ |
| 478 |
|
union { |
| 479 |
< |
XEvent u; |
| 480 |
< |
XButtonReleasedEvent b; |
| 481 |
< |
} e; |
| 479 |
> |
XEvent u; |
| 480 |
> |
XButtonReleasedEvent b; |
| 481 |
> |
XPointerMovedEvent m; |
| 482 |
> |
} e; |
| 483 |
> |
int nxo, nyo; |
| 484 |
|
|
| 485 |
< |
XMaskEvent(thedisplay, ButtonReleaseMask, &e.u); |
| 485 |
> |
XMaskEvent(thedisplay, ButtonReleaseMask|ButtonMotionMask, &e.u); |
| 486 |
> |
while (e.u.type == MotionNotify) { |
| 487 |
> |
nxo = xoff + e.m.x - ebut->x; |
| 488 |
> |
nyo = yoff + e.m.y - ebut->y; |
| 489 |
> |
revbox(nxo, nyo, nxo+xmax, nyo+ymax); |
| 490 |
> |
XMaskEvent(thedisplay,ButtonReleaseMask|ButtonMotionMask,&e.u); |
| 491 |
> |
revbox(nxo, nyo, nxo+xmax, nyo+ymax); |
| 492 |
> |
} |
| 493 |
|
xoff += e.b.x - ebut->x; |
| 494 |
|
yoff += e.b.y - ebut->y; |
| 495 |
|
XClearWindow(thedisplay, wind); |
| 607 |
|
if (err > 127) |
| 608 |
|
err -= 255; |
| 609 |
|
else |
| 610 |
< |
*dp |= 1<<(x&07); |
| 610 |
> |
*dp |= 1<<(7-(x&07)); |
| 611 |
|
cerr[x] = err >>= 1; |
| 612 |
|
} |
| 613 |
|
} |