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.9 by greg, Thu Oct 6 13:27:16 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 +                                        expval *= d;
95 +                                scalecolor(exposure, d);
96 +                                doexposure++;
97 +                                i++;
98 +                                break;
99                          case 'R':               /* reverse byte sequence */
100                                  if (argv[i][0] == '-') {
101                                          ord[0]=BLU; ord[1]=GRN; ord[2]=RED;
# Line 127 | Line 141 | char  **argv;
141                                  }
142                                  break;
143                          case 'x':               /* x resolution */
144 +                        case 'X':               /* x resolution */
145                                  resolution = 0;
146                                  if (argv[i][0] == '-')
147                                          picres.or |= XDECR;
148                                  picres.xr = atoi(argv[++i]);
149                                  break;
150                          case 'y':               /* y resolution */
151 +                        case 'Y':               /* y resolution */
152                                  resolution = 0;
153                                  if (argv[i][0] == '-')
154                                          picres.or |= YDECR;
# Line 182 | Line 198 | unkopt:
198                          setmode(fileno(fin), O_BINARY);
199   #endif
200                                          /* get header */
201 <                if (header && checkheader(fin, fmtid, stdout) < 0) {
202 <                        fprintf(stderr, "%s: wrong input format\n", progname);
203 <                        quit(1);
204 <                }
201 >                if (header) {
202 >                        if (checkheader(fin, fmtid, stdout) < 0) {
203 >                                fprintf(stderr, "%s: wrong input format\n",
204 >                                                progname);
205 >                                quit(1);
206 >                        }
207 >                } else
208 >                        newheader("RADIANCE", stdout);
209                                          /* get resolution */
210                  if ((resolution && !fgetsresolu(&picres, fin)) ||
211                                  picres.xr <= 0 || picres.yr <= 0) {
# Line 194 | Line 214 | unkopt:
214                  }
215                                                  /* add to header */
216                  printargs(i, argv, stdout);
217 +                if (expval < .99 || expval > 1.01)
218 +                        fputexpos(expval, stdout);
219                  fputformat(COLRFMT, stdout);
220                  putchar('\n');
221                  fputsresolu(&picres, stdout);   /* always put resolution */
# Line 217 | Line 239 | unkopt:
239                  }
240                  if (header) {
241                          printargs(i, argv, stdout);
242 +                        if (expval < .99 || expval > 1.01)
243 +                                fputexpos(expval, stdout);
244                          fputformat(fmtid, stdout);
245                          putchar('\n');
246                  }
# Line 236 | Line 260 | char  *line;
260          double  d;
261          COLOR   ctmp;
262  
263 <        if (isformat(line)) {
240 <                formatval(fmt, line);
263 >        if (formatval(fmt, line))
264                  wrongformat = strcmp(fmt, COLRFMT);
265 <        } else if (original && isexpos(line)) {
265 >        else if (original && isexpos(line)) {
266                  d = 1.0/exposval(line);
267                  scalecolor(exposure, d);
268 +                doexposure++;
269          } else if (original && iscolcor(line)) {
270                  colcorval(ctmp, line);
271                  setcolor(exposure, colval(exposure,RED)/colval(ctmp,RED),
272                                  colval(exposure,GRN)/colval(ctmp,GRN),
273                                  colval(exposure,BLU)/colval(ctmp,BLU));
274 +                doexposure++;
275          } else if (header)
276                  fputs(line, stdout);
277   }
# Line 284 | Line 309 | pixtoval()                             /* convert picture to values */
309                                          continue;
310                                  else
311                                          copycolor(lastc, scanln[x]);
312 <                        if (original)
312 >                        if (doexposure)
313                                  multcolor(scanln[x], exposure);
314                          if (dogamma)
315                                  setcolor(scanln[x],
# Line 332 | Line 357 | valtopix()                     /* convert values to a pixel file */
357                                          pow(colval(scanln[x],RED), gamcor),
358                                          pow(colval(scanln[x],GRN), gamcor),
359                                          pow(colval(scanln[x],BLU), gamcor));
360 +                        if (doexposure)
361 +                                multcolor(scanln[x], exposure);
362                  }
363                  if (fwritescan(scanln, scanlen(&picres), stdout) < 0) {
364                          fprintf(stderr, "%s: write error\n", progname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines