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 2.55 by gwlarson, Tue Jul 20 14:07:38 1999 UTC vs.
Revision 2.56 by greg, Sat Feb 22 02:07:28 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1999 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  x11image.c - driver for X-windows
6   *
# Line 27 | Line 24 | static char SCCSid[] = "$SunId$ SGI";
24   #include  <X11/Xutil.h>
25   #include  <X11/Xatom.h>
26  
30 #undef  NOPROTO
31 #define NOPROTO 1
27   #include  "color.h"
28   #include  "tonemap.h"
29   #include  "view.h"
30   #include  "x11raster.h"
31   #include  "random.h"
37 #include  "resolu.h"
32  
33   #define  FONTNAME       "8x13"          /* text font we'll use */
34  
# Line 109 | Line 103 | unsigned char  *ourdata;               /* our image data */
103  
104   struct {
105          int  xmin, ymin, xsiz, ysiz;
106 < }  box = {0, 0, 0, 0};                  /* current box */
106 > }  bbox = {0, 0, 0, 0};                 /* current bbox */
107  
108   char  *geometry = NULL;                 /* geometry specification */
109  
# Line 637 | Line 631 | int  xpos, ypos;
631          COLOR  cval;
632          register char  *cp;
633  
634 <        box.xmin = xpos; box.xsiz = 1;
635 <        box.ymin = ypos; box.ysiz = 1;
634 >        bbox.xmin = xpos; bbox.xsiz = 1;
635 >        bbox.ymin = ypos; bbox.ysiz = 1;
636          avgbox(cval);
637          scalecolor(cval, 1./exposure);
638          pix2loc(hv, &inpres, xpos-xoff, ypos-yoff);
# Line 703 | Line 697 | XKeyPressedEvent  *ekey;
697                          sprintf(buf, "%.3f", intens(cval)/exposure);
698                          break;
699                  case 'l':                               /* luminance */
700 <                        sprintf(buf, "%.0fL", luminance(cval)/exposure);
700 >                        sprintf(buf, "%.1fL", luminance(cval)/exposure);
701                          break;
702                  case 'c':                               /* color */
703                          comp = pow(2.0, (double)scale);
# Line 714 | Line 708 | XKeyPressedEvent  *ekey;
708                          break;
709                  }
710                  XDrawImageString(thedisplay, wind, ourgc,
711 <                                box.xmin, box.ymin+box.ysiz, buf, strlen(buf));
711 >                                bbox.xmin, bbox.ymin+bbox.ysiz, buf, strlen(buf));
712                  return(0);
713          case 'i':                               /* identify (contour) */
714                  if (ourras->pixels == NULL)
# Line 776 | Line 770 | XKeyPressedEvent  *ekey;
770                  sprintf(buf, "%+d", scale);
771          remap:
772                  XDrawImageString(thedisplay, wind, ourgc,
773 <                                box.xmin, box.ymin+box.ysiz, buf, strlen(buf));
773 >                                bbox.xmin, bbox.ymin+bbox.ysiz, buf, strlen(buf));
774                  XFlush(thedisplay);
775 <                free(ourdata);
775 >                /* free(ourdata);       This is done in XDestroyImage()! */
776                  free_raster(ourras);
777                  getras();
778          /* fall through */
# Line 807 | Line 801 | XKeyPressedEvent  *ekey;
801                  redraw(0, 0, width, height);
802                  return(0);
803          case ' ':                               /* clear */
804 <                redraw(box.xmin, box.ymin, box.xsiz, box.ysiz);
804 >                redraw(bbox.xmin, bbox.ymin, bbox.xsiz, bbox.ysiz);
805                  return(0);
806          default:
807                  XBell(thedisplay, 0);
# Line 841 | Line 835 | XButtonPressedEvent  *ebut;
835   }
836  
837  
838 < getbox(ebut)                            /* get new box */
838 > getbox(ebut)                            /* get new bbox */
839   XButtonPressedEvent  *ebut;
840   {
841          XEvent  e;
842  
843          XMaskEvent(thedisplay, ButtonReleaseMask|ButtonMotionMask, &e);
844          while (e.type == MotionNotify) {
845 <                revbox(ebut->x, ebut->y, box.xmin = e.xmotion.x, box.ymin = e.xmotion.y);
845 >                revbox(ebut->x, ebut->y, bbox.xmin = e.xmotion.x, bbox.ymin = e.xmotion.y);
846                  XMaskEvent(thedisplay,ButtonReleaseMask|ButtonMotionMask,&e);
847 <                revbox(ebut->x, ebut->y, box.xmin, box.ymin);
847 >                revbox(ebut->x, ebut->y, bbox.xmin, bbox.ymin);
848          }
849 <        box.xmin = e.xbutton.x<0 ? 0 : (e.xbutton.x>=width ? width-1 : e.xbutton.x);
850 <        box.ymin = e.xbutton.y<0 ? 0 : (e.xbutton.y>=height ? height-1 : e.xbutton.y);
851 <        if (box.xmin > ebut->x) {
852 <                box.xsiz = box.xmin - ebut->x + 1;
853 <                box.xmin = ebut->x;
849 >        bbox.xmin = e.xbutton.x<0 ? 0 : (e.xbutton.x>=width ? width-1 : e.xbutton.x);
850 >        bbox.ymin = e.xbutton.y<0 ? 0 : (e.xbutton.y>=height ? height-1 : e.xbutton.y);
851 >        if (bbox.xmin > ebut->x) {
852 >                bbox.xsiz = bbox.xmin - ebut->x + 1;
853 >                bbox.xmin = ebut->x;
854          } else {
855 <                box.xsiz = ebut->x - box.xmin + 1;
855 >                bbox.xsiz = ebut->x - bbox.xmin + 1;
856          }
857 <        if (box.ymin > ebut->y) {
858 <                box.ysiz = box.ymin - ebut->y + 1;
859 <                box.ymin = ebut->y;
857 >        if (bbox.ymin > ebut->y) {
858 >                bbox.ysiz = bbox.ymin - ebut->y + 1;
859 >                bbox.ymin = ebut->y;
860          } else {
861 <                box.ysiz = ebut->y - box.ymin + 1;
861 >                bbox.ysiz = ebut->y - bbox.ymin + 1;
862          }
863   }
864  
# Line 888 | Line 882 | XButtonPressedEvent  *ebut;
882   }
883  
884  
885 < revbox(x0, y0, x1, y1)                  /* draw box with reversed lines */
885 > revbox(x0, y0, x1, y1)                  /* draw bbox with reversed lines */
886   int  x0, y0, x1, y1;
887   {
888          revline(x0, y0, x1, y0);
# Line 907 | Line 901 | COLOR  cavg;
901          COLOR   col;
902  
903          while (n--) {
904 <                colr_color(col, scn++);
904 >                colr_color(col, *scn++);
905                  addcolor(cavg, col);
906          }
907   }
908  
909  
910   int
911 < avgbox(cavg)                            /* average color over current box */
911 > avgbox(cavg)                            /* average color over current bbox */
912   COLOR   cavg;
913   {
914          double  d;
# Line 931 | Line 925 | COLOR  cavg;
925  
926  
927   int
928 < dobox(f, p)                             /* run function over box */
928 > dobox(f, p)                             /* run function over bbox */
929   int     (*f)();                 /* function to call for each subscan */
930   char    *p;                     /* pointer to private data */
931   {
932          int  left, right, top, bottom;
933          int  y;
934  
935 <        left = box.xmin - xoff;
936 <        right = left + box.xsiz;
935 >        left = bbox.xmin - xoff;
936 >        right = left + bbox.xsiz;
937          if (left < 0)
938                  left = 0;
939          if (right > xmax)
940                  right = xmax;
941          if (left >= right)
942                  return(0);
943 <        top = box.ymin - yoff;
944 <        bottom = top + box.ysiz;
943 >        top = bbox.ymin - yoff;
944 >        bottom = top + bbox.ysiz;
945          if (top < 0)
946                  top = 0;
947          if (bottom > ymax)
# Line 1100 | Line 1094 | getmono()                      /* get monochrome data */
1094                          cerr[x] = err + errp;
1095                  }
1096          }
1097 <        free((char *)cerr);
1097 >        free((void *)cerr);
1098   }
1099  
1100  
# Line 1143 | Line 1137 | COLR  *scan;
1137                  errp = err;
1138                  ti = x*xmax/iconwidth;
1139                  copycolr(clr, scan[ti]);
1140 <                normcolrs(clr, 1, scale);
1140 >                normcolrs(&clr, 1, scale);
1141                  err += normbright(clr) + cerr[x];
1142                  if (err > 127)
1143                          err -= 255;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines