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

Comparing ray/src/util/rcode_norm.c (file contents):
Revision 2.2 by greg, Sat Jul 20 02:07:23 2019 UTC vs.
Revision 2.5 by greg, Wed Nov 13 18:17:05 2019 UTC

# Line 38 | Line 38 | encode_normals(NORMCODEC *ncp)
38          long    nexpected = (long)ncp->res.xr * ncp->res.yr;
39  
40          if (ncp->inpfmt[0]) {
41 <                if (strcasestr(ncp->inpfmt, "ascii") != NULL)
41 >                if (strstr(ncp->inpfmt, "ascii") != NULL)
42                          ncp->format = 'a';
43 <                else if (strcasestr(ncp->inpfmt, "float") != NULL)
43 >                else if (strstr(ncp->inpfmt, "float") != NULL)
44                          ncp->format = 'f';
45 <                else if (strcasestr(ncp->inpfmt, "double") != NULL)
45 >                else if (strstr(ncp->inpfmt, "double") != NULL)
46                          ncp->format = 'd';
47                  else {
48                          fputs(ncp->inpname, stderr);
# Line 65 | Line 65 | encode_normals(NORMCODEC *ncp)
65   #ifdef SMLFLT
66                  case 'f':
67                          ok = (getbinary(nrm, sizeof(*nrm), 3, ncp->finp) == 3);
68 +                        if (ncp->swapped)
69 +                                swap32((char *)nrm, 3);
70                          break;
71                  case 'd': {
72 <                                double  nrmd[3];
73 <                                ok = (getbinary(nrmd, sizeof(*nrmd),
74 <                                                3, ncp->finp) == 3);
75 <                                if (ok) VCOPY(nrm, nrmd);
76 <                        }
77 <                        break;
72 >                        double  nrmd[3];
73 >                        ok = (getbinary(nrmd, sizeof(*nrmd),
74 >                                        3, ncp->finp) == 3);
75 >                        if (ncp->swapped)
76 >                                swap64((char *)nrmd, 3);
77 >                        if (ok) VCOPY(nrm, nrmd);
78 >                        } break;
79   #else
80                  case 'f': {
81 <                                float   nrmf[3];
82 <                                ok = (getbinary(nrmf, sizeof(*nrmf),
83 <                                                3, ncp->finp) == 3);
84 <                                if (ok) VCOPY(nrm, nrmf);
85 <                        }
86 <                        break;
81 >                        float   nrmf[3];
82 >                        ok = (getbinary(nrmf, sizeof(*nrmf),
83 >                                        3, ncp->finp) == 3);
84 >                        if (ncp->swapped)
85 >                                swap32((char *)nrmf, 3);
86 >                        if (ok) VCOPY(nrm, nrmf);
87 >                        } break;
88                  case 'd':
89                          ok = (getbinary(nrm, sizeof(*nrm), 3, ncp->finp) == 3);
90 +                        if (ncp->swapped)
91 +                                swap64((char *)nrm, 3);
92                          break;
93   #endif
94                  }
# Line 210 | Line 216 | pixel_normals(NORMCODEC *ncp, int unbuf)
216   int
217   main(int argc, char *argv[])
218   {
219 +        int             xres=0, yres=0;
220          int             reverse = 0;
221          int             bypixel = 0;
222          int             unbuffered = 0;
# Line 271 | Line 278 | main(int argc, char *argv[])
278                                  usage_exit(1);
279                          }
280                          break;
281 +                case 'x':
282 +                        xres = atoi(argv[++a]);
283 +                        break;
284 +                case 'y':
285 +                        yres = atoi(argv[++a]);
286 +                        break;
287                  case 'i':
288                          bypixel++;
289                          break;
# Line 282 | Line 295 | main(int argc, char *argv[])
295                  }
296          nc.hdrflags |= !reverse * HF_ENCODE;
297  
298 <        if ((nc.hdrflags & (HF_RESIN|HF_RESOUT)) == HF_RESOUT) {
298 >        if ((xres > 0) & (yres > 0)) {
299 >                nc.hdrflags &= ~HF_RESIN;
300 >                nc.res.rt = PIXSTANDARD;
301 >                nc.res.xr = xres;
302 >                nc.res.yr = yres;
303 >        } else if ((nc.hdrflags & (HF_RESIN|HF_RESOUT)) == HF_RESOUT) {
304                  fputs(progname, stderr);
305                  fputs(": unknown resolution for output\n", stderr);
306                  return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines