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.1 by greg, Thu Mar 1 13:18:22 1990 UTC vs.
Revision 1.2 by greg, Thu Mar 1 18:13:31 1990 UTC

# Line 43 | Line 43 | static char SCCSid[] = "$SunId$ LBL";
43   #define  ourroot        RootWindow(thedisplay,ourscreen)
44   #define  ourgc          DefaultGC(thedisplay,ourscreen)
45  
46 + #define  redraw(x,y,w,h) patch_raster(wind,(x)-xoff,(y)-yoff,x,y,w,h,ourras)
47 +
48   double  gamcor = 2.2;                   /* gamma correction */
49  
50   int  dither = 1;                        /* dither colors? */
# Line 51 | Line 53 | int  fast = 0;                         /* keep picture in Pixmap? */
53   Window  wind = 0;                       /* our output window */
54   Font  fontid;                           /* our font */
55  
56 < long  maxcolors = 0;                    /* maximum colors */
56 > int  maxcolors = 0;                     /* maximum colors */
57   int  greyscale = 0;                     /* in grey */
58  
59   int  scale = 0;                         /* scalefactor; power of two */
# Line 175 | Line 177 | char  *s;
177          static char  *altname[] = {"rview","rpict","pinterp",VIEWSTR,NULL};
178          register char  **an;
179  
180 <        if (!strncmp(s, "EXPOSURE=", 9))
181 <                exposure *= atof(s+9);
180 >        if (isexpos(s))
181 >                exposure *= exposval(s);
182          else
183                  for (an = altname; *an != NULL; an++)
184                          if (!strncmp(*an, s, strlen(*an))) {
185 <                                if (sscanview(&ourview, s+strlen(*an)) == 0)
185 >                                if (sscanview(&ourview, s+strlen(*an)) > 0)
186                                          gotview++;
187                                  return;
188                          }
# Line 206 | Line 208 | init()                 /* get data and open window */
208          if (wind == 0)
209                  quiterr("can't create window");
210          if (maxcolors == 0) {           /* get number of available colors */
211 <                maxcolors = 1<<DisplayPlanes(thedisplay,ourscreen);
211 >                i = DisplayPlanes(thedisplay,ourscreen);
212 >                maxcolors = i > 8 ? 256 : 1<<i;
213                  if (maxcolors > 4) maxcolors -= 2;
214          }
215          fontid = XLoadFont(thedisplay, FONTNAME);
# Line 233 | Line 236 | init()                 /* get data and open window */
236          }
237                                  /* store image */
238          getras();
239 <        XSelectInput(thedisplay, wind, ButtonPressMask|ButtonReleaseMask|
240 <                        StructureNotifyMask|ButtonMotionMask|
241 <                        KeyPressMask|ExposureMask);
239 >        XSelectInput(thedisplay, wind, ButtonPressMask|ButtonReleaseMask
240 >                        |ButtonMotionMask|StructureNotifyMask
241 >                        |KeyPressMask|ExposureMask);
242          XMapWindow(thedisplay, wind);
243          return;
244   memerr:
# Line 359 | Line 362 | getevent()                             /* process the next event */
362   }
363  
364  
362 redraw(x, y, w, h)                      /* redraw section of window */
363 int  x, y;
364 int  w, h;
365 {
366        patch_raster(wind,x-xoff,y-yoff,x,y,w,h,ourras);
367 }
368
369
365   docom(ekey)                                     /* execute command */
366   XKeyPressedEvent  *ekey;
367   {
# Line 419 | Line 414 | XKeyPressedEvent  *ekey;
414                  cvx.red = random() & 65535;
415                  cvx.green = random() & 65535;
416                  cvx.blue = random() & 65535;
417 <                XStoreColors(thedisplay, ourras->cmap, &cvx, 1);
417 >                cvx.flags = DoRed|DoGreen|DoBlue;
418 >                XStoreColor(thedisplay, ourras->cmap, &cvx);
419                  return(0);
420          case 'p':                               /* position */
421                  sprintf(buf, "(%d,%d)", ekey->x-xoff, ymax-1-ekey->y+yoff);
# Line 467 | Line 463 | XKeyPressedEvent  *ekey;
463                  redraw(box.xmin, box.ymin, box.xsiz, box.ysiz);
464                  return(0);
465          default:
466 <                XBell(0);
466 >                XBell(thedisplay, 0);
467                  return(-1);
468          }
469   }
470  
471  
472 < moveimage(ep)                           /* shift the image */
473 < XButtonPressedEvent  *ep;
472 > moveimage(ebut)                         /* shift the image */
473 > XButtonPressedEvent  *ebut;
474   {
475 <        XButtonPressedEvent  eb;
475 >        union {
476 >                XEvent  u;
477 >                XButtonReleasedEvent    b;
478 >        } e;
479  
480 <        XMaskEvent(thedisplay, ButtonReleaseMask, &eb);
481 <        xoff += eb.x - ep->x;
482 <        yoff += eb.y - ep->y;
480 >        XMaskEvent(thedisplay, ButtonReleaseMask, &e.u);
481 >        xoff += e.b.x - ebut->x;
482 >        yoff += e.b.y - ebut->y;
483          XClearWindow(thedisplay, wind);
484          redraw(0, 0, width, height);
486        return(0);
485   }
486  
487  
# Line 491 | Line 489 | getbox(ebut)                           /* get new box */
489   XButtonPressedEvent  *ebut;
490   {
491          union {
492 <                XEvent  e;
492 >                XEvent  u;
493                  XButtonReleasedEvent  b;
494                  XPointerMovedEvent  m;
495          }  e;
496  
497 <        XMaskEvent(thedisplay, ButtonReleaseMask|ButtonMotionMask, &e.e);
498 <        while (e.e.type == ButtonMotionMask) {
497 >        XMaskEvent(thedisplay, ButtonReleaseMask|ButtonMotionMask, &e.u);
498 >        while (e.u.type == MotionNotify) {
499                  revbox(ebut->x, ebut->y, box.xmin = e.m.x, box.ymin = e.m.y);
500 <                XMaskEvent(thedisplay, ButtonReleaseMask|ButtonMotionMask,
503 <                                &e.e);
500 >                XMaskEvent(thedisplay,ButtonReleaseMask|ButtonMotionMask,&e.u);
501                  revbox(ebut->x, ebut->y, box.xmin, box.ymin);
502          }
503          box.xmin = e.b.x<0 ? 0 : (e.b.x>=width ? width-1 : e.b.x);
# Line 527 | Line 524 | int  x0, y0, x1, y1;
524  
525          if (mygc == 0) {
526                  mygc = XCreateGC(thedisplay, wind, 0, 0);
530                XSetPlaneMask(thedisplay, mygc, ~0L);
527                  XSetFunction(thedisplay, mygc, GXinvert);
528          }
529          XDrawLine(thedisplay, wind, mygc, x0, y0, x1, y0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines