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

Comparing ray/src/px/ra_bmp.c (file contents):
Revision 2.1 by greg, Fri Mar 26 03:11:50 2004 UTC vs.
Revision 2.2 by greg, Sat Mar 27 05:43:37 2004 UTC

# Line 100 | Line 100 | main(int argc, char *argv[])
100                  rs.xr = rdr->hdr->width;
101                  rs.yr = rdr->hdr->height;
102                  rs.rt = YMAJOR;
103 +                                        /* write scans downward if we can */
104                  if (rdr->hdr->yIsDown || inpfile != NULL)
105                          rs.rt |= YDECR;
106                  fputsresolu(&rs, stdout);
107                                          /* convert file */
108                  bmp2rad(rdr, stdout, !rdr->hdr->yIsDown && inpfile!=NULL);
109                                          /* flush output */
110 <                BMPcloseInput(rdr);     /* COMMENT OUT LATER */
110 >                BMPcloseInput(rdr);
111                  if (fflush(stdout) < 0)
112                          quiterr("error writing Radiance output");
113          } else {
# Line 123 | Line 124 | main(int argc, char *argv[])
124                                  !fgetsresolu(&rs, stdin))
125                          quiterr("bad Radiance picture format");
126                                          /* initialize BMP header */
127 <                if (gryflag)
127 >                if (gryflag) {
128                          hdr = BMPmappedHeader(numscans(&rs),
129                                                  scanlen(&rs), 0, 256);
130 <                else
130 >                        if (outfile != NULL)
131 >                                hdr->compr = BI_RLE8;
132 >                } else
133                          hdr = BMPtruecolorHeader(numscans(&rs),
134                                                  scanlen(&rs), 0);
135                  if (hdr == NULL)
136                          quiterr("cannot initialize BMP header");
137 <                hdr->yIsDown = (rs.rt & YDECR) && outfile == NULL;
137 >                                        /* set up output direction */
138 >                hdr->yIsDown = (rs.rt & YDECR) &&
139 >                                (outfile == NULL | hdr->compr == BI_RLE8);
140                                          /* open BMP output */
141                  if (outfile != NULL)
142                          wtr = BMPopenOutputFile(outfile, hdr);
143                  else
144                          wtr = BMPopenOutputStream(stdout, hdr);
145 +                if (wtr == NULL)
146 +                        quiterr("cannot allocate writer structure");
147                                          /* convert file */
148                  rad2bmp(stdin, wtr, !hdr->yIsDown && (rs.rt&YDECR), gryflag);
149                                          /* flush output */
150                  if (fflush((FILE *)wtr->c_data) < 0)
151                          quiterr("error writing BMP output");
152 <                BMPcloseOutput(wtr);    /* COMMENT OUT LATER */
152 >                BMPcloseOutput(wtr);
153          }
154          exit(0);                        /* success */
155   userr:
# Line 150 | Line 157 | userr:
157                  "Usage: %s [-r][-g gamma][-e +/-stops] [input [output]]\n",
158                          progname);
159          exit(1);
160 <        return(1);      /* to keep compiler happy */
160 >        return(1);      /* gratis return */
161   }
162  
163   /* print message and exit */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines