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 1.5 by greg, Fri Dec 14 16:33:19 1990 UTC vs.
Revision 1.6 by greg, Fri Apr 19 09:00:55 1991 UTC

# Line 19 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19   int  xres = 0;                  /* resolution of input */
20   int  yres = 0;
21  
22 < int  uniq = 0;                  /* unique values? */
22 > int  uniq = 0;                  /* print only unique values? */
23  
24 < int  original = 0;              /* original values? */
24 > int  original = 0;              /* convert back to original values? */
25  
26   int  dataonly = 0;              /* data only format? */
27  
# Line 30 | Line 30 | int  brightonly = 0;           /* only brightness values? */
30   int  reverse = 0;               /* reverse conversion? */
31  
32   int  format = 'a';              /* input/output format */
33 + char  *fmtid = "ascii";         /* format identifier for header */
34  
35   int  header = 1;                /* do header */
36  
37 + int  wrongformat = 0;           /* wrong input format? */
38 +
39   COLOR  exposure = WHTCOLOR;
40  
41   char  *progname;
# Line 76 | Line 79 | char  **argv;
79                                  case '\0':
80                                  case 'a':               /* ascii */
81                                          format = 'a';
82 +                                        fmtid = "ascii";
83                                          break;
84                                  case 'i':               /* integer */
85 +                                        format = 'i';
86 +                                        fmtid = "ascii";
87 +                                        break;
88                                  case 'b':               /* byte */
89 +                                        format = 'b';
90 +                                        fmtid = "byte";
91 +                                        break;
92                                  case 'f':               /* float */
93 +                                        format = 'f';
94 +                                        fmtid = "float";
95 +                                        break;
96                                  case 'd':               /* double */
97 <                                        format = argv[i][2];
97 >                                        format = 'd';
98 >                                        fmtid = "double";
99                                          break;
100                                  default:
101                                          goto unkopt;
# Line 102 | Line 116 | unkopt:
116                          }
117                  else
118                          break;
119 <                        
119 >                                        /* recognize special formats */
120 >        if (dataonly && format == 'b')
121 >                if (brightonly)
122 >                        fmtid = "8-bit_grey";
123 >                else
124 >                        fmtid = "24-bit_rgb";
125 >
126          if (i == argc) {
127                  fin = stdin;
128          } else if (i == argc-1) {
# Line 119 | Line 139 | unkopt:
139          set_io();
140  
141          if (reverse) {
122                if (header)                     /* get header */
123                        copyheader(fin, stdout);
124                                                /* add to header */
125                printargs(i, argv, stdout);
126                printf("\n");
142                  if (yres <= 0 || xres <= 0) {
143                          fprintf(stderr, "%s: missing x and y resolution\n",
144                                          progname);
145                          quit(1);
146                  }
147 +                                        /* get header */
148 +                if (header && checkheader(fin, fmtid, stdout) < 0) {
149 +                        fprintf(stderr, "%s: wrong input format\n", progname);
150 +                        quit(1);
151 +                }
152 +                                                /* add to header */
153 +                printargs(i, argv, stdout);
154 +                fputformat(COLRFMT, stdout);
155 +                printf("\n");
156                  fputresolu(YMAJOR|YDECR, xres, yres, stdout);
157                  valtopix();
158          } else {
159                                                  /* get header */
160 <                getheader(fin, checkhead);
160 >                getheader(fin, checkhead, NULL);
161 >                if (wrongformat) {
162 >                        fprintf(stderr, "%s: input not a Radiance picture\n",
163 >                                        progname);
164 >                        quit(1);
165 >                }
166  
167                  if (xres <= 0 || yres <= 0)             /* get picture size */
168                          if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) {
# Line 144 | Line 173 | unkopt:
173                          }
174                  if (header) {
175                          printargs(i, argv, stdout);
176 +                        fputformat(fmtid, stdout);
177                          printf("\n");
178                  }
179                  pixtoval();
# Line 156 | Line 186 | unkopt:
186   checkhead(line)                         /* deal with line from header */
187   char  *line;
188   {
189 +        char    fmt[32];
190          double  d;
191          COLOR   ctmp;
192  
193 <        if (header)
194 <                fputs(line, stdout);
195 <        if (isexpos(line)) {
193 >        if (isformat(line)) {
194 >                formatval(fmt, line);
195 >                wrongformat = strcmp(fmt, COLRFMT);
196 >        } else if (original && isexpos(line)) {
197                  d = 1.0/exposval(line);
198                  scalecolor(exposure, d);
199 <        } else if (iscolcor(line)) {
199 >        } else if (original && iscolcor(line)) {
200                  colcorval(ctmp, line);
201                  colval(exposure,RED) /= colval(ctmp,RED);
202                  colval(exposure,GRN) /= colval(ctmp,GRN);
203                  colval(exposure,BLU) /= colval(ctmp,BLU);
204 <        }
204 >        } else if (header)
205 >                fputs(line, stdout);
206   }
207  
208  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines