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.7 by greg, Tue Sep 12 12:28:26 1989 UTC vs.
Revision 1.10 by greg, Tue Oct 3 12:17:09 1989 UTC

# Line 96 | 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 <
105 <        ourview.hresolu -= ourview.hresolu % psample;
106 <        ourview.vresolu -= ourview.vresolu % psample;
107 <                
104 >                                        /* allocate scanlines */
105          for (i = 0; i <= psample; i++) {
106 <                scanbar[i] = (COLOR *)malloc((ourview.hresolu+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          }
113        
110                                          /* write out boundaries */
111          fputresolu(YMAJOR|YDECR, ourview.hresolu, ourview.vresolu, stdout);
112 <
113 <        ypos = ourview.vresolu - salvage(oldfile);      /* find top line */
114 <        fillscanline(scanbar[0], ypos, psample);        /* top scan */
115 <
116 <        for (ypos -= psample; ypos > -psample; ypos -= psample) {
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--)
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;
135                pctdone = 100.0*(ourview.vresolu-ypos)/ourview.vresolu;
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 143 | 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 <= ourview.hresolu; 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;
188          register int  i, j;
189          
190 <        for (i = 0; i < ourview.hresolu; i++) {
190 >        for (i = 0; i < xres; i++) {
191                  
192                  copycolor(vline[0], scanbar[0][i]);
193                  copycolor(vline[ysize], scanbar[ysize][i]);
# Line 255 | 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 274 | Line 293 | char  *oldfile;
293                  sprintf(errmsg, "resolution mismatch in recover file \"%s\"",
294                                  oldfile);
295                  error(USER, errmsg);
277                return(0);
296          }
297  
298          scanline = (COLR *)malloc(ourview.hresolu*sizeof(COLR));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines