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.3 by greg, Sat Oct 20 11:41:29 1990 UTC vs.
Revision 1.6 by greg, Mon Apr 29 11:14:10 1991 UTC

# Line 69 | Line 69 | char  *argv[];
69                          quiterr("bad raster format");
70                  xmax = head.ras_width;
71                  ymax = head.ras_height;
72 <                if (head.ras_type != RT_STANDARD ||
73 <                                head.ras_maptype != RMT_NONE ||
74 <                                head.ras_depth != 24)
72 >                if ((head.ras_type != RT_STANDARD
73 >                                        && head.ras_type != RT_FORMAT_RGB)
74 >                                || head.ras_maptype != RMT_NONE
75 >                                || head.ras_depth != 24)
76                          quiterr("incompatible format");
77                                          /* put header */
78                  printargs(i, argv, stdout);
79 +                fputformat(COLRFMT, stdout);
80                  putchar('\n');
81                  fputresolu(YMAJOR|YDECR, xmax, ymax, stdout);
82                                          /* convert file */
83 <                pr2ra();
83 >                pr2ra(head.ras_type);
84          } else {
85 <                                        /* discard input header */
86 <                getheader(stdin, NULL);
87 <                                        /* get resolution */
88 <                if (fgetresolu(&xmax, &ymax, stdin) != (YMAJOR|YDECR))
87 <                        quiterr("bad picture size");
85 >                                        /* get header info. */
86 >                if (checkheader(stdin, COLRFMT, NULL) < 0 ||
87 >                        fgetresolu(&xmax, &ymax, stdin) != (YMAJOR|YDECR))
88 >                        quiterr("bad picture format");
89                                          /* write rasterfile header */
90                  head.ras_magic = RAS_MAGIC;
91                  head.ras_width = xmax;
# Line 117 | Line 118 | char  *err;
118   }
119  
120  
121 < pr2ra()                 /* convert 24-bit scanlines to Radiance picture */
121 > pr2ra(rf)               /* convert 24-bit scanlines to Radiance picture */
122 > int     rf;
123   {
124          COLR    *scanout;
125          register int    x;
# Line 128 | Line 130 | pr2ra()                        /* convert 24-bit scanlines to Radiance pict
130                  quiterr("out of memory in pr2ra");
131                                                  /* convert image */
132          for (y = ymax-1; y >= 0; y--) {
133 <                for (x = 0; x < xmax; x++) {
134 <                        scanout[x][RED] = getc(stdin);
135 <                        scanout[x][GRN] = getc(stdin);
136 <                        scanout[x][BLU] = getc(stdin);
137 <                }
133 >                for (x = 0; x < xmax; x++)
134 >                        if (rf == RT_FORMAT_RGB) {
135 >                                scanout[x][RED] = getc(stdin);
136 >                                scanout[x][GRN] = getc(stdin);
137 >                                scanout[x][BLU] = getc(stdin);
138 >                        } else {
139 >                                scanout[x][BLU] = getc(stdin);
140 >                                scanout[x][GRN] = getc(stdin);
141 >                                scanout[x][RED] = getc(stdin);
142 >                        }
143                  if (feof(stdin) || ferror(stdin))
144                          quiterr("error reading rasterfile");
145                  gambs_colrs(scanout, xmax);
# Line 159 | Line 166 | ra2pr()                        /* convert Radiance scanlines to 24-bit rast
166                          quiterr("error reading Radiance picture");
167                  colrs_gambs(scanin, xmax);
168                  for (x = 0; x < xmax; x++) {
162                        putc(scanin[x][RED], stdout);
163                        putc(scanin[x][GRN], stdout);
169                          putc(scanin[x][BLU], stdout);
170 +                        putc(scanin[x][GRN], stdout);
171 +                        putc(scanin[x][RED], stdout);
172                  }
173                  if (ferror(stdout))
174                          quiterr("error writing rasterfile");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines