| 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 */ |
| 97 |
|
COLOR *colptr; |
| 98 |
|
register int i; |
| 99 |
< |
/* set rendered resolution */ |
| 100 |
< |
xres = ourview.hresolu; |
| 102 |
< |
yres = ourview.vresolu; |
| 103 |
< |
/* adjust for sampling */ |
| 104 |
< |
if (psample <= 1) |
| 99 |
> |
/* check sampling */ |
| 100 |
> |
if (psample < 1) |
| 101 |
|
psample = 1; |
| 102 |
< |
else { |
| 103 |
< |
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 |
< |
} |
| 102 |
> |
else if (psample > MAXDIV) |
| 103 |
> |
psample = MAXDIV; |
| 104 |
|
/* allocate scanlines */ |
| 105 |
|
for (i = 0; i <= psample; i++) { |
| 106 |
< |
scanbar[i] = (COLOR *)malloc(xres*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, ourview.hresolu, ourview.vresolu, stdout); |
| 112 |
< |
|
| 113 |
< |
ypos = ourview.vresolu-1 - salvage(oldfile); /* find top line */ |
| 114 |
< |
fillscanline(scanbar[0], xres, 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 |
< |
pctdone = 100.0*(ourview.vresolu-ypos+psample)/ourview.vresolu; |
| 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], xres, ypos, psample); /* fill base */ |
| 125 |
< |
|
| 126 |
< |
fillscanbar(scanbar, xres, ypos, psample); /* fill bar */ |
| 127 |
< |
|
| 128 |
< |
for (i = psample; (ypos>0) ? i > 0 : ypos+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; |
| 133 |
|
} |
| 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 |
< |
|
| 150 |
> |
/* free scanlines */ |
| 151 |
|
for (i = 0; i <= psample; i++) |
| 152 |
|
free((char *)scanbar[i]); |
| 153 |
|
return; |
| 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 |
|
|