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.3 by greg, Fri Jun 4 14:45:59 1993 UTC vs.
Revision 2.10 by schorsch, Thu Jun 5 19:29:34 2003 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  "color.h"
14   #include  "resolu.h"
15  
16 < extern char  *malloc();
16 > double  gamcor = 2.2;                   /* gamma correction */
17  
21 double  gamma = 2.2;                    /* gamma correction */
22
18   int  bradj = 0;                         /* brightness adjustment */
19  
20   char  *progname;
# Line 41 | Line 36 | char  *argv[];
36                  if (argv[i][0] == '-')
37                          switch (argv[i][1]) {
38                          case 'g':               /* gamma correction */
39 <                                gamma = atof(argv[++i]);
39 >                                gamcor = atof(argv[++i]);
40                                  break;
41                          case 'e':               /* exposure adjustment */
42                                  if (argv[i+1][0] != '+' && argv[i+1][0] != '-')
# Line 65 | Line 60 | char  *argv[];
60                  exit(1);
61          }
62          if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) {
63 <                fprintf(stderr, "can't open output \"%s\"\n",
63 >                fprintf(stderr, "%s: can't open output \"%s\"\n",
64                                  progname, argv[i+1]);
65                  exit(1);
66          }
67 < #ifdef MSDOS
68 <        setmode(fileno(stdin), O_BINARY);
69 <        setmode(fileno(stdout), O_BINARY);
75 < #endif
76 <        setcolrgam(gamma);              /* set up gamma correction */
67 >        SET_FILE_BINARY(stdin);
68 >        SET_FILE_BINARY(stdout);
69 >        setcolrgam(gamcor);             /* set up gamma correction */
70          if (reverse) {
71                                          /* get their image resolution */
72                  xmax = getint(4, stdin);
73                  ymax = getint(4, stdin);
74 +                if (feof(stdin))
75 +                        quiterr("empty input file");
76                                          /* put our header */
77 +                newheader("RADIANCE", stdout);
78                  printargs(i, argv, stdout);
79                  fputformat(COLRFMT, stdout);
80                  putchar('\n');
# Line 127 | Line 123 | avs2ra()               /* convert 24-bit scanlines to Radiance pict
123                  quiterr("out of memory in avs2ra");
124                                                  /* convert image */
125          for (y = ymax-1; y >= 0; y--) {
126 <                (void)getc(stdin);                      /* toss alpha */
127 <                scanout[x][RED] = getc(stdin);
128 <                scanout[x][GRN] = getc(stdin);
129 <                scanout[x][BLU] = getc(stdin);
130 <                if (feof(stdin) || ferror(stdin))
126 >                for (x = 0; x < xmax; x++) {
127 >                        (void)getc(stdin);                      /* toss alpha */
128 >                        scanout[x][RED] = getc(stdin);
129 >                        scanout[x][GRN] = getc(stdin);
130 >                        scanout[x][BLU] = getc(stdin);
131 >                }
132 >                if (feof(stdin) | ferror(stdin))
133                          quiterr("error reading AVS image");
134                                                  /* undo gamma */
135                  gambs_colrs(scanout, xmax);
# Line 141 | Line 139 | avs2ra()               /* convert 24-bit scanlines to Radiance pict
139                          quiterr("error writing Radiance picture");
140          }
141                                                  /* free scanline */
142 <        free((char *)scanout);
142 >        free((void *)scanout);
143   }
144  
145  
# Line 171 | Line 169 | ra2avs()               /* convert Radiance scanlines to 24-bit */
169                          quiterr("error writing AVS file");
170          }
171                                                  /* free scanline */
172 <        free((char *)scanin);
172 >        free((void *)scanin);
173   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines