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

Comparing ray/src/px/ra_pr24.c (file contents):
Revision 1.8 by greg, Thu Aug 15 12:38:24 1991 UTC vs.
Revision 1.9 by greg, Mon Oct 14 17:06:49 1991 UTC

# Line 35 | Line 35 | char  *argv[];
35          
36          progname = argv[0];
37  
38 +        head.ras_type = RT_STANDARD;
39          for (i = 1; i < argc; i++)
40                  if (argv[i][0] == '-')
41                          switch (argv[i][1]) {
# Line 47 | Line 48 | char  *argv[];
48                                  bradj = atoi(argv[++i]);
49                                  break;
50                          case 'r':
51 <                                reverse = !reverse;
51 >                                if (!strcmp(argv[i], "-rgb"))
52 >                                        head.ras_type = RT_FORMAT_RGB;
53 >                                else
54 >                                        reverse = 1;
55                                  break;
56                          default:
57                                  goto userr;
# Line 99 | Line 103 | char  *argv[];
103                  head.ras_height = ymax;
104                  head.ras_depth = 24;
105                  head.ras_length = xmax*ymax*3;
102                head.ras_type = RT_STANDARD;
106                  head.ras_maptype = RMT_NONE;
107                  head.ras_maplength = 0;
108                  fwrite((char *)&head, sizeof(head), 1, stdout);
109                                          /* convert file */
110 <                ra2pr();
110 >                ra2pr(head.ras_type);
111          }
112          exit(0);
113   userr:
# Line 137 | Line 140 | int    rf;
140                  quiterr("out of memory in pr2ra");
141                                                  /* convert image */
142          for (y = ymax-1; y >= 0; y--) {
143 <                for (x = 0; x < xmax; x++)
144 <                        if (rf == RT_FORMAT_RGB) {
143 >                if (rf == RT_FORMAT_RGB)
144 >                        for (x = 0; x < xmax; x++) {
145                                  scanout[x][RED] = getc(stdin);
146                                  scanout[x][GRN] = getc(stdin);
147                                  scanout[x][BLU] = getc(stdin);
148 <                        } else {
148 >                        }
149 >                else
150 >                        for (x = 0; x < xmax; x++) {
151                                  scanout[x][BLU] = getc(stdin);
152                                  scanout[x][GRN] = getc(stdin);
153                                  scanout[x][RED] = getc(stdin);
# Line 160 | Line 165 | int    rf;
165   }
166  
167  
168 < ra2pr()                 /* convert Radiance scanlines to 24-bit rasterfile */
168 > ra2pr(rf)               /* convert Radiance scanlines to 24-bit rasterfile */
169 > int  rf;
170   {
171          COLR    *scanin;
172          register int    x;
# Line 176 | Line 182 | ra2pr()                        /* convert Radiance scanlines to 24-bit rast
182                  if (bradj)
183                          shiftcolrs(scanin, xmax, bradj);
184                  colrs_gambs(scanin, xmax);
185 <                for (x = 0; x < xmax; x++) {
186 <                        putc(scanin[x][BLU], stdout);
187 <                        putc(scanin[x][GRN], stdout);
188 <                        putc(scanin[x][RED], stdout);
189 <                }
185 >                if (rf == RT_FORMAT_RGB)
186 >                        for (x = 0; x < xmax; x++) {
187 >                                putc(scanin[x][RED], stdout);
188 >                                putc(scanin[x][GRN], stdout);
189 >                                putc(scanin[x][BLU], stdout);
190 >                        }
191 >                else
192 >                        for (x = 0; x < xmax; x++) {
193 >                                putc(scanin[x][BLU], stdout);
194 >                                putc(scanin[x][GRN], stdout);
195 >                                putc(scanin[x][RED], stdout);
196 >                        }
197                  if (ferror(stdout))
198                          quiterr("error writing rasterfile");
199          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines