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.1 by greg, Wed Jan 9 11:15:13 1991 UTC vs.
Revision 2.2 by greg, Mon Sep 21 12:14:23 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 8 | Line 8 | static char SCCSid[] = "$SunId$ LBL";
8   * flip picture file horizontally and/or vertically
9   */
10  
11 < #include "standard.h"
11 > #include <stdio.h>
12  
13 + #ifdef MSDOS
14 + #include  <fcntl.h>
15 + #endif
16 +
17   #include "color.h"
18  
19 < int     xres, yres;                     /* input resolution */
19 > #include "resolu.h"
20  
21 + int     order;                          /* input orientation */
22 + int     xres, yres;                     /* resolution (scanlen, nscans) */
23 +
24   long    *scanpos;                       /* scanline positions */
25  
26 < int     fhoriz, fvert;                  /* flip flags */
26 > int     fhoriz=0, fvert=0;              /* flip flags */
27  
28 + int     correctorder = 0;               /* correcting orientation? */
29 +
30   FILE    *fin;                           /* input file */
31  
32   char    *progname;
33  
34 + extern char     *malloc();
35  
36 +
37 + int
38 + neworder()                      /* figure out new order from old */
39 + {
40 +        register int  no;
41 +
42 +        if (correctorder)
43 +                return(order);          /* just leave it */
44 +        if ((no = order) & YMAJOR) {
45 +                if (fhoriz) no ^= XDECR;
46 +                if (fvert) no ^= YDECR;
47 +        } else {
48 +                if (fhoriz) no ^= YDECR;
49 +                if (fvert) no ^= XDECR;
50 +        }
51 +        return(no);
52 + }
53 +
54 +
55   main(argc, argv)
56   int     argc;
57   char    *argv[];
58   {
59          int     i;
60 <
60 > #ifdef MSDOS
61 >        extern int  _fmode;
62 >        _fmode = O_BINARY;
63 >        setmode(fileno(stdout), O_BINARY);
64 > #endif
65          progname = argv[0];
66  
67          for (i = 1; i < argc; i++)
# Line 36 | Line 69 | char   *argv[];
69                          fhoriz++;
70                  else if (!strcmp(argv[i], "-v"))
71                          fvert++;
72 +                else if (!strcmp(argv[i], "-c"))
73 +                        correctorder++;
74                  else
75                          break;
76          if (i >= argc || argv[i][0] == '-') {
77 <                fprintf(stderr, "Usage: %s [-h][-v] infile [outfile]\n",
77 >                fprintf(stderr, "Usage: %s [-h][-v][-c] infile [outfile]\n",
78                                  progname);
79                  exit(1);
80          }
# Line 52 | Line 87 | char   *argv[];
87                  exit(1);
88          }
89                                          /* transfer header */
90 <        copyheader(fin, stdout);
90 >        if (checkheader(fin, COLRFMT, stdout) < 0) {
91 >                fprintf(stderr, "%s: input not a Radiance picture\n",
92 >                                progname);
93 >                exit(1);
94 >        }
95                                          /* add new header info. */
96 <        printargs(argc, argv, stdout);
96 >        printargs(i, argv, stdout);
97 >        fputformat(COLRFMT, stdout);
98          putchar('\n');
99                                          /* get picture size */
100 <        if (fgetresolu(&xres, &yres, fin) != (YMAJOR|YDECR)) {
100 >        if ((order = fgetresolu(&xres, &yres, fin)) < 0) {
101                  fprintf(stderr, "%s: bad picture size\n", progname);
102                  exit(1);
103          }
104                                          /* write new picture size */
105 <        fputresolu(YMAJOR|YDECR, xres, yres, stdout);
105 >        fputresolu(neworder(), xres, yres, stdout);
106                                          /* goto end if vertical flip */
107          if (fvert)
108                  scanfile();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines