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.10 by greg, Tue Oct 3 12:17:09 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 98 | Line 96 | char  *oldfile;
96          int  ypos;                      /* current scanline */
97          COLOR  *colptr;
98          register int  i;
99 <
99 >                                        /* check sampling */
100          if (psample < 1)
101                  psample = 1;
102          else if (psample > MAXDIV)
103                  psample = MAXDIV;
104 <                                        /* output resolution may be smaller */
107 <        xres = ourview.hresolu - (ourview.hresolu % psample);
108 <        yres = ourview.vresolu - (ourview.vresolu % psample);
109 <
104 >                                        /* allocate scanlines */
105          for (i = 0; i <= psample; i++) {
106 <                scanbar[i] = (COLOR *)malloc((xres+1)*sizeof(COLOR));
106 >                scanbar[i] = (COLOR *)malloc(ourview.hresolu*sizeof(COLOR));
107                  if (scanbar[i] == NULL)
108                          error(SYSTEM, "out of memory in render");
109          }
110                                          /* write out boundaries */
111 <        fputresolu(YMAJOR|YDECR, xres, yres, stdout);
112 <
113 <        ypos = yres - salvage(oldfile); /* find top line */
114 <        fillscanline(scanbar[0], ypos, psample);        /* top scan */
115 <
116 <        for (ypos -= psample; ypos > -psample; ypos -= psample) {
111 >        fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, stdout);
112 >                                        /* recover file and compute first */
113 >        ypos = ourview.vresolu-1 - salvage(oldfile);
114 >        fillscanline(scanbar[0], ourview.hresolu, ypos, psample);
115 >                                                /* compute scanlines */
116 >        for (ypos -= psample; ypos >= 0; ypos -= psample) {
117          
118 <                colptr = scanbar[psample];              /* get last scanline */
118 >                pctdone = 100.0*(ourview.vresolu-ypos-psample)/ourview.vresolu;
119 >
120 >                colptr = scanbar[psample];              /* move base to top */
121                  scanbar[psample] = scanbar[0];
122                  scanbar[0] = colptr;
123 <
124 <                fillscanline(scanbar[0], ypos, psample);        /* base scan */
125 <        
126 <                fillscanbar(scanbar, ypos, psample);
127 <                
128 <                for (i = psample-1; i >= 0; i--)
129 <                        if (fwritescan(scanbar[i], xres, stdout) < 0)
123 >                                                        /* fill base line */
124 >                fillscanline(scanbar[0], ourview.hresolu, ypos, psample);
125 >                                                        /* fill bar */
126 >                fillscanbar(scanbar, ourview.hresolu, ypos, psample);
127 >                                                        /* write it out */
128 >                for (i = psample; i > 0; i--)
129 >                        if (fwritescan(scanbar[i], ourview.hresolu, stdout) < 0)
130                                  goto writerr;
131                  if (fflush(stdout) == EOF)
132                          goto writerr;
136                pctdone = 100.0*(yres-ypos)/yres;
133          }
134 <                
134 >                                                /* compute residual */
135 >        colptr = scanbar[psample];
136 >        scanbar[psample] = scanbar[0];
137 >        scanbar[0] = colptr;
138 >        if (ypos > -psample) {
139 >                fillscanline(scanbar[-ypos], ourview.hresolu,
140 >                                0, psample);
141 >                fillscanbar(scanbar-ypos, ourview.hresolu,
142 >                                0, psample+ypos);
143 >        }
144 >        for (i = psample; i+ypos >= 0; i--)
145 >                if (fwritescan(scanbar[i], ourview.hresolu, stdout) < 0)
146 >                        goto writerr;
147 >        if (fflush(stdout) == EOF)
148 >                goto writerr;
149 >        pctdone = 100.0;
150 >                                                /* free scanlines */
151          for (i = 0; i <= psample; i++)
152                  free((char *)scanbar[i]);
153          return;
# Line 144 | Line 156 | writerr:
156   }
157  
158  
159 < fillscanline(scanline, y, xstep)                /* fill scan line at y */
159 > fillscanline(scanline, xres, y, xstep)          /* fill scan line at y */
160   register COLOR  *scanline;
161 < int  y, xstep;
161 > int  xres, y, xstep;
162   {
163          int  b = xstep;
164          register int  i;
165          
166          pixvalue(scanline[0], 0, y);
167  
168 <        for (i = xstep; i <= xres; i += xstep) {
168 >        for (i = xstep; i < xres; i += xstep) {
169          
170                  pixvalue(scanline[i], i, y);
171                  
172                  b = fillsample(scanline+i-xstep, i-xstep, y, xstep, 0, b/2);
173          }
174 +        if (i-xstep < xres-1) {
175 +                pixvalue(scanline[xres-1], xres-1, y);
176 +                fillsample(scanline+i-xstep, i-xstep, y,
177 +                                xres-1-(i-xstep), 0, b/2);
178 +        }
179   }
180  
181  
182 < fillscanbar(scanbar, y, ysize)          /* fill interior */
182 > fillscanbar(scanbar, xres, y, ysize)            /* fill interior */
183   register COLOR  *scanbar[];
184 < int  y, ysize;
184 > int  xres, y, ysize;
185   {
186          COLOR  vline[MAXDIV+1];
187          int  b = ysize;
# Line 256 | Line 273 | char  *oldfile;
273  
274          if (oldfile == NULL)
275                  return(0);
276 <        else if ((fp = fopen(oldfile, "r")) == NULL) {
276 >        
277 >        if ((fp = fopen(oldfile, "r")) == NULL) {
278                  sprintf(errmsg, "cannot open recover file \"%s\"", oldfile);
279                  error(WARNING, errmsg);
280                  return(0);
# Line 271 | Line 289 | char  *oldfile;
289                  return(0);
290          }
291  
292 <        if (x != xres || y != yres) {
292 >        if (x != ourview.hresolu || y != ourview.vresolu) {
293                  sprintf(errmsg, "resolution mismatch in recover file \"%s\"",
294                                  oldfile);
295                  error(USER, errmsg);
278                return(0);
296          }
297  
298 <        scanline = (COLR *)malloc(xres*sizeof(COLR));
298 >        scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR));
299          if (scanline == NULL)
300                  error(SYSTEM, "out of memory in salvage");
301 <        for (y = 0; y < yres; y++) {
302 <                if (freadcolrs(scanline, xres, fp) < 0)
301 >        for (y = 0; y < ourview.vresolu; y++) {
302 >                if (freadcolrs(scanline, ourview.hresolu, fp) < 0)
303                          break;
304 <                if (fwritecolrs(scanline, xres, stdout) < 0)
304 >                if (fwritecolrs(scanline, ourview.hresolu, stdout) < 0)
305                          goto writerr;
306          }
307          if (fflush(stdout) == EOF)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines