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

Comparing ray/src/px/pvalue.c (file contents):
Revision 2.5 by greg, Mon Sep 21 12:14:37 1992 UTC vs.
Revision 2.8 by greg, Sun Feb 27 10:16:48 1994 UTC

# Line 22 | Line 22 | RESOLU picres;                 /* resolution of picture */
22  
23   int  uniq = 0;                  /* print only unique values? */
24  
25 < int  original = 0;              /* convert back to original values? */
25 > int  doexposure = 0;            /* exposure change? (>100 to print) */
26  
27   int  dataonly = 0;              /* data only format? */
28  
# Line 37 | Line 37 | int  header = 1;               /* do header? */
37  
38   int  resolution = 1;            /* put/get resolution string? */
39  
40 + int  original = 0;              /* convert to original values? */
41 +
42   int  wrongformat = 0;           /* wrong input format? */
43  
44   double  gamcor = 1.0;           /* gamma correction */
# Line 58 | Line 60 | int  argc;
60   char  **argv;
61   {
62          extern int  checkhead();
63 +        double  d, expval = 1.0;
64          int  i;
65  
66          progname = argv[0];
# Line 78 | Line 81 | char  **argv;
81                                  original = argv[i][0] == '-';
82                                  break;
83                          case 'g':               /* gamma correction */
84 <                                gamcor = atof(argv[++i]);
84 >                                gamcor = atof(argv[i+1]);
85                                  if (argv[i][0] == '+')
86                                          gamcor = 1.0/gamcor;
87 +                                i++;
88                                  break;
89 +                        case 'e':               /* exposure correction */
90 +                                d = atof(argv[i+1]);
91 +                                if (argv[i+1][0] == '-' || argv[i+1][0] == '+')
92 +                                        d = pow(2.0, d);
93 +                                if (argv[i][0] == '-')
94 +                                        doexposure = 100;
95 +                                scalecolor(exposure, d);
96 +                                expval *= d;
97 +                                doexposure++;
98 +                                i++;
99 +                                break;
100                          case 'R':               /* reverse byte sequence */
101                                  if (argv[i][0] == '-') {
102                                          ord[0]=BLU; ord[1]=GRN; ord[2]=RED;
# Line 127 | Line 142 | char  **argv;
142                                  }
143                                  break;
144                          case 'x':               /* x resolution */
145 +                        case 'X':               /* x resolution */
146                                  resolution = 0;
147                                  if (argv[i][0] == '-')
148                                          picres.or |= XDECR;
149                                  picres.xr = atoi(argv[++i]);
150                                  break;
151                          case 'y':               /* y resolution */
152 +                        case 'Y':               /* y resolution */
153                                  resolution = 0;
154                                  if (argv[i][0] == '-')
155                                          picres.or |= YDECR;
# Line 182 | Line 199 | unkopt:
199                          setmode(fileno(fin), O_BINARY);
200   #endif
201                                          /* get header */
202 <                if (header && checkheader(fin, fmtid, stdout) < 0) {
203 <                        fprintf(stderr, "%s: wrong input format\n", progname);
204 <                        quit(1);
205 <                }
202 >                if (header) {
203 >                        if (checkheader(fin, fmtid, stdout) < 0) {
204 >                                fprintf(stderr, "%s: wrong input format\n",
205 >                                                progname);
206 >                                quit(1);
207 >                        }
208 >                } else
209 >                        newheader("RADIANCE", stdout);
210                                          /* get resolution */
211                  if ((resolution && !fgetsresolu(&picres, fin)) ||
212                                  picres.xr <= 0 || picres.yr <= 0) {
# Line 194 | Line 215 | unkopt:
215                  }
216                                                  /* add to header */
217                  printargs(i, argv, stdout);
218 +                if (doexposure > 100)
219 +                        fputexpos(expval, stdout);
220                  fputformat(COLRFMT, stdout);
221                  putchar('\n');
222                  fputsresolu(&picres, stdout);   /* always put resolution */
# Line 217 | Line 240 | unkopt:
240                  }
241                  if (header) {
242                          printargs(i, argv, stdout);
243 +                        if (doexposure > 100)
244 +                                fputexpos(expval, stdout);
245                          fputformat(fmtid, stdout);
246                          putchar('\n');
247                  }
# Line 236 | Line 261 | char  *line;
261          double  d;
262          COLOR   ctmp;
263  
264 <        if (isformat(line)) {
240 <                formatval(fmt, line);
264 >        if (formatval(fmt, line))
265                  wrongformat = strcmp(fmt, COLRFMT);
266 <        } else if (original && isexpos(line)) {
266 >        else if (original && isexpos(line)) {
267                  d = 1.0/exposval(line);
268                  scalecolor(exposure, d);
269 +                doexposure++;
270          } else if (original && iscolcor(line)) {
271                  colcorval(ctmp, line);
272                  setcolor(exposure, colval(exposure,RED)/colval(ctmp,RED),
273                                  colval(exposure,GRN)/colval(ctmp,GRN),
274                                  colval(exposure,BLU)/colval(ctmp,BLU));
275 +                doexposure++;
276          } else if (header)
277                  fputs(line, stdout);
278   }
# Line 284 | Line 310 | pixtoval()                             /* convert picture to values */
310                                          continue;
311                                  else
312                                          copycolor(lastc, scanln[x]);
313 <                        if (original)
313 >                        if (doexposure)
314                                  multcolor(scanln[x], exposure);
315                          if (dogamma)
316                                  setcolor(scanln[x],
# Line 332 | Line 358 | valtopix()                     /* convert values to a pixel file */
358                                          pow(colval(scanln[x],RED), gamcor),
359                                          pow(colval(scanln[x],GRN), gamcor),
360                                          pow(colval(scanln[x],BLU), gamcor));
361 +                        if (doexposure)
362 +                                multcolor(scanln[x], exposure);
363                  }
364                  if (fwritescan(scanln, scanlen(&picres), stdout) < 0) {
365                          fprintf(stderr, "%s: write error\n", progname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines