1 |
< |
/* Copyright (c) 1994 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
26 |
|
#define sscan(y) (ourspict+(y)*hresolu) |
27 |
|
#define wscan(y) (ourweigh+(y)*hresolu) |
28 |
|
#define zscan(y) (ourzbuf+(y)*hresolu) |
29 |
+ |
#define bscan(y) (ourbpict+(y)*hresolu) |
30 |
|
#define averaging (ourweigh != NULL) |
31 |
+ |
#define blurring (ourbpict != NULL) |
32 |
|
#define usematrix (hasmatrix & !averaging) |
33 |
|
#define zisnorm (!usematrix | ourview.type != VT_PER) |
34 |
|
|
61 |
|
COLOR *ourspict; /* output pixel sums (averaging) */ |
62 |
|
float *ourweigh = NULL; /* output pixel weights (averaging) */ |
63 |
|
float *ourzbuf; /* corresponding z-buffer */ |
64 |
+ |
COLOR *ourbpict = NULL; /* blurred picture (view averaging) */ |
65 |
|
|
66 |
+ |
VIEW avgview; /* average view for -B option */ |
67 |
+ |
int nvavg; /* number of views averaged */ |
68 |
+ |
|
69 |
|
char *progname; |
70 |
|
|
71 |
|
int fillo = F_FORE|F_BACK; /* selected fill options */ |
76 |
|
COLOR backcolor = BLKCOLOR; /* background color (float) */ |
77 |
|
double backz = 0.0; /* background z value */ |
78 |
|
int normdist = 1; /* i/o normalized distance? */ |
79 |
+ |
char ourfmt[LPICFMT+1] = PICFMT; /* original picture format */ |
80 |
|
double ourexp = -1; /* original picture exposure */ |
81 |
|
int expadj = 0; /* exposure adjustment (f-stops) */ |
82 |
|
double rexpadj = 1; /* real exposure adjustment */ |
83 |
|
|
84 |
< |
VIEW theirview = STDVIEW; /* input view */ |
84 |
> |
VIEW theirview; /* input view */ |
85 |
|
int gotview; /* got input view? */ |
86 |
|
int wrongformat = 0; /* input in another format? */ |
87 |
|
RESOLU tresolu; /* input resolution */ |
93 |
|
#define childpid (PDesc[2]) |
94 |
|
unsigned short queue[PACKSIZ][2]; /* pending pixels */ |
95 |
|
int packsiz; /* actual packet size */ |
96 |
< |
int queuesiz; /* number of pixels pending */ |
96 |
> |
int queuesiz = 0; /* number of pixels pending */ |
97 |
|
|
98 |
|
extern double movepixel(); |
99 |
|
|
102 |
|
int argc; |
103 |
|
char *argv[]; |
104 |
|
{ |
105 |
< |
#define check(ol,al) if (argv[i][ol] || \ |
106 |
< |
badarg(argc-i-1,argv+i+1,al)) \ |
105 |
> |
#define check(ol,al) if (argv[an][ol] || \ |
106 |
> |
badarg(argc-an-1,argv+an+1,al)) \ |
107 |
|
goto badopt |
108 |
|
int gotvfile = 0; |
109 |
|
int doavg = -1; |
110 |
+ |
int doblur = 0; |
111 |
|
char *zfile = NULL; |
112 |
|
char *expcomp = NULL; |
113 |
< |
char *err; |
106 |
< |
int i, rval; |
113 |
> |
int i, an, rval; |
114 |
|
|
115 |
|
progname = argv[0]; |
116 |
|
|
117 |
< |
for (i = 1; i < argc && argv[i][0] == '-'; i++) { |
118 |
< |
rval = getviewopt(&ourview, argc-i, argv+i); |
117 |
> |
for (an = 1; an < argc && argv[an][0] == '-'; an++) { |
118 |
> |
rval = getviewopt(&ourview, argc-an, argv+an); |
119 |
|
if (rval >= 0) { |
120 |
< |
i += rval; |
120 |
> |
an += rval; |
121 |
|
continue; |
122 |
|
} |
123 |
< |
switch (argv[i][1]) { |
123 |
> |
switch (argv[an][1]) { |
124 |
|
case 'e': /* exposure */ |
125 |
|
check(2,"f"); |
126 |
< |
expcomp = argv[++i]; |
126 |
> |
expcomp = argv[++an]; |
127 |
|
break; |
128 |
|
case 't': /* threshold */ |
129 |
|
check(2,"f"); |
130 |
< |
zeps = atof(argv[++i]); |
130 |
> |
zeps = atof(argv[++an]); |
131 |
|
break; |
132 |
|
case 'a': /* average */ |
133 |
|
check(2,NULL); |
134 |
|
doavg = 1; |
135 |
|
break; |
136 |
+ |
case 'B': /* blur views */ |
137 |
+ |
check(2,NULL); |
138 |
+ |
doblur = 1; |
139 |
+ |
break; |
140 |
|
case 'q': /* quick (no avg.) */ |
141 |
|
check(2,NULL); |
142 |
|
doavg = 0; |
146 |
|
normdist = !normdist; |
147 |
|
break; |
148 |
|
case 'f': /* fill type */ |
149 |
< |
switch (argv[i][2]) { |
149 |
> |
switch (argv[an][2]) { |
150 |
|
case '0': /* none */ |
151 |
|
check(3,NULL); |
152 |
|
fillo = 0; |
165 |
|
break; |
166 |
|
case 's': /* sample */ |
167 |
|
check(3,"i"); |
168 |
< |
fillsamp = atoi(argv[++i]); |
168 |
> |
fillsamp = atoi(argv[++an]); |
169 |
|
break; |
170 |
|
case 'c': /* color */ |
171 |
|
check(3,"fff"); |
172 |
|
fillfunc = backfill; |
173 |
< |
setcolor(backcolor, atof(argv[i+1]), |
174 |
< |
atof(argv[i+2]), atof(argv[i+3])); |
173 |
> |
setcolor(backcolor, atof(argv[an+1]), |
174 |
> |
atof(argv[an+2]), atof(argv[an+3])); |
175 |
|
setcolr(backcolr, colval(backcolor,RED), |
176 |
|
colval(backcolor,GRN), |
177 |
|
colval(backcolor,BLU)); |
178 |
< |
i += 3; |
178 |
> |
an += 3; |
179 |
|
break; |
180 |
|
case 'z': /* z value */ |
181 |
|
check(3,"f"); |
182 |
|
fillfunc = backfill; |
183 |
< |
backz = atof(argv[++i]); |
183 |
> |
backz = atof(argv[++an]); |
184 |
|
break; |
185 |
|
case 'r': /* rtrace */ |
186 |
|
check(3,"s"); |
187 |
|
fillfunc = rcalfill; |
188 |
< |
calstart(RTCOM, argv[++i]); |
188 |
> |
calstart(RTCOM, argv[++an]); |
189 |
|
break; |
190 |
|
default: |
191 |
|
goto badopt; |
193 |
|
break; |
194 |
|
case 'z': /* z file */ |
195 |
|
check(2,"s"); |
196 |
< |
zfile = argv[++i]; |
196 |
> |
zfile = argv[++an]; |
197 |
|
break; |
198 |
|
case 'x': /* x resolution */ |
199 |
|
check(2,"i"); |
200 |
< |
hresolu = atoi(argv[++i]); |
200 |
> |
hresolu = atoi(argv[++an]); |
201 |
|
break; |
202 |
|
case 'y': /* y resolution */ |
203 |
|
check(2,"i"); |
204 |
< |
vresolu = atoi(argv[++i]); |
204 |
> |
vresolu = atoi(argv[++an]); |
205 |
|
break; |
206 |
|
case 'p': /* pixel aspect */ |
207 |
< |
if (argv[i][2] != 'a') |
207 |
> |
if (argv[an][2] != 'a') |
208 |
|
goto badopt; |
209 |
|
check(3,"f"); |
210 |
< |
pixaspect = atof(argv[++i]); |
210 |
> |
pixaspect = atof(argv[++an]); |
211 |
|
break; |
212 |
|
case 'v': /* view file */ |
213 |
< |
if (argv[i][2] != 'f') |
213 |
> |
if (argv[an][2] != 'f') |
214 |
|
goto badopt; |
215 |
|
check(3,"s"); |
216 |
< |
gotvfile = viewfile(argv[++i], &ourview, 0, 0); |
216 |
> |
gotvfile = viewfile(argv[++an], &ourview, 0, 0); |
217 |
|
if (gotvfile < 0) |
218 |
< |
syserror(argv[i]); |
218 |
> |
syserror(argv[an]); |
219 |
|
else if (gotvfile == 0) { |
220 |
|
fprintf(stderr, "%s: bad view file\n", |
221 |
< |
argv[i]); |
221 |
> |
argv[an]); |
222 |
|
exit(1); |
223 |
|
} |
224 |
|
break; |
225 |
|
default: |
226 |
|
badopt: |
227 |
|
fprintf(stderr, "%s: command line error at '%s'\n", |
228 |
< |
progname, argv[i]); |
228 |
> |
progname, argv[an]); |
229 |
|
goto userr; |
230 |
|
} |
231 |
|
} |
232 |
|
/* check arguments */ |
233 |
< |
if ((argc-i)%2) |
233 |
> |
if ((argc-an)%2) |
234 |
|
goto userr; |
235 |
|
if (fillsamp == 1) |
236 |
|
fillo &= ~F_BACK; |
237 |
|
if (doavg < 0) |
238 |
< |
doavg = (argc-i) > 2; |
238 |
> |
doavg = (argc-an) > 2; |
239 |
|
if (expcomp != NULL) |
240 |
|
if (expcomp[0] == '+' | expcomp[0] == '-') { |
241 |
|
expadj = atof(expcomp) + (expcomp[0]=='+' ? .5 : -.5); |
242 |
< |
if (doavg) |
242 |
> |
if (doavg | doblur) |
243 |
|
rexpadj = pow(2.0, atof(expcomp)); |
244 |
|
else |
245 |
|
rexpadj = pow(2.0, (double)expadj); |
248 |
|
goto userr; |
249 |
|
rexpadj = atof(expcomp); |
250 |
|
expadj = log(rexpadj)/LOG2 + (rexpadj>1 ? .5 : -.5); |
251 |
< |
if (!doavg) |
251 |
> |
if (!(doavg | doblur)) |
252 |
|
rexpadj = pow(2.0, (double)expadj); |
253 |
|
} |
254 |
|
/* set view */ |
255 |
< |
if ((err = setview(&ourview)) != NULL) { |
256 |
< |
fprintf(stderr, "%s: %s\n", progname, err); |
255 |
> |
if (nextview(doblur ? stdin : NULL) == EOF) { |
256 |
> |
fprintf(stderr, "%s: no view on standard input!\n", |
257 |
> |
progname); |
258 |
|
exit(1); |
259 |
|
} |
260 |
|
normaspect(viewaspect(&ourview), &pixaspect, &hresolu, &vresolu); |
269 |
|
if (ourpict == NULL) |
270 |
|
syserror(progname); |
271 |
|
} |
272 |
+ |
if (doblur) { |
273 |
+ |
ourbpict = (COLOR *)bmalloc(hresolu*vresolu*sizeof(COLOR)); |
274 |
+ |
if (ourbpict == NULL) |
275 |
+ |
syserror(progname); |
276 |
+ |
} |
277 |
|
ourzbuf = (float *)bmalloc(hresolu*vresolu*sizeof(float)); |
278 |
|
if (ourzbuf == NULL) |
279 |
|
syserror(progname); |
263 |
– |
bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float)); |
280 |
|
/* new header */ |
281 |
|
newheader("RADIANCE", stdout); |
282 |
< |
/* get input */ |
283 |
< |
for ( ; i < argc; i += 2) |
284 |
< |
addpicture(argv[i], argv[i+1]); |
285 |
< |
/* fill in spaces */ |
286 |
< |
if (fillo&F_BACK) |
287 |
< |
backpicture(fillfunc, fillsamp); |
288 |
< |
else |
289 |
< |
fillpicture(fillfunc); |
282 |
> |
/* run pictures */ |
283 |
> |
do { |
284 |
> |
bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float)); |
285 |
> |
for (i = an; i < argc; i += 2) |
286 |
> |
addpicture(argv[i], argv[i+1]); |
287 |
> |
if (fillo&F_BACK) /* fill in spaces */ |
288 |
> |
backpicture(fillfunc, fillsamp); |
289 |
> |
else |
290 |
> |
fillpicture(fillfunc); |
291 |
> |
/* aft clipping */ |
292 |
> |
clipaft(); |
293 |
> |
} while (addblur() && nextview(stdin) != EOF); |
294 |
|
/* close calculation */ |
295 |
|
caldone(); |
276 |
– |
/* aft clipping */ |
277 |
– |
clipaft(); |
296 |
|
/* add to header */ |
297 |
|
printargs(argc, argv, stdout); |
298 |
< |
if (gotvfile) { |
298 |
> |
compavgview(); |
299 |
> |
if (doblur | gotvfile) { |
300 |
|
fputs(VIEWSTR, stdout); |
301 |
< |
fprintview(&ourview, stdout); |
301 |
> |
fprintview(&avgview, stdout); |
302 |
|
putc('\n', stdout); |
303 |
|
} |
304 |
|
if (pixaspect < .99 | pixaspect > 1.01) |
309 |
|
ourexp = rexpadj; |
310 |
|
if (ourexp < .995 | ourexp > 1.005) |
311 |
|
fputexpos(ourexp, stdout); |
312 |
< |
fputformat(COLRFMT, stdout); |
312 |
> |
if (strcmp(ourfmt, PICFMT)) /* print format if known */ |
313 |
> |
fputformat(ourfmt, stdout); |
314 |
|
putc('\n', stdout); |
315 |
|
/* write picture */ |
316 |
|
writepicture(); |
321 |
|
exit(0); |
322 |
|
userr: |
323 |
|
fprintf(stderr, |
324 |
< |
"Usage: %s [view opts][-t eps][-z zout][-e spec][-a|-q][-fT][-n] pfile zspec ..\n", |
324 |
> |
"Usage: %s [view opts][-t eps][-z zout][-e spec][-B][-a|-q][-fT][-n] pfile zspec ..\n", |
325 |
|
progname); |
326 |
|
exit(1); |
327 |
|
#undef check |
336 |
|
if (isheadid(s)) |
337 |
|
return; |
338 |
|
if (formatval(fmt, s)) { |
339 |
< |
wrongformat = strcmp(fmt, COLRFMT); |
339 |
> |
if (globmatch(ourfmt, fmt)) { |
340 |
> |
wrongformat = 0; |
341 |
> |
strcpy(ourfmt, fmt); |
342 |
> |
} else |
343 |
> |
wrongformat = 1; |
344 |
|
return; |
345 |
|
} |
346 |
< |
putc('\t', stdout); |
347 |
< |
fputs(s, stdout); |
348 |
< |
|
346 |
> |
if (nvavg < 2) { |
347 |
> |
putc('\t', stdout); |
348 |
> |
fputs(s, stdout); |
349 |
> |
} |
350 |
|
if (isexpos(s)) { |
351 |
|
theirexp *= exposval(s); |
352 |
|
return; |
356 |
|
} |
357 |
|
|
358 |
|
|
359 |
+ |
nextview(fp) /* get and set next view */ |
360 |
+ |
FILE *fp; |
361 |
+ |
{ |
362 |
+ |
char linebuf[256]; |
363 |
+ |
char *err; |
364 |
+ |
register int i; |
365 |
+ |
|
366 |
+ |
if (fp != NULL) { |
367 |
+ |
do /* get new view */ |
368 |
+ |
if (fgets(linebuf, sizeof(linebuf), fp) == NULL) |
369 |
+ |
return(EOF); |
370 |
+ |
while (!isview(linebuf) || !sscanview(&ourview, linebuf)); |
371 |
+ |
} |
372 |
+ |
/* set new view */ |
373 |
+ |
if ((err = setview(&ourview)) != NULL) { |
374 |
+ |
fprintf(stderr, "%s: %s\n", progname, err); |
375 |
+ |
exit(1); |
376 |
+ |
} |
377 |
+ |
if (!nvavg) { /* first view */ |
378 |
+ |
copystruct(&avgview, &ourview); |
379 |
+ |
return(nvavg++); |
380 |
+ |
} |
381 |
+ |
/* add to average view */ |
382 |
+ |
for (i = 0; i < 3; i++) { |
383 |
+ |
avgview.vp[i] += ourview.vp[i]; |
384 |
+ |
avgview.vdir[i] += ourview.vdir[i]; |
385 |
+ |
avgview.vup[i] += ourview.vup[i]; |
386 |
+ |
} |
387 |
+ |
avgview.horiz += ourview.horiz; |
388 |
+ |
avgview.vert += ourview.vert; |
389 |
+ |
avgview.hoff += ourview.hoff; |
390 |
+ |
avgview.voff += ourview.voff; |
391 |
+ |
avgview.vfore += ourview.vfore; |
392 |
+ |
avgview.vaft += ourview.vaft; |
393 |
+ |
return(nvavg++); |
394 |
+ |
} |
395 |
+ |
|
396 |
+ |
|
397 |
+ |
compavgview() /* compute average view */ |
398 |
+ |
{ |
399 |
+ |
register int i; |
400 |
+ |
double f; |
401 |
+ |
|
402 |
+ |
if (nvavg < 2) |
403 |
+ |
return; |
404 |
+ |
f = 1.0/nvavg; |
405 |
+ |
for (i = 0; i < 3; i++) { |
406 |
+ |
avgview.vp[i] *= f; |
407 |
+ |
avgview.vdir[i] *= f; |
408 |
+ |
avgview.vup[i] *= f; |
409 |
+ |
} |
410 |
+ |
avgview.horiz *= f; |
411 |
+ |
avgview.vert *= f; |
412 |
+ |
avgview.hoff *= f; |
413 |
+ |
avgview.voff *= f; |
414 |
+ |
avgview.vfore *= f; |
415 |
+ |
avgview.vaft *= f; |
416 |
+ |
if (setview(&avgview) != NULL) /* in case of emergency... */ |
417 |
+ |
copystruct(&avgview, &ourview); |
418 |
+ |
pixaspect = viewaspect(&avgview) * hresolu / vresolu; |
419 |
+ |
} |
420 |
+ |
|
421 |
+ |
|
422 |
|
addpicture(pfile, zspec) /* add picture to output */ |
423 |
|
char *pfile, *zspec; |
424 |
|
{ |
435 |
|
syserror(pfile); |
436 |
|
/* get header with exposure and view */ |
437 |
|
theirexp = 1.0; |
438 |
+ |
copystruct(&theirview, &stdview); |
439 |
|
gotview = 0; |
440 |
< |
printf("%s:\n", pfile); |
440 |
> |
if (nvavg < 2) |
441 |
> |
printf("%s:\n", pfile); |
442 |
|
getheader(pfp, headline, NULL); |
443 |
|
if (wrongformat || !gotview || !fgetsresolu(&tresolu, pfp)) { |
444 |
|
fprintf(stderr, "%s: picture format error\n", pfile); |
522 |
|
{ |
523 |
|
double m4t[4][4]; |
524 |
|
|
525 |
< |
if (vw1->type != VT_PER && vw1->type != VT_PAR) |
525 |
> |
if (vw1->type != VT_PER & vw1->type != VT_PAR) |
526 |
|
return(0); |
527 |
< |
if (vw2->type != VT_PER && vw2->type != VT_PAR) |
527 |
> |
if (vw2->type != VT_PER & vw2->type != VT_PAR) |
528 |
|
return(0); |
529 |
|
setident4(xfmat); |
530 |
|
xfmat[0][0] = vw1->hvec[0]; |
641 |
|
y1 = p0->y + c1*s1y/l1; |
642 |
|
for (c2 = l2; c2-- > 0; ) { |
643 |
|
x = x1 + c2*s2x/l2; |
644 |
< |
if (x < 0 || x >= hresolu) |
644 |
> |
if (x < 0 | x >= hresolu) |
645 |
|
continue; |
646 |
|
y = y1 + c2*s2y/l2; |
647 |
< |
if (y < 0 || y >= vresolu) |
647 |
> |
if (y < 0 | y >= vresolu) |
648 |
|
continue; |
649 |
|
if (averaging) { |
650 |
|
if (zscan(y)[x] <= 0 || zscan(y)[x]-z |
679 |
|
if (usematrix) { |
680 |
|
pos[0] += theirview.hoff - .5; |
681 |
|
pos[1] += theirview.voff - .5; |
682 |
+ |
if (normdist & theirview.type == VT_PER) |
683 |
+ |
d = sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
684 |
+ |
+ pos[1]*pos[1]*theirview.vn2); |
685 |
+ |
else |
686 |
+ |
d = 1.; |
687 |
+ |
pos[2] += d*theirview.vfore; |
688 |
|
if (theirview.type == VT_PER) { |
689 |
< |
if (normdist) /* adjust distance */ |
594 |
< |
pos[2] /= sqrt(1. + pos[0]*pos[0]*theirview.hn2 |
595 |
< |
+ pos[1]*pos[1]*theirview.vn2); |
689 |
> |
pos[2] /= d; |
690 |
|
pos[0] *= pos[2]; |
691 |
|
pos[1] *= pos[2]; |
692 |
|
} |
693 |
|
multp3(pos, pos, theirs2ours); |
694 |
< |
if (pos[2] <= 0) |
694 |
> |
if (pos[2] <= ourview.vfore) |
695 |
|
return(0); |
696 |
|
if (ourview.type == VT_PER) { |
697 |
|
pos[0] /= pos[2]; |
699 |
|
} |
700 |
|
pos[0] += .5 - ourview.hoff; |
701 |
|
pos[1] += .5 - ourview.voff; |
702 |
+ |
pos[2] -= ourview.vfore; |
703 |
|
} else { |
704 |
|
if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY) |
705 |
|
return(0); |
713 |
|
if (pos[2] <= 0) |
714 |
|
return(0); |
715 |
|
} |
716 |
< |
if (pos[0] < 0 || pos[0] >= 1-FTINY || pos[1] < 0 || pos[1] >= 1-FTINY) |
716 |
> |
if (pos[0] < 0 | pos[0] >= 1-FTINY | pos[1] < 0 | pos[1] >= 1-FTINY) |
717 |
|
return(0); |
718 |
|
if (!averaging) |
719 |
|
return(1); |
930 |
|
for (x = 0; x < hresolu; x++) |
931 |
|
if (zscan(y)[x] <= 0) |
932 |
|
(*fill)(x,y); |
933 |
+ |
if (fill == rcalfill) |
934 |
+ |
clearqueue(); |
935 |
|
} |
936 |
|
|
937 |
|
|
943 |
|
double yzn2, vx; |
944 |
|
|
945 |
|
if (ourview.vaft <= FTINY) |
946 |
< |
return; |
946 |
> |
return(0); |
947 |
|
tstdist = ourview.vaft - ourview.vfore; |
948 |
|
for (y = 0; y < vresolu; y++) { |
949 |
|
if (adjtest) { /* adjust test */ |
967 |
|
zscan(y)[x] = 0.0; |
968 |
|
} |
969 |
|
} |
970 |
+ |
return(1); |
971 |
|
} |
972 |
|
|
973 |
|
|
974 |
+ |
addblur() /* add to blurred picture */ |
975 |
+ |
{ |
976 |
+ |
COLOR cval; |
977 |
+ |
double d; |
978 |
+ |
register int i; |
979 |
+ |
|
980 |
+ |
if (!blurring) |
981 |
+ |
return(0); |
982 |
+ |
i = hresolu*vresolu; |
983 |
+ |
if (nvavg < 2) |
984 |
+ |
if (averaging) |
985 |
+ |
while (i--) { |
986 |
+ |
copycolor(ourbpict[i], ourspict[i]); |
987 |
+ |
d = 1.0/ourweigh[i]; |
988 |
+ |
scalecolor(ourbpict[i], d); |
989 |
+ |
} |
990 |
+ |
else |
991 |
+ |
while (i--) |
992 |
+ |
colr_color(ourbpict[i], ourpict[i]); |
993 |
+ |
else |
994 |
+ |
if (averaging) |
995 |
+ |
while (i--) { |
996 |
+ |
copycolor(cval, ourspict[i]); |
997 |
+ |
d = 1.0/ourweigh[i]; |
998 |
+ |
scalecolor(cval, d); |
999 |
+ |
addcolor(ourbpict[i], cval); |
1000 |
+ |
} |
1001 |
+ |
else |
1002 |
+ |
while (i--) { |
1003 |
+ |
colr_color(cval, ourpict[i]); |
1004 |
+ |
addcolor(ourbpict[i], cval); |
1005 |
+ |
} |
1006 |
+ |
/* print view */ |
1007 |
+ |
printf("VIEW%d:", nvavg); |
1008 |
+ |
fprintview(&ourview, stdout); |
1009 |
+ |
putchar('\n'); |
1010 |
+ |
return(1); |
1011 |
+ |
} |
1012 |
+ |
|
1013 |
+ |
|
1014 |
|
writepicture() /* write out picture (alters buffer) */ |
1015 |
|
{ |
1016 |
|
int y; |
1019 |
|
|
1020 |
|
fprtresolu(hresolu, vresolu, stdout); |
1021 |
|
for (y = vresolu-1; y >= 0; y--) |
1022 |
< |
if (averaging) { |
1022 |
> |
if (blurring) { |
1023 |
> |
for (x = 0; x < hresolu; x++) { /* compute avg. */ |
1024 |
> |
d = rexpadj/nvavg; |
1025 |
> |
scalecolor(bscan(y)[x], d); |
1026 |
> |
} |
1027 |
> |
if (fwritescan(bscan(y), hresolu, stdout) < 0) |
1028 |
> |
syserror(progname); |
1029 |
> |
} else if (averaging) { |
1030 |
|
for (x = 0; x < hresolu; x++) { /* average pixels */ |
1031 |
|
d = rexpadj/wscan(y)[x]; |
1032 |
|
scalecolor(sscan(y)[x], d); |