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.17 by greg, Mon Jan 8 14:47:15 1990 UTC vs.
Revision 1.21 by greg, Wed Jan 17 15:12:37 1990 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include "standard.h"
12  
13 + #include <sys/fcntl.h>
14 +
15   #include "view.h"
16  
17   #include "color.h"
18  
19 + #ifndef BSD
20 + #define vfork           fork
21 + #endif
22 +
23   #define pscan(y)        (ourpict+(y)*hresolu)
24   #define zscan(y)        (ourzbuf+(y)*hresolu)
25  
# Line 31 | Line 37 | struct position {int x,y; float z;};
37   VIEW    ourview = STDVIEW;              /* desired view */
38   int     hresolu = 512;                  /* horizontal resolution */
39   int     vresolu = 512;                  /* vertical resolution */
40 + double  pixaspect = 1.0;                /* pixel aspect ratio */
41  
42   double  zeps = .02;                     /* allowed z epsilon */
43  
# Line 138 | Line 145 | char   *argv[];
145                          check(2,1);
146                          vresolu = atoi(argv[++i]);
147                          break;
148 +                case 'p':                               /* pixel aspect */
149 +                        check(2,1);
150 +                        pixaspect = atof(argv[++i]);
151 +                        break;
152                  case 'v':                               /* view file */
153                          if (argv[i][2] != 'f')
154                                  goto badopt;
155                          check(3,1);
156 <                        gotvfile = viewfile(argv[++i], &ourview);
156 >                        gotvfile = viewfile(argv[++i], &ourview, 0, 0);
157                          if (gotvfile < 0) {
158                                  perror(argv[i]);
159                                  exit(1);
# Line 167 | Line 178 | char   *argv[];
178                  fprintf(stderr, "%s: %s\n", progname, err);
179                  exit(1);
180          }
181 +        normaspect(viewaspect(&ourview), &pixaspect, &hresolu, &vresolu);
182                                                  /* allocate frame */
183          ourpict = (COLR *)malloc(hresolu*vresolu*sizeof(COLR));
184          ourzbuf = (float *)calloc(hresolu*vresolu,sizeof(float));
# Line 189 | Line 201 | char   *argv[];
201                  fprintview(&ourview, stdout);
202                  printf("\n");
203          }
204 <        if (ourexp > 0 && ourexp != 1.0)
204 >        if (pixaspect < .99 || pixaspect > 1.01)
205 >                fputaspect(pixaspect, stdout);
206 >        if (ourexp > 0 && (ourexp < .995 || ourexp > 1.005))
207                  fputexpos(ourexp, stdout);
208          printf("\n");
209                                                          /* write picture */
# Line 233 | Line 247 | addpicture(pfile, zspec)               /* add picture to output */
247   char    *pfile, *zspec;
248   {
249          extern double   atof();
250 <        FILE    *pfp, *zfp;
250 >        FILE    *pfp;
251 >        int     zfd;
252          char    *err;
253          COLR    *scanin;
254          float   *zin;
# Line 271 | Line 286 | char   *pfile, *zspec;
286          if (scanin == NULL || zin == NULL || plast == NULL)
287                  syserror();
288                                          /* get z specification or file */
289 <        if ((zfp = fopen(zspec, "r")) == NULL) {
289 >        if ((zfd = open(zspec, O_RDONLY)) == -1) {
290                  double  zvalue;
291                  register int    x;
292                  if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0) {
# Line 287 | Line 302 | char   *pfile, *zspec;
302                          fprintf(stderr, "%s: read error\n", pfile);
303                          exit(1);
304                  }
305 <                if (zfp != NULL
306 <                        && fread(zin,sizeof(float),thresolu,zfp) < thresolu) {
305 >                if (zfd != -1 && read(zfd,zin,thresolu*sizeof(float))
306 >                                < thresolu*sizeof(float)) {
307                          fprintf(stderr, "%s: read error\n", zspec);
308                          exit(1);
309                  }
# Line 299 | Line 314 | char   *pfile, *zspec;
314          free((char *)zin);
315          free((char *)plast);
316          fclose(pfp);
317 <        if (zfp != NULL)
318 <                fclose(zfp);
317 >        if (zfd != -1)
318 >                close(zfd);
319   }
320  
321  
# Line 351 | Line 366 | struct position        *lasty;         /* input/output */
366          struct position lastx, newpos;
367          register int    x;
368  
369 +        lastx.z = 0;
370          for (x = thresolu-1; x >= 0; x--) {
371                  pos[0] = (x+.5)/thresolu + theirview.hoff - .5;
372                  pos[1] = (y+.5)/tvresolu + theirview.voff - .5;
# Line 552 | Line 568 | char   *fname;
568   {
569          extern double   sqrt();
570          int     donorm = normdist && ourview.type == VT_PER;
571 <        FILE    *fp;
571 >        int     fd;
572          int     y;
573          float   *zout;
574  
575 <        if ((fp = fopen(fname, "w")) == NULL) {
575 >        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
576                  perror(fname);
577                  exit(1);
578          }
# Line 576 | Line 592 | char   *fname;
592                          }
593                  } else
594                          zout = zscan(y);
595 <                if (fwrite(zout, sizeof(float), hresolu, fp) < hresolu) {
595 >                if (write(fd, zout, hresolu*sizeof(float))
596 >                                < hresolu*sizeof(float)) {
597                          perror(fname);
598                          exit(1);
599                  }
600          }
601          if (donorm)
602                  free((char *)zout);
603 <        fclose(fp);
603 >        close(fd);
604   }
605  
606  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines