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

Comparing ray/src/px/ra_avs.c (file contents):
Revision 2.4 by greg, Mon Jul 12 12:41:13 1993 UTC vs.
Revision 2.11 by schorsch, Sun Mar 28 20:33:14 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1993 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  Convert Radiance file to/from AVS file.
6   */
7  
8   #include  <stdio.h>
9   #include  <math.h>
10 < #ifdef MSDOS
11 < #include  <fcntl.h>
12 < #endif
10 > #include  <time.h>
11 >
12 > #include  "platform.h"
13 > #include  "rtio.h"
14   #include  "color.h"
15   #include  "resolu.h"
16  
19 extern char  *malloc();
20
17   double  gamcor = 2.2;                   /* gamma correction */
18  
19   int  bradj = 0;                         /* brightness adjustment */
# Line 26 | Line 22 | char  *progname;
22  
23   int  xmax, ymax;
24  
25 + static void quiterr(char  *err);
26 + static void avs2ra(void);
27 + static void ra2avs(void);
28  
29 < main(argc, argv)
30 < int  argc;
31 < char  *argv[];
29 >
30 > int
31 > main(
32 >        int  argc,
33 >        char  *argv[]
34 > )
35   {
34        extern long  getint();
36          int  reverse = 0;
37          int  i;
38          
# Line 65 | Line 66 | char  *argv[];
66                  exit(1);
67          }
68          if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) {
69 <                fprintf(stderr, "can't open output \"%s\"\n",
69 >                fprintf(stderr, "%s: can't open output \"%s\"\n",
70                                  progname, argv[i+1]);
71                  exit(1);
72          }
73 < #ifdef MSDOS
74 <        setmode(fileno(stdin), O_BINARY);
74 <        setmode(fileno(stdout), O_BINARY);
75 < #endif
73 >        SET_FILE_BINARY(stdin);
74 >        SET_FILE_BINARY(stdout);
75          setcolrgam(gamcor);             /* set up gamma correction */
76          if (reverse) {
77                                          /* get their image resolution */
78                  xmax = getint(4, stdin);
79                  ymax = getint(4, stdin);
80 +                if (feof(stdin))
81 +                        quiterr("empty input file");
82                                          /* put our header */
83 +                newheader("RADIANCE", stdout);
84                  printargs(i, argv, stdout);
85                  fputformat(COLRFMT, stdout);
86                  putchar('\n');
# Line 105 | Line 107 | userr:
107   }
108  
109  
110 < quiterr(err)            /* print message and exit */
111 < char  *err;
110 > static void
111 > quiterr(                /* print message and exit */
112 >        char  *err
113 > )
114   {
115          if (err != NULL) {
116                  fprintf(stderr, "%s: %s\n", progname, err);
# Line 116 | Line 120 | char  *err;
120   }
121  
122  
123 < avs2ra()                /* convert 24-bit scanlines to Radiance picture */
123 > static void
124 > avs2ra(void)            /* convert 24-bit scanlines to Radiance picture */
125   {
126          COLR    *scanout;
127          register int    x;
# Line 127 | Line 132 | avs2ra()               /* convert 24-bit scanlines to Radiance pict
132                  quiterr("out of memory in avs2ra");
133                                                  /* convert image */
134          for (y = ymax-1; y >= 0; y--) {
135 <                (void)getc(stdin);                      /* toss alpha */
136 <                scanout[x][RED] = getc(stdin);
137 <                scanout[x][GRN] = getc(stdin);
138 <                scanout[x][BLU] = getc(stdin);
139 <                if (feof(stdin) || ferror(stdin))
135 >                for (x = 0; x < xmax; x++) {
136 >                        (void)getc(stdin);                      /* toss alpha */
137 >                        scanout[x][RED] = getc(stdin);
138 >                        scanout[x][GRN] = getc(stdin);
139 >                        scanout[x][BLU] = getc(stdin);
140 >                }
141 >                if (feof(stdin) | ferror(stdin))
142                          quiterr("error reading AVS image");
143                                                  /* undo gamma */
144                  gambs_colrs(scanout, xmax);
# Line 141 | Line 148 | avs2ra()               /* convert 24-bit scanlines to Radiance pict
148                          quiterr("error writing Radiance picture");
149          }
150                                                  /* free scanline */
151 <        free((char *)scanout);
151 >        free((void *)scanout);
152   }
153  
154  
155 < ra2avs()                /* convert Radiance scanlines to 24-bit */
155 > static void
156 > ra2avs(void)            /* convert Radiance scanlines to 24-bit */
157   {
158          COLR    *scanin;
159          register int    x;
# Line 171 | Line 179 | ra2avs()               /* convert Radiance scanlines to 24-bit */
179                          quiterr("error writing AVS file");
180          }
181                                                  /* free scanline */
182 <        free((char *)scanin);
182 >        free((void *)scanin);
183   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines