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

Comparing ray/src/rt/rc2.c (file contents):
Revision 2.7 by greg, Thu Nov 15 19:41:03 2012 UTC vs.
Revision 2.13 by greg, Thu Jul 24 16:28:17 2014 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8  
9   #include "rcontrib.h"
10   #include "resolu.h"
11 + #include <ctype.h>
12  
13   /* Close output stream and free record */
14   static void
# Line 111 | Line 112 | printheader(FILE *fout, const char *info)
112          printargs(gargc-1, gargv, fout);        /* add our command */
113          fprintf(fout, "SOFTWARE= %s\n", VersionID);
114          fputnow(fout);
115 +        fputs("NCOMP=3\n", fout);               /* always RGB */
116          if (info != NULL)                       /* add extra info if given */
117                  fputs(info, fout);
118          fputformat(formstr(outfmt), fout);
# Line 131 | Line 133 | printresolu(FILE *fout, int xr, int yr)
133   STREAMOUT *
134   getostream(const char *ospec, const char *mname, int bn, int noopen)
135   {
134        /* static const DCOLOR  nocontrib = BLKCOLOR; */
136          static STREAMOUT        stdos;
137 +        char                    info[1024];
138          int                     ofl;
139          char                    oname[1024];
140          LUENT                   *lep;
141          STREAMOUT               *sop;
142 +        char                    *cp;
143          
144          if (ospec == NULL) {                    /* use stdout? */
145                  if (!noopen & !using_stdout) {
146                          if (outfmt != 'a')
147                                  SET_FILE_BINARY(stdout);
148 <                        if (header)
149 <                                printheader(stdout, NULL);
150 <                        printresolu(stdout, xres, yres);
148 >                        if (header) {
149 >                                cp = info;
150 >                                if (yres > 0) {
151 >                                        sprintf(cp, "NROWS=%d\n", yres *
152 >                                                        (xres + !xres) );
153 >                                        while (*cp) ++cp;
154 >                                }
155 >                                if ((xres <= 0) | (stdos.reclen > 1))
156 >                                        sprintf(cp, "NCOLS=%d\n", stdos.reclen);
157 >                                printheader(stdout, info);
158 >                        }
159 >                        if (stdos.reclen == 1)
160 >                                printresolu(stdout, xres, yres);
161                          if (waitflush > 0)
162                                  fflush(stdout);
163                          stdos.xr = xres; stdos.yr = yres;
# Line 182 | Line 195 | getostream(const char *ospec, const char *mname, int b
195                  }
196          }
197          if (!noopen && sop->ofp == NULL) {      /* open output stream */
185                long            i;
198                  if (oname[0] == '!')            /* output to command */
199                          sop->ofp = popen(oname+1, "w");
200                  else                            /* else open file */
# Line 194 | Line 206 | getostream(const char *ospec, const char *mname, int b
206   #ifdef getc_unlocked
207                  flockfile(sop->ofp);            /* avoid lock/unlock overhead */
208   #endif
209 +                if (accumulate > 0) {           /* global resolution */
210 +                        sop->xr = xres; sop->yr = yres;
211 +                }
212                  if (header) {
213 <                        char    info[512];
199 <                        char    *cp = info;
213 >                        cp = info;
214                          if (ofl & OF_MODIFIER || sop->reclen == 1) {
215                                  sprintf(cp, "MODIFIER=%s\n", mname);
216                                  while (*cp) ++cp;
# Line 205 | Line 219 | getostream(const char *ospec, const char *mname, int b
219                                  sprintf(cp, "BIN=%d\n", bn);
220                                  while (*cp) ++cp;
221                          }
222 <                        *cp = '\0';
222 >                        if (sop->yr > 0) {
223 >                                sprintf(cp, "NROWS=%d\n", sop->yr *
224 >                                                (sop->xr + !sop->xr) );
225 >                                while (*cp) ++cp;
226 >                        }
227 >                        if ((sop->xr <= 0) | (sop->reclen > 1))
228 >                                sprintf(cp, "NCOLS=%d\n", sop->reclen);
229                          printheader(sop->ofp, info);
230                  }
231 <                if (accumulate > 0) {           /* global resolution */
232 <                        sop->xr = xres; sop->yr = yres;
213 <                }
214 <                printresolu(sop->ofp, sop->xr, sop->yr);
215 < #if 0
216 <                                                /* play catch-up */
217 <                for (i = accumulate > 0 ? lastdone/accumulate : 0; i--; ) {
218 <                        int     j = sop->reclen;
219 <                        if (j <= 0) j = 1;
220 <                        while (j--)
221 <                                put_contrib(nocontrib, sop->ofp);
222 <                        if (outfmt == 'a')
223 <                                putc('\n', sop->ofp);
224 <                }
225 < #endif
231 >                if (sop->reclen == 1)
232 >                        printresolu(sop->ofp, sop->xr, sop->yr);
233                  if (waitflush > 0)
234                          fflush(sop->ofp);
235          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines