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

Comparing ray/src/rt/rpict.c (file contents):
Revision 1.8 by greg, Wed Sep 13 15:21:41 1989 UTC vs.
Revision 1.9 by greg, Fri Sep 29 08:16:41 1989 UTC

# Line 49 | Line 49 | double  pctdone = 0.0;                 /* percentage done */
49  
50   extern long  nrays;                     /* number of rays traced */
51  
52 static int  xres, yres;                 /* output x and y resolution */
53
52   #define  MAXDIV         32              /* maximum sample size */
53  
54   #define  pixjitter()    (.5+dstrpix*(.5-frandom()))
# Line 96 | Line 94 | char  *oldfile;
94   {
95          COLOR  *scanbar[MAXDIV+1];      /* scanline arrays of pixel values */
96          int  ypos;                      /* current scanline */
97 +        int  xres, yres;                /* rendered x and y resolution */
98          COLOR  *colptr;
99          register int  i;
100 <
101 <        if (psample < 1)
100 >                                        /* set rendered resolution */
101 >        xres = ourview.hresolu;
102 >        yres = ourview.vresolu;
103 >                                        /* adjust for sampling */
104 >        if (psample <= 1)
105                  psample = 1;
106 <        else if (psample > MAXDIV)
107 <                psample = MAXDIV;
108 <                                        /* output resolution may be smaller */
109 <        xres = ourview.hresolu - (ourview.hresolu % psample);
110 <        yres = ourview.vresolu - (ourview.vresolu % psample);
111 <
106 >        else {
107 >                if (psample > MAXDIV)
108 >                        psample = MAXDIV;
109 >                                        /* rendered resolution may be larger */
110 >                xres += psample-1 - ((ourview.hresolu-2)%psample);
111 >                yres += psample-1 - ((ourview.vresolu-2)%psample);
112 >        }
113 >                                        /* allocate scanlines */
114          for (i = 0; i <= psample; i++) {
115 <                scanbar[i] = (COLOR *)malloc((xres+1)*sizeof(COLOR));
115 >                scanbar[i] = (COLOR *)malloc(xres*sizeof(COLOR));
116                  if (scanbar[i] == NULL)
117                          error(SYSTEM, "out of memory in render");
118          }
119                                          /* write out boundaries */
120 <        fputresolu(YMAJOR|YDECR, xres, yres, stdout);
120 >        fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, stdout);
121  
122 <        ypos = yres - salvage(oldfile); /* find top line */
123 <        fillscanline(scanbar[0], ypos, psample);        /* top scan */
122 >        ypos = ourview.vresolu-1 - salvage(oldfile);    /* find top line */
123 >        fillscanline(scanbar[0], xres, ypos, psample);  /* top scan */
124  
125          for (ypos -= psample; ypos > -psample; ypos -= psample) {
126          
127 <                colptr = scanbar[psample];              /* get last scanline */
127 >                pctdone = 100.0*(ourview.vresolu-ypos+psample)/ourview.vresolu;
128 >
129 >                colptr = scanbar[psample];              /* move base to top */
130                  scanbar[psample] = scanbar[0];
131                  scanbar[0] = colptr;
132  
133 <                fillscanline(scanbar[0], ypos, psample);        /* base scan */
133 >                fillscanline(scanbar[0], xres, ypos, psample);  /* fill base */
134          
135 <                fillscanbar(scanbar, ypos, psample);
135 >                fillscanbar(scanbar, xres, ypos, psample);      /* fill bar */
136                  
137 <                for (i = psample-1; i >= 0; i--)
138 <                        if (fwritescan(scanbar[i], xres, stdout) < 0)
137 >                for (i = psample; (ypos>0) ? i > 0 : ypos+i >= 0; i--)
138 >                        if (fwritescan(scanbar[i], ourview.hresolu, stdout) < 0)
139                                  goto writerr;
140                  if (fflush(stdout) == EOF)
141                          goto writerr;
136                pctdone = 100.0*(yres-ypos)/yres;
142          }
143 +        pctdone = 100.0;
144                  
145          for (i = 0; i <= psample; i++)
146                  free((char *)scanbar[i]);
# Line 144 | Line 150 | writerr:
150   }
151  
152  
153 < fillscanline(scanline, y, xstep)                /* fill scan line at y */
153 > fillscanline(scanline, xres, y, xstep)          /* fill scan line at y */
154   register COLOR  *scanline;
155 < int  y, xstep;
155 > int  xres, y, xstep;
156   {
157          int  b = xstep;
158          register int  i;
159          
160          pixvalue(scanline[0], 0, y);
161  
162 <        for (i = xstep; i <= xres; i += xstep) {
162 >        for (i = xstep; i < xres; i += xstep) {
163          
164                  pixvalue(scanline[i], i, y);
165                  
# Line 162 | Line 168 | int  y, xstep;
168   }
169  
170  
171 < fillscanbar(scanbar, y, ysize)          /* fill interior */
171 > fillscanbar(scanbar, xres, y, ysize)            /* fill interior */
172   register COLOR  *scanbar[];
173 < int  y, ysize;
173 > int  xres, y, ysize;
174   {
175          COLOR  vline[MAXDIV+1];
176          int  b = ysize;
# Line 256 | Line 262 | char  *oldfile;
262  
263          if (oldfile == NULL)
264                  return(0);
265 <        else if ((fp = fopen(oldfile, "r")) == NULL) {
265 >        
266 >        if ((fp = fopen(oldfile, "r")) == NULL) {
267                  sprintf(errmsg, "cannot open recover file \"%s\"", oldfile);
268                  error(WARNING, errmsg);
269                  return(0);
# Line 271 | Line 278 | char  *oldfile;
278                  return(0);
279          }
280  
281 <        if (x != xres || y != yres) {
281 >        if (x != ourview.hresolu || y != ourview.vresolu) {
282                  sprintf(errmsg, "resolution mismatch in recover file \"%s\"",
283                                  oldfile);
284                  error(USER, errmsg);
278                return(0);
285          }
286  
287 <        scanline = (COLR *)malloc(xres*sizeof(COLR));
287 >        scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR));
288          if (scanline == NULL)
289                  error(SYSTEM, "out of memory in salvage");
290 <        for (y = 0; y < yres; y++) {
291 <                if (freadcolrs(scanline, xres, fp) < 0)
290 >        for (y = 0; y < ourview.vresolu; y++) {
291 >                if (freadcolrs(scanline, ourview.hresolu, fp) < 0)
292                          break;
293 <                if (fwritecolrs(scanline, xres, stdout) < 0)
293 >                if (fwritecolrs(scanline, ourview.hresolu, stdout) < 0)
294                          goto writerr;
295          }
296          if (fflush(stdout) == EOF)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines