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.5 by greg, Mon Nov 11 14:02:02 1991 UTC vs.
Revision 2.4 by greg, Mon Oct 16 11:40:11 1995 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 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include <stdio.h>
12  
13 + #ifdef MSDOS
14 + #include  <fcntl.h>
15 + #endif
16 +
17   #include "color.h"
18  
19   #include "resolu.h"
# Line 27 | Line 31 | 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   {
# Line 50 | Line 56 | main(argc, argv)
56   int     argc;
57   char    *argv[];
58   {
59 <        int     i;
60 <
59 >        static char     picfmt[LPICFMT+1] = PICFMT;
60 >        int     i, rval;
61 > #ifdef MSDOS
62 >        extern int  _fmode;
63 >        _fmode = O_BINARY;
64 >        setmode(fileno(stdout), O_BINARY);
65 > #endif
66          progname = argv[0];
67  
68          for (i = 1; i < argc; i++)
# Line 77 | Line 88 | char   *argv[];
88                  exit(1);
89          }
90                                          /* transfer header */
91 <        if (checkheader(fin, COLRFMT, stdout) < 0) {
91 >        if ((rval = checkheader(fin, picfmt, stdout)) < 0) {
92                  fprintf(stderr, "%s: input not a Radiance picture\n",
93                                  progname);
94                  exit(1);
95          }
96 +        if (rval)
97 +                fputformat(picfmt, stdout);
98                                          /* add new header info. */
99          printargs(i, argv, stdout);
87        fputformat(COLRFMT, stdout);
100          putchar('\n');
101                                          /* get picture size */
102          if ((order = fgetresolu(&xres, &yres, fin)) < 0) {
# Line 118 | Line 130 | scanfile()                             /* scan to the end of file */
130                  memerr();
131          if ((scanin = (COLR *)malloc(xres*sizeof(COLR))) == NULL)
132                  memerr();
133 <        for (y = yres-1; y >= 0; y--) {
133 >        for (y = yres-1; y > 0; y--) {
134                  scanpos[y] = ftell(fin);
135                  if (freadcolrs(scanin, xres, fin) < 0) {
136                          fprintf(stderr, "%s: read error\n", progname);
137                          exit(1);
138                  }
139          }
140 +        scanpos[0] = ftell(fin);
141          free((char *)scanin);
142   }
143  
# Line 160 | Line 173 | flip()                                 /* flip the picture */
173                  }
174          }
175          free((char *)scanin);
176 <        free((char *)scanout);
176 >        if (fhoriz)
177 >                free((char *)scanout);
178   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines