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.1 by greg, Tue Jun 1 17:36:55 1993 UTC vs.
Revision 2.7 by greg, Wed Dec 1 10:02:15 1993 UTC

# Line 9 | Line 9 | static char SCCSid[] = "$SunId$ LBL";
9   */
10  
11   #include  <stdio.h>
12 + #include  <math.h>
13   #ifdef MSDOS
14   #include  <fcntl.h>
15   #endif
# Line 17 | Line 18 | static char SCCSid[] = "$SunId$ LBL";
18  
19   extern char  *malloc();
20  
21 < double  gamma = 2.2;                    /* gamma correction */
21 > double  gamcor = 2.2;                   /* gamma correction */
22  
23   int  bradj = 0;                         /* brightness adjustment */
24  
# Line 30 | Line 31 | main(argc, argv)
31   int  argc;
32   char  *argv[];
33   {
34 +        extern long  getint();
35          int  reverse = 0;
36          int  i;
37          
# Line 39 | Line 41 | char  *argv[];
41                  if (argv[i][0] == '-')
42                          switch (argv[i][1]) {
43                          case 'g':               /* gamma correction */
44 <                                gamma = atof(argv[++i]);
44 >                                gamcor = atof(argv[++i]);
45                                  break;
46                          case 'e':               /* exposure adjustment */
47                                  if (argv[i+1][0] != '+' && argv[i+1][0] != '-')
# Line 63 | Line 65 | char  *argv[];
65                  exit(1);
66          }
67          if (i == argc-2 && freopen(argv[i+1], "w", stdout) == NULL) {
68 <                fprintf(stderr, "can't open output \"%s\"\n",
68 >                fprintf(stderr, "%s: can't open output \"%s\"\n",
69                                  progname, argv[i+1]);
70                  exit(1);
71          }
# Line 71 | Line 73 | char  *argv[];
73          setmode(fileno(stdin), O_BINARY);
74          setmode(fileno(stdout), O_BINARY);
75   #endif
76 <        setcolrgam(gamma);              /* set up gamma correction */
76 >        setcolrgam(gamcor);             /* set up gamma correction */
77          if (reverse) {
78                                          /* get their image resolution */
79 <                fread((char *)&xmax, sizeof(int), 1, stdin);
80 <                fread((char *)&ymax, sizeof(int), 1, stdin);
79 >                xmax = getint(4, stdin);
80 >                ymax = getint(4, stdin);
81 >                if (feof(stdin))
82 >                        quiterr("empty input file");
83                                          /* put our header */
84                  printargs(i, argv, stdout);
85                  fputformat(COLRFMT, stdout);
# Line 89 | Line 93 | char  *argv[];
93                                  fgetresolu(&xmax, &ymax, stdin) < 0)
94                          quiterr("bad picture format");
95                                          /* write their header */
96 <                fwrite((char *)&xmax, sizeof(int), 1, stdout);
97 <                fwrite((char *)&ymax, sizeof(int), 1, stdout);
96 >                putint((long)xmax, 4, stdout);
97 >                putint((long)ymax, 4, stdout);
98                                          /* convert file */
99                  ra2avs();
100          }
# Line 125 | Line 129 | avs2ra()               /* convert 24-bit scanlines to Radiance pict
129                  quiterr("out of memory in avs2ra");
130                                                  /* convert image */
131          for (y = ymax-1; y >= 0; y--) {
132 <                (void)getc(stdin);                      /* toss alpha */
133 <                scanout[x][RED] = getc(stdin);
134 <                scanout[x][GRN] = getc(stdin);
135 <                scanout[x][BLU] = getc(stdin);
136 <                if (feof(stdin) || ferror(stdin))
132 >                for (x = 0; x < xmax; x++) {
133 >                        (void)getc(stdin);                      /* toss alpha */
134 >                        scanout[x][RED] = getc(stdin);
135 >                        scanout[x][GRN] = getc(stdin);
136 >                        scanout[x][BLU] = getc(stdin);
137 >                }
138 >                if (feof(stdin) | ferror(stdin))
139                          quiterr("error reading AVS image");
140                                                  /* undo gamma */
141                  gambs_colrs(scanout, xmax);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines