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

Comparing ray/src/common/normcodec.c (file contents):
Revision 2.5 by greg, Thu Nov 7 23:20:28 2019 UTC vs.
Revision 2.7 by greg, Wed Aug 24 19:55:58 2022 UTC

# Line 57 | Line 57 | process_nc_header(NORMCODEC *ncp, int ac, char *av[])
57                  }
58                  return 0;
59          }
60 +                                        /* get resolution string? */
61 +        if (ncp->hdrflags & HF_RESIN && !fgetsresolu(&ncp->res, ncp->finp)) {
62 +                if (ncp->hdrflags & HF_STDERR) {
63 +                        fputs(ncp->inpname, stderr);
64 +                        fputs(": bad resolution string\n", stderr);
65 +                }
66 +                return 0;
67 +        }
68          if (ncp->hdrflags & HF_HEADOUT) {       /* finish header */
69                  if (!(ncp->hdrflags & HF_HEADIN))
70                          newheader("RADIANCE", stdout);
# Line 64 | Line 72 | process_nc_header(NORMCODEC *ncp, int ac, char *av[])
72                          printargs(ac, av, stdout);
73                  if (ncp->hdrflags & HF_ENCODE) {
74                          fputformat(NORMAL32FMT, stdout);
75 <                } else
75 >                } else {
76 >                        fputs("NCOMP=3\n", stdout);
77 >                        if ((ncp->hdrflags & (HF_RESIN|HF_RESOUT)) == HF_RESIN)
78 >                                printf("NCOLS=%d\nNROWS=%d\n",
79 >                                                scanlen(&ncp->res),
80 >                                                numscans(&ncp->res));
81                          switch (ncp->format) {
82                          case 'a':
83                                  fputformat("ascii", stdout);
# Line 78 | Line 91 | process_nc_header(NORMCODEC *ncp, int ac, char *av[])
91                                  fputformat("double", stdout);
92                                  break;
93                          }
94 +                }
95                  fputc('\n', stdout);
96          }
97 <                                        /* get/put resolution string */
84 <        if (ncp->hdrflags & HF_RESIN && !fgetsresolu(&ncp->res, ncp->finp)) {
85 <                if (ncp->hdrflags & HF_STDERR) {
86 <                        fputs(ncp->inpname, stderr);
87 <                        fputs(": bad resolution string\n", stderr);
88 <                }
89 <                return 0;
90 <        }
91 <        if (ncp->hdrflags & HF_RESOUT)
97 >        if (ncp->hdrflags & HF_RESOUT)  /* put resolution string? */
98                  fputsresolu(&ncp->res, stdout);
99  
100 <        ncp->dstart = ncp->curpos = ftell(ncp->finp);
100 >        ncp->dstart = ftell(ncp->finp);
101          return 1;
102   }
103  
# Line 131 | Line 137 | decode_normal_next(FVECT nrm, NORMCODEC *ncp)
137          if (c == EOF && feof(ncp->finp))
138                  return -1;
139  
134        ncp->curpos += 4;
135
140          if (c == lastc) {                       /* optimization */
141                  VCOPY(nrm, lastv);
142          } else {
# Line 150 | Line 154 | decode_normal_next(FVECT nrm, NORMCODEC *ncp)
154   int
155   seek_nc_pix(NORMCODEC *ncp, int x, int y)
156   {
153        long    seekpos;
154
157          if ((ncp->res.xr <= 0) | (ncp->res.yr <= 0)) {
158                  if (ncp->hdrflags & HF_STDERR) {
159                          fputs(progname, stderr);
# Line 167 | Line 169 | seek_nc_pix(NORMCODEC *ncp, int x, int y)
169                  }
170                  return 0;
171          }
172 <        seekpos = ncp->dstart + 4*((long)y*scanlen(&ncp->res) + x);
173 <
172 <        if (seekpos != ncp->curpos &&
173 <                        fseek(ncp->finp, seekpos, SEEK_SET) == EOF) {
172 >        if (fseek(ncp->finp, ncp->dstart + 4*((long)y*scanlen(&ncp->res) + x),
173 >                        SEEK_SET) == EOF) {
174                  if (ncp->hdrflags & HF_STDERR) {
175                          fputs(ncp->inpname, stderr);
176                          fputs(": seek error\n", stderr);
177                  }
178                  return -1;
179          }
180        ncp->curpos = seekpos;
180          return 1;
181   }
182  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines