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

Comparing ray/src/px/pinterp.c (file contents):
Revision 2.20 by greg, Mon Dec 26 19:57:22 1994 UTC vs.
Revision 2.21 by greg, Mon Dec 26 21:02:31 1994 UTC

# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20  
21   #include "resolu.h"
22  
23 + #define LOG2            0.69314718055994530942
24 +
25   #define pscan(y)        (ourpict+(y)*hresolu)
26   #define sscan(y)        (ourspict+(y)*hresolu)
27   #define wscan(y)        (ourweigh+(y)*hresolu)
# Line 66 | Line 68 | COLR   backcolr = BLKCOLR;             /* background color */
68   COLOR   backcolor = BLKCOLOR;           /* background color (float) */
69   double  backz = 0.0;                    /* background z value */
70   int     normdist = 1;                   /* normalized distance? */
71 < double  ourexp = -1;                    /* output picture exposure */
71 > double  ourexp = -1;                    /* original picture exposure */
72 > int     expadj = 0;                     /* exposure adjustment (f-stops) */
73 > double  rexpadj = 1;                    /* real exposure adjustment */
74  
75   VIEW    theirview = STDVIEW;            /* input view */
76   int     gotview;                        /* got input view? */
# Line 95 | Line 99 | char   *argv[];
99          int     gotvfile = 0;
100          int     doavg = -1;
101          char    *zfile = NULL;
102 +        char    *expcomp = NULL;
103          char    *err;
104          int     i, rval;
105  
# Line 107 | Line 112 | char   *argv[];
112                          continue;
113                  }
114                  switch (argv[i][1]) {
115 +                case 'e':                               /* exposure */
116 +                        check(2,"f");
117 +                        expcomp = argv[++i];
118 +                        break;
119                  case 't':                               /* threshold */
120                          check(2,"f");
121                          zeps = atof(argv[++i]);
# Line 214 | Line 223 | char   *argv[];
223                  fillo &= ~F_BACK;
224          if (doavg < 0)
225                  doavg = (argc-i) > 2;
226 +        if (expcomp != NULL)
227 +                if (expcomp[0] == '+' | expcomp[0] == '-') {
228 +                        expadj = atof(expcomp) + (expcomp[0]=='+' ? .5 : -.5);
229 +                        if (doavg)
230 +                                rexpadj = pow(2.0, atof(expcomp));
231 +                        else
232 +                                rexpadj = pow(2.0, (double)expadj);
233 +                } else {
234 +                        if (!isflt(expcomp))
235 +                                goto userr;
236 +                        rexpadj = atof(expcomp);
237 +                        expadj = log(rexpadj)/LOG2 + (rexpadj>1 ? .5 : -.5);
238 +                        if (!doavg)
239 +                                rexpadj = pow(2.0, (double)expadj);
240 +                }
241                                                  /* set view */
242          if ((err = setview(&ourview)) != NULL) {
243                  fprintf(stderr, "%s: %s\n", progname, err);
# Line 256 | Line 280 | char   *argv[];
280                  fprintview(&ourview, stdout);
281                  putc('\n', stdout);
282          }
283 <        if (pixaspect < .99 || pixaspect > 1.01)
283 >        if (pixaspect < .99 | pixaspect > 1.01)
284                  fputaspect(pixaspect, stdout);
285 <        if (ourexp > 0 && (ourexp < .995 || ourexp > 1.005))
285 >        if (ourexp > 0)
286 >                ourexp *= rexpadj;
287 >        else
288 >                ourexp = rexpadj;
289 >        if (ourexp < .995 | ourexp > 1.005)
290                  fputexpos(ourexp, stdout);
291          fputformat(COLRFMT, stdout);
292          putc('\n', stdout);
# Line 271 | Line 299 | char   *argv[];
299          exit(0);
300   userr:
301          fprintf(stderr,
302 <        "Usage: %s [view opts][-t eps][-z zout][-fT][-n] pfile zspec ..\n",
302 >        "Usage: %s [view opts][-t eps][-z zout][-e spec][-a|-q][-fT][-n] pfile zspec ..\n",
303                          progname);
304          exit(1);
305   #undef check
# Line 842 | Line 870 | clipaft()                      /* perform aft clipping as indicated */
870   }
871  
872  
873 < writepicture()                          /* write out picture */
873 > writepicture()                          /* write out picture (alters buffer) */
874   {
875          int     y;
876          register int    x;
# Line 852 | Line 880 | writepicture()                         /* write out picture */
880          for (y = vresolu-1; y >= 0; y--)
881                  if (averaging) {
882                          for (x = 0; x < hresolu; x++) { /* average pixels */
883 <                                d = 1./wscan(y)[x];
883 >                                d = rexpadj/wscan(y)[x];
884                                  scalecolor(sscan(y)[x], d);
857                                wscan(y)[x] = 1;
885                          }
886                          if (fwritescan(sscan(y), hresolu, stdout) < 0)
887                                  syserror(progname);
888 <                } else if (fwritecolrs(pscan(y), hresolu, stdout) < 0)
889 <                        syserror(progname);
888 >                } else {
889 >                        if (expadj)
890 >                                shiftcolrs(pscan(y), hresolu, expadj);
891 >                        if (fwritecolrs(pscan(y), hresolu, stdout) < 0)
892 >                                syserror(progname);
893 >                }
894   }
895  
896  
897   writedistance(fname)                    /* write out z file */
898   char    *fname;
899   {
900 <        int     donorm = normdist && ourview.type == VT_PER;
900 >        int     donorm = normdist && ourview.type == VT_PER &&
901 >                        !averaging && hasmatrix;
902          int     fd;
903          int     y;
904          float   *zout;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines