18 |
|
VIEW myview = STDVIEW; /* current output view */ |
19 |
|
int xres = 512, yres = 512; /* max. horizontal and vertical resolution */ |
20 |
|
char *outspec = NULL; /* output file specification */ |
21 |
+ |
int randflag = 0; /* random resampling algorithm? */ |
22 |
|
double pixaspect = 1.; /* pixel aspect ratio */ |
23 |
|
int seqstart = 0; /* sequence start frame */ |
24 |
|
double expval = 1.; /* exposure value */ |
75 |
|
goto userr; |
76 |
|
outspec = argv[++i]; |
77 |
|
break; |
78 |
+ |
case 'r': /* random sampling */ |
79 |
+ |
randflag = 1; |
80 |
+ |
break; |
81 |
+ |
case 's': /* smooth sampling */ |
82 |
+ |
randflag = 0; |
83 |
+ |
break; |
84 |
|
case 'S': /* sequence start */ |
85 |
|
if (badarg(argc-i-1,argv+i+1,"i")) |
86 |
|
goto userr; |
87 |
|
seqstart = atoi(argv[++i]); |
88 |
|
break; |
89 |
|
case 'v': /* view file */ |
90 |
< |
if (argv[i][1]!='f' || badarg(argc-i-1,argv+i+1,"s")) |
90 |
> |
if (argv[i][2]!='f' || badarg(argc-i-1,argv+i+1,"s")) |
91 |
|
goto userr; |
92 |
|
rval = viewfile(argv[++i], &myview, NULL); |
93 |
|
if (rval < 0) { |
118 |
|
quit(0); /* all done! */ |
119 |
|
userr: |
120 |
|
fprintf(stderr, |
121 |
< |
"Usage: %s [-w][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n", |
121 |
> |
"Usage: %s [-w][-r|-s][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n", |
122 |
|
progname); |
123 |
|
quit(1); |
124 |
|
} |
178 |
|
bil[i].b = bl[i].bi; |
179 |
|
} |
180 |
|
hdloadbeams(bil, nb, pixBeam); |
181 |
< |
pixFlush(); |
181 |
> |
pixFinish(randflag); |
182 |
|
free((char *)bil); |
183 |
|
} |
184 |
|
|
227 |
|
int |
228 |
|
endpicture() /* finish and write out pixels */ |
229 |
|
{ |
230 |
< |
int nunrend = 0; |
231 |
< |
int v; |
230 |
> |
int lastr = -1, nunrend = 0; |
231 |
> |
int4 lastp, lastrp; |
232 |
> |
register int4 p; |
233 |
|
register double d; |
226 |
– |
register int p; |
234 |
|
/* compute final pixel values */ |
235 |
|
for (p = hres*vres; p--; ) { |
236 |
|
if (myweight[p] <= FTINY) { |
237 |
+ |
if (lastr >= 0) |
238 |
+ |
if (p/hres == lastp/hres) |
239 |
+ |
copycolor(mypixel[p], mypixel[lastp]); |
240 |
+ |
else |
241 |
+ |
copycolor(mypixel[p], mypixel[lastrp]); |
242 |
|
nunrend++; |
243 |
|
continue; |
244 |
|
} |
245 |
|
d = expval/myweight[p]; |
246 |
|
scalecolor(mypixel[p], d); |
247 |
+ |
if ((lastp=p)/hres != lastr) |
248 |
+ |
lastr = (lastrp=p)/hres; |
249 |
|
} |
250 |
|
/* write each scanline */ |
251 |
< |
for (v = vres; v--; ) |
252 |
< |
if (fwritescan(mypixel+v*hres, hres, stdout) < 0) |
251 |
> |
for (p = vres; p--; ) |
252 |
> |
if (fwritescan(mypixel+p*hres, hres, stdout) < 0) |
253 |
|
return(-1); |
254 |
|
if (fflush(stdout) == EOF) |
255 |
|
return(-1); |