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.4 by greg, Fri Mar 2 14:58:57 1990 UTC vs.
Revision 1.6 by greg, Mon Mar 12 15:14:53 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  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 */
# Line 75 | Line 77 | int  cury = 0;                         /* current scan location */
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  
# Line 222 | Line 226 | init()                 /* get data and open window */
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));
# Line 485 | Line 493 | XButtonPressedEvent  *ebut;
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;
# Line 537 | Line 549 | XButtonPressedEvent  *ebut;
549   revbox(x0, y0, x1, y1)                  /* draw box with reversed lines */
550   int  x0, y0, x1, y1;
551   {
552 <        static GC       mygc = 0;
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  
542        if (mygc == 0) {
543                mygc = XCreateGC(thedisplay, wind, 0, 0);
544                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 */
558  
552
559   avgbox(clr)                             /* average color over current box */
560   COLOR  clr;
561   {
# Line 595 | Line 601 | getmono()                      /* get monochrome data */
601          register unsigned char  *dp;
602          register int    x, err;
603          int     y;
604 <        rgbpixel        *inline;
604 >        rgbpixel        *inl;
605          short   *cerr;
606  
607 <        if ((inline = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL
607 >        if ((inl = (rgbpixel *)malloc(xmax*sizeof(rgbpixel))) == NULL
608                          || (cerr = (short *)calloc(xmax,sizeof(short))) == NULL)
609                  quit("out of memory in getmono");
610          dp = ourdata - 1;
611          for (y = 0; y < ymax; y++) {
612 <                picreadline3(y, inline);
612 >                picreadline3(y, inl);
613                  err = 0;
614                  for (x = 0; x < xmax; x++) {
615                          if (!(x&7))
616                                  *++dp = 0;
617 <                        err += rgb_bright(&inline[x]) + cerr[x];
617 >                        err += rgb_bright(&inl[x]) + cerr[x];
618                          if (err > 127)
619                                  err -= 255;
620                          else
# Line 616 | Line 622 | getmono()                      /* get monochrome data */
622                          cerr[x] = err >>= 1;
623                  }
624          }
625 <        free((char *)inline);
625 >        free((char *)inl);
626          free((char *)cerr);
627   }
628  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines