ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/x11image.c
(Generate patch)

Comparing ray/src/px/x11image.c (file contents):
Revision 1.2 by greg, Thu Mar 1 18:13:31 1990 UTC vs.
Revision 1.3 by greg, Fri Mar 2 12:22:37 1990 UTC

# Line 137 | Line 137 | char  *argv[];
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 */
# Line 223 | Line 226 | init()                 /* get data and open window */
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 */
# Line 274 | Line 284 | int  code;
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));
# Line 308 | Line 316 | getras()                               /* get raster file */
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;
# Line 402 | Line 405 | XKeyPressedEvent  *ekey;
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)
# Line 443 | Line 446 | XKeyPressedEvent  *ekey;
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);
# Line 473 | Line 476 | moveimage(ebut)                                /* shift the image */
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);
# Line 595 | Line 607 | getmono()                      /* get monochrome data */
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          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines