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.23 by greg, Mon May 6 13:14:17 1991 UTC vs.
Revision 2.3 by greg, Mon Dec 23 23:20:09 1991 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1990 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 30 | Line 30 | static char SCCSid[] = "$SunId$ LBL";
30   #include  "pic.h"
31   #include  "x11raster.h"
32   #include  "random.h"
33 + #include  "resolu.h"
34  
35   #define  FONTNAME       "8x13"          /* text font we'll use */
36  
37 < #define  CTRL(c)        ('c'-'@')
37 > #define  CTRL(c)        ((c)-'@')
38  
39   #define  BORWIDTH       5               /* border width */
40  
# Line 70 | Line 71 | int  gotview = 0;                      /* got parameters from file */
71  
72   COLR  *scanline;                        /* scan line buffer */
73  
74 < int  xmax, ymax;                        /* picture resolution */
74 > RESOLU  inpres;                         /* input resolution and ordering */
75 > int  xmax, ymax;                        /* picture dimensions */
76   int  width, height;                     /* window size */
77   char  *fname = NULL;                    /* input file name */
78   FILE  *fin = stdin;                     /* input file */
# Line 103 | Line 105 | extern long  ftell();
105  
106   extern char  *malloc(), *calloc();
107  
108 < extern double  atof(), pow(), log();
108 > extern double  pow(), log();
109  
110   Display  *thedisplay;
111  
# Line 165 | Line 167 | char  *argv[];
167                                  /* get header */
168          getheader(fin, headline, NULL);
169                                  /* get picture dimensions */
170 <        if (wrongformat || fgetresolu(&xmax, &ymax, fin) != (YMAJOR|YDECR))
170 >        if (wrongformat || !fgetsresolu(&inpres, fin))
171                  quiterr("bad picture format");
172 +        xmax = scanlen(&inpres);
173 +        ymax = numscans(&inpres);
174                                  /* set view parameters */
175          if (gotview && setview(&ourview) != NULL)
176                  gotview = 0;
# Line 406 | Line 410 | XKeyPressedEvent  *ekey;
410          XColor  cvx;
411          int  com, n;
412          double  comp;
413 +        FLOAT  hv[2];
414          FVECT  rorg, rdir;
415  
416          n = XLookupString(ekey, buf, sizeof(buf), NULL, NULL);
# Line 414 | Line 419 | XKeyPressedEvent  *ekey;
419          com = buf[0];
420          switch (com) {                  /* interpret command */
421          case 'q':
422 <        case CTRL(D):                           /* quit */
422 >        case CTRL('D'):                         /* quit */
423                  quit(0);
424          case '\n':
425          case '\r':
# Line 454 | Line 459 | XKeyPressedEvent  *ekey;
459                  XStoreColor(thedisplay, ourras->cmap, &cvx);
460                  return(0);
461          case 'p':                               /* position */
462 <                sprintf(buf, "(%d,%d)", ekey->x-xoff, ymax-1-ekey->y+yoff);
462 >                pix2loc(hv, &inpres, ekey->x-xoff, ekey->y-yoff);
463 >                sprintf(buf, "(%d,%d)", (int)(hv[0]*inpres.xr),
464 >                                (int)(hv[1]*inpres.yr));
465                  XDrawImageString(thedisplay, wind, ourgc, ekey->x, ekey->y,
466                                          buf, strlen(buf));
467                  return(0);
# Line 463 | Line 470 | XKeyPressedEvent  *ekey;
470                          XBell(thedisplay, 0);
471                          return(-1);
472                  }
473 <                if (viewray(rorg, rdir, &ourview,
474 <                                (ekey->x-xoff+.5)/xmax,
468 <                                (ymax-1-ekey->y+yoff+.5)/ymax) < 0)
473 >                pix2loc(hv, &inpres, ekey->x-xoff, ekey->y-yoff);
474 >                if (viewray(rorg, rdir, &ourview, hv[0], hv[1]) < 0)
475                          return(-1);
476                  printf("%e %e %e ", rorg[0], rorg[1], rorg[2]);
477                  printf("%e %e %e\n", rdir[0], rdir[1], rdir[2]);
# Line 487 | Line 493 | XKeyPressedEvent  *ekey;
493                  free_raster(ourras);
494                  getras();
495          /* fall through */
496 <        case CTRL(R):                           /* redraw */
497 <        case CTRL(L):
496 >        case CTRL('R'):                         /* redraw */
497 >        case CTRL('L'):
498                  unmap_rcolors(ourras);
499                  XClearWindow(thedisplay, wind);
500                  map_rcolors(ourras, wind);
# Line 580 | Line 586 | int  x0, y0, x1, y1;
586   avgbox(clr)                             /* average color over current box */
587   COLOR  clr;
588   {
589 +        static COLOR  lc;
590 +        static int  ll, lr, lt, lb;
591          int  left, right, top, bottom;
592          int  y;
593          double  d;
# Line 603 | Line 611 | COLOR  clr;
611                  bottom = ymax;
612          if (top >= bottom)
613                  return(-1);
614 +        if (left == ll && right == lr && top == lt && bottom == lb) {
615 +                copycolor(clr, lc);
616 +                return;
617 +        }
618          for (y = top; y < bottom; y++) {
619                  if (getscan(y) == -1)
620                          return(-1);
# Line 613 | Line 625 | COLOR  clr;
625          }
626          d = 1.0/((right-left)*(bottom-top));
627          scalecolor(clr, d);
628 +        ll = left; lr = right; lt = top; lb = bottom;
629 +        copycolor(lc, clr);
630          return(0);
631   }
632  
# Line 668 | Line 682 | COLR  *scan;
682                  } else if (xmax > ymax) {
683                          iconwidth = ICONSIZ;
684                          iconheight = ICONSIZ*ymax/xmax;
685 +                        if (iconheight < 1)
686 +                                iconheight = 1;
687                  } else {
688                          iconwidth = ICONSIZ*xmax/ymax;
689 +                        if (iconwidth < 1)
690 +                                iconwidth = 1;
691                          iconheight = ICONSIZ;
692                  }
693                  ynext = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines