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

Comparing ray/src/px/protate.c (file contents):
Revision 1.2 by greg, Tue Sep 12 13:04:27 1989 UTC vs.
Revision 1.6 by greg, Tue Jul 3 08:45:48 1990 UTC

# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ LBL";
14   #include "color.h"
15  
16   int     xres, yres;                     /* input resolution */
17 + double  inpaspect = 1.0;                /* input aspect ratio */
18  
19   char    buf[1<<20];                     /* output buffer */
20  
# Line 24 | Line 25 | int    nrows;                          /* number of rows output at once */
25   char    *progname;
26  
27  
28 + headline(s)                             /* process line from header */
29 + char    *s;
30 + {
31 +        fputs(s, stdout);
32 +        if (isaspect(s))
33 +                inpaspect *= aspectval(s);
34 + }
35 +
36 +
37   main(argc, argv)
38   int     argc;
39   char    *argv[];
# Line 44 | Line 54 | char   *argv[];
54                  fprintf(stderr, "%s: cannot open\n", argv[2]);
55                  exit(1);
56          }
57 <                                        /* copy header */
58 <        while (fgets(buf, sizeof(buf), fin) != NULL && buf[0] != '\n')
49 <                fputs(buf, stdout);
57 >                                        /* transfer header */
58 >        getheader(fin, headline);
59                                          /* add new header info. */
60 +        if (inpaspect < .99 || inpaspect > 1.01)
61 +                fputaspect(1./inpaspect/inpaspect, stdout);
62          printf("%s\n\n", progname);
63                                          /* get picture size */
64          if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) {
# Line 66 | Line 77 | char   *argv[];
77   rotate(fp)                      /* rotate picture */
78   FILE    *fp;
79   {
80 <        register COLR   *inline;
80 >        register COLR   *inln;
81          register int    xoff, inx, iny;
82          long    start, ftell();
83  
84 <        if ((inline = (COLR *)malloc(xres*sizeof(COLR))) == NULL) {
84 >        if ((inln = (COLR *)malloc(xres*sizeof(COLR))) == NULL) {
85                  fprintf(stderr, "%s: out of memory\n", progname);
86                  exit(1);
87          }
# Line 81 | Line 92 | FILE   *fp;
92                          exit(1);
93                  }
94                  for (iny = yres-1; iny >= 0; iny--) {
95 <                        if (freadcolrs(inline, xres, fp) < 0) {
95 >                        if (freadcolrs(inln, xres, fp) < 0) {
96                                  fprintf(stderr, "%s: read error\n", progname);
97                                  exit(1);
98                          }
99                          for (inx = 0; inx < nrows && xoff+inx < xres; inx++)
100 <                                bcopy(inline[xoff+inx], scanbar[inx*yres+iny],
100 >                                bcopy((char *)inln[xoff+inx],
101 >                                                (char *)scanbar[inx*yres+iny],
102                                                  sizeof(COLR));
103                  }
104                  for (inx = 0; inx < nrows && xoff+inx < xres; inx++)
# Line 95 | Line 107 | FILE   *fp;
107                                  exit(1);
108                          }
109          }
110 <        free((char *)inline);
110 >        free((char *)inln);
111   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines