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

Comparing ray/src/px/pinterp.c (file contents):
Revision 1.8 by greg, Wed Jan 3 09:37:16 1990 UTC vs.
Revision 1.9 by greg, Wed Jan 3 12:52:30 1990 UTC

# Line 175 | Line 175 | char   *pfile, *zfile;
175          FILE    *pfp, *zfp;
176          char    *err;
177          COLR    *scanin;
178 <        float   *zin, *zout;
179 <        int     *pout;
180 <        int     xres, yres;
178 >        float   *zin, *zlast;
179 >        int     *plast;
180          int     y;
181                                          /* open input files */
182          if ((pfp = fopen(pfile, "r")) == NULL) {
# Line 192 | Line 191 | char   *pfile, *zfile;
191          printf("%s:\n", pfile);
192          gotview = 0;
193          getheader(pfp, headline);
194 <        if (!gotview || fgetresolu(&xres, &yres, pfp) != (YMAJOR|YDECR)) {
194 >        if (!gotview || fgetresolu(&theirview.hresolu, &theirview.vresolu, pfp)
195 >                        != (YMAJOR|YDECR)) {
196                  fprintf(stderr, "%s: picture view error\n", pfile);
197                  exit(1);
198          }
199        theirview.hresolu = xres;
200        theirview.vresolu = yres;
199          if (err = setview(&theirview)) {
200                  fprintf(stderr, "%s: %s\n", pfile, err);
201                  exit(1);
# Line 205 | Line 203 | char   *pfile, *zfile;
203                                          /* compute transformation */
204          pixform(theirs2ours, &theirview, &ourview);
205                                          /* allocate scanlines */
206 <        scanin = (COLR *)malloc(xres*sizeof(COLR));
207 <        zin = (float *)malloc(xres*sizeof(float));
208 <        zout = (float *)calloc(xres, sizeof(float));
209 <        pout = (int *)calloc(xres, sizeof(int));
210 <        if (scanin == NULL || zin == NULL || zout == NULL || pout == NULL) {
206 >        scanin = (COLR *)malloc(theirview.hresolu*sizeof(COLR));
207 >        zin = (float *)malloc(theirview.hresolu*sizeof(float));
208 >        zlast = (float *)calloc(theirview.hresolu, sizeof(float));
209 >        plast = (int *)calloc(theirview.hresolu, sizeof(int));
210 >        if (scanin == NULL || zin == NULL || zlast == NULL || plast == NULL) {
211                  perror(progname);
212                  exit(1);
213          }
214                                          /* load image */
215 <        for (y = yres-1; y >= 0; y--) {
216 <                if (freadcolrs(scanin, xres, pfp) < 0) {
215 >        for (y = theirview.vresolu-1; y >= 0; y--) {
216 >                if (freadcolrs(scanin, theirview.hresolu, pfp) < 0) {
217                          fprintf(stderr, "%s: read error\n", pfile);
218                          exit(1);
219                  }
220 <                if (fread(zin, sizeof(float), xres, zfp) < xres) {
220 >                if (fread(zin, sizeof(float), theirview.hresolu, zfp)
221 >                                < theirview.hresolu) {
222                          fprintf(stderr, "%s: read error\n", zfile);
223                          exit(1);
224                  }
225 <                addscanline(y, scanin, zin, pout, zout);
225 >                addscanline(y, scanin, zin, plast, zlast);
226          }
227                                          /* clean up */
228          free((char *)scanin);
229          free((char *)zin);
230 <        free((char *)pout);
231 <        free((char *)zout);
230 >        free((char *)plast);
231 >        free((char *)zlast);
232          fclose(pfp);
233          fclose(zfp);
234   }
# Line 275 | Line 274 | addscanline(y, pline, zline, lasty, lastyz)    /* add sca
274   int     y;
275   COLR    *pline;
276   float   *zline;
277 < int     *lasty;
278 < float   *lastyz;
277 > int     *lasty;                 /* input/output */
278 > float   *lastyz;                /* input/output */
279   {
280          extern double   sqrt(), fabs();
281          double  pos[3];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines