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

Comparing ray/src/px/pflip.c (file contents):
Revision 1.4 by greg, Thu Apr 18 14:35:24 1991 UTC vs.
Revision 1.5 by greg, Mon Nov 11 14:02:02 1991 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include "color.h"
14  
15 < int     xres, yres;                     /* input resolution */
15 > #include "resolu.h"
16  
17 + int     order;                          /* input orientation */
18 + int     xres, yres;                     /* resolution (scanlen, nscans) */
19 +
20   long    *scanpos;                       /* scanline positions */
21  
22 < int     fhoriz, fvert;                  /* flip flags */
22 > int     fhoriz=0, fvert=0;              /* flip flags */
23  
24 + int     correctorder = 0;               /* correcting orientation? */
25 +
26   FILE    *fin;                           /* input file */
27  
28   char    *progname;
29  
30  
31 + int
32 + neworder()                      /* figure out new order from old */
33 + {
34 +        register int  no;
35 +
36 +        if (correctorder)
37 +                return(order);          /* just leave it */
38 +        if ((no = order) & YMAJOR) {
39 +                if (fhoriz) no ^= XDECR;
40 +                if (fvert) no ^= YDECR;
41 +        } else {
42 +                if (fhoriz) no ^= YDECR;
43 +                if (fvert) no ^= XDECR;
44 +        }
45 +        return(no);
46 + }
47 +
48 +
49   main(argc, argv)
50   int     argc;
51   char    *argv[];
# Line 36 | Line 59 | char   *argv[];
59                          fhoriz++;
60                  else if (!strcmp(argv[i], "-v"))
61                          fvert++;
62 +                else if (!strcmp(argv[i], "-c"))
63 +                        correctorder++;
64                  else
65                          break;
66          if (i >= argc || argv[i][0] == '-') {
67 <                fprintf(stderr, "Usage: %s [-h][-v] infile [outfile]\n",
67 >                fprintf(stderr, "Usage: %s [-h][-v][-c] infile [outfile]\n",
68                                  progname);
69                  exit(1);
70          }
# Line 62 | Line 87 | char   *argv[];
87          fputformat(COLRFMT, stdout);
88          putchar('\n');
89                                          /* get picture size */
90 <        if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) {
90 >        if ((order = fgetresolu(&xres, &yres, fin)) < 0) {
91                  fprintf(stderr, "%s: bad picture size\n", progname);
92                  exit(1);
93          }
94                                          /* write new picture size */
95 <        fputresolu(YMAJOR|YDECR, xres, yres, stdout);
95 >        fputresolu(neworder(), xres, yres, stdout);
96                                          /* goto end if vertical flip */
97          if (fvert)
98                  scanfile();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines