ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rv2.c
Revision: 1.23
Committed: Thu Jul 18 15:49:06 1991 UTC (32 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 1.22: +38 -2 lines
Log Message:
added set options for di, i and b

File Contents

# User Rev Content
1 greg 1.1 /* Copyright (c) 1987 Regents of the University of California */
2    
3     #ifndef lint
4     static char SCCSid[] = "$SunId$ LBL";
5     #endif
6    
7     /*
8     * rv2.c - command routines used in tracing a view.
9     *
10     * 3/24/87
11     */
12    
13     #include "ray.h"
14    
15     #include "octree.h"
16    
17     #include "otypes.h"
18    
19     #include "rpaint.h"
20    
21     #include <ctype.h>
22    
23     #define CTRL(c) ('c'-'@')
24    
25     extern char *progname;
26    
27    
28     getframe(s) /* get a new frame */
29     char *s;
30     {
31 greg 1.12 if (getrect(s, &pframe) < 0)
32 greg 1.1 return;
33     pdepth = 0;
34     }
35    
36    
37 greg 1.12 getrepaint(s) /* get area and repaint */
38     char *s;
39     {
40     RECT box;
41    
42     if (getrect(s, &box) < 0)
43     return;
44 greg 1.14 paintrect(&ptrunk, 0, 0, hresolu, vresolu, &box);
45 greg 1.12 }
46    
47    
48 greg 1.1 getview(s) /* get/show view parameters */
49     char *s;
50     {
51     FILE *fp;
52     char buf[128];
53 greg 1.10 char *fname;
54 greg 1.3 int change = 0;
55 greg 1.1 VIEW nv;
56    
57     if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */
58 greg 1.10 if ((fname = getpath(buf, NULL, 0)) == NULL ||
59 greg 1.1 (fp = fopen(fname, "a")) == NULL) {
60     sprintf(errmsg, "cannot open \"%s\"", buf);
61     error(COMMAND, errmsg);
62     return;
63     }
64 greg 1.2 fputs(progname, fp);
65 greg 1.1 fprintview(&ourview, fp);
66 greg 1.19 fputs(sskip(s), fp);
67 greg 1.1 fputs("\n", fp);
68     fclose(fp);
69     return;
70     }
71     sprintf(buf, "view type (%c): ", ourview.type);
72     (*dev->comout)(buf);
73 greg 1.18 (*dev->comin)(buf, NULL);
74 greg 1.1 if (buf[0] == CTRL(C)) return;
75 greg 1.3 if (buf[0] && buf[0] != ourview.type) {
76 greg 1.1 nv.type = buf[0];
77 greg 1.3 change++;
78     } else
79 greg 1.1 nv.type = ourview.type;
80     sprintf(buf, "view point (%.6g %.6g %.6g): ",
81     ourview.vp[0], ourview.vp[1], ourview.vp[2]);
82     (*dev->comout)(buf);
83 greg 1.18 (*dev->comin)(buf, NULL);
84 greg 1.1 if (buf[0] == CTRL(C)) return;
85 greg 1.3 if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3)
86     change++;
87     else
88 greg 1.1 VCOPY(nv.vp, ourview.vp);
89     sprintf(buf, "view direction (%.6g %.6g %.6g): ",
90     ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]);
91     (*dev->comout)(buf);
92 greg 1.18 (*dev->comin)(buf, NULL);
93 greg 1.1 if (buf[0] == CTRL(C)) return;
94 greg 1.3 if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3)
95     change++;
96     else
97 greg 1.1 VCOPY(nv.vdir, ourview.vdir);
98     sprintf(buf, "view up (%.6g %.6g %.6g): ",
99     ourview.vup[0], ourview.vup[1], ourview.vup[2]);
100     (*dev->comout)(buf);
101 greg 1.18 (*dev->comin)(buf, NULL);
102 greg 1.1 if (buf[0] == CTRL(C)) return;
103 greg 1.3 if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3)
104     change++;
105     else
106 greg 1.1 VCOPY(nv.vup, ourview.vup);
107     sprintf(buf, "view horiz and vert size (%.6g %.6g): ",
108     ourview.horiz, ourview.vert);
109     (*dev->comout)(buf);
110 greg 1.18 (*dev->comin)(buf, NULL);
111 greg 1.1 if (buf[0] == CTRL(C)) return;
112 greg 1.3 if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2)
113     change++;
114     else {
115 greg 1.1 nv.horiz = ourview.horiz; nv.vert = ourview.vert;
116     }
117 greg 1.14 sprintf(buf, "view shift and lift (%.6g %.6g): ",
118     ourview.hoff, ourview.voff);
119 greg 1.1 (*dev->comout)(buf);
120 greg 1.18 (*dev->comin)(buf, NULL);
121 greg 1.1 if (buf[0] == CTRL(C)) return;
122 greg 1.14 if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2)
123 greg 1.3 change++;
124     else {
125 greg 1.14 nv.hoff = ourview.hoff; nv.voff = ourview.voff;
126 greg 1.1 }
127 greg 1.3 if (change)
128     newview(&nv);
129 greg 1.1 }
130    
131    
132     lastview(s) /* return to a previous view */
133     char *s;
134     {
135     char buf[128];
136 greg 1.10 char *fname;
137 greg 1.1 int success;
138     VIEW nv;
139    
140     if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */
141 greg 1.17 copystruct(&nv, &stdview);
142 greg 1.10 if ((fname = getpath(buf, NULL, 0)) == NULL ||
143 greg 1.16 (success = viewfile(fname, &nv, 0, 0)) == -1) {
144 greg 1.1 sprintf(errmsg, "cannot open \"%s\"", buf);
145     error(COMMAND, errmsg);
146     return;
147     }
148     if (!success)
149     error(COMMAND, "wrong file format");
150     else
151     newview(&nv);
152     return;
153     }
154 greg 1.20 if (oldview.type == 0) { /* no old view! */
155 greg 1.1 error(COMMAND, "no previous view");
156     return;
157     }
158 greg 1.17 copystruct(&nv, &ourview);
159     copystruct(&ourview, &oldview);
160     copystruct(&oldview, &nv);
161 greg 1.1 newimage();
162     }
163    
164    
165     getaim(s) /* aim camera */
166     char *s;
167     {
168     extern double tan(), atan();
169     double zfact;
170     VIEW nv;
171    
172     if (getinterest(s, 1, nv.vdir, &zfact) < 0)
173     return;
174 greg 1.21 nv.type = ourview.type;
175 greg 1.1 VCOPY(nv.vp, ourview.vp);
176     VCOPY(nv.vup, ourview.vup);
177 greg 1.14 nv.hoff = ourview.hoff; nv.voff = ourview.voff;
178 greg 1.21 nv.horiz = ourview.horiz; nv.vert = ourview.vert;
179     zoomview(&nv, zfact);
180 greg 1.1 newview(&nv);
181     }
182    
183    
184     getmove(s) /* move camera */
185     char *s;
186     {
187     FVECT vc;
188     double mag;
189    
190     if (getinterest(s, 0, vc, &mag) < 0)
191     return;
192 greg 1.4 moveview(0.0, 0.0, mag, vc);
193 greg 1.1 }
194    
195    
196     getrotate(s) /* rotate camera */
197     char *s;
198     {
199 greg 1.4 extern double normalize(), tan(), atan();
200 greg 1.1 VIEW nv;
201     FVECT v1;
202 greg 1.4 double angle, elev, zfact;
203 greg 1.1
204 greg 1.4 elev = 0.0; zfact = 1.0;
205     if (sscanf(s, "%lf %lf %lf", &angle, &elev, &zfact) < 1) {
206 greg 1.1 error(COMMAND, "missing angle");
207     return;
208     }
209 greg 1.21 nv.type = ourview.type;
210 greg 1.1 VCOPY(nv.vp, ourview.vp);
211     VCOPY(nv.vup, ourview.vup);
212 greg 1.14 nv.hoff = ourview.hoff; nv.voff = ourview.voff;
213 greg 1.1 spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.));
214     if (elev != 0.0) {
215     fcross(v1, nv.vdir, ourview.vup);
216     normalize(v1);
217     spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
218     }
219 greg 1.21 nv.horiz = ourview.horiz; nv.vert = ourview.vert;
220     zoomview(&nv, zfact);
221 greg 1.1 newview(&nv);
222     }
223    
224    
225     getpivot(s) /* pivot viewpoint */
226     register char *s;
227     {
228     FVECT vc;
229 greg 1.4 double angle, elev, mag;
230 greg 1.1
231 greg 1.4 elev = 0.0;
232     if (sscanf(s, "%lf %lf", &angle, &elev) < 1) {
233 greg 1.1 error(COMMAND, "missing angle");
234     return;
235     }
236 greg 1.4 if (getinterest(sskip(sskip(s)), 0, vc, &mag) < 0)
237 greg 1.1 return;
238 greg 1.4 moveview(angle, elev, mag, vc);
239 greg 1.1 }
240    
241    
242     getexposure(s) /* get new exposure */
243     char *s;
244     {
245     double atof(), pow(), fabs();
246     char buf[128];
247     register char *cp;
248     register PNODE *p;
249     RECT r;
250     int x, y;
251     double e;
252    
253     for (cp = s; isspace(*cp); cp++)
254     ;
255     if (*cp == '\0') { /* normalize to point */
256     if (dev->getcur == NULL)
257     return;
258     (*dev->comout)("Pick point for exposure\n");
259     if ((*dev->getcur)(&x, &y) == ABORT)
260     return;
261     r.l = r.d = 0;
262 greg 1.14 r.r = hresolu; r.u = vresolu;
263 greg 1.1 p = findrect(x, y, &ptrunk, &r, -1);
264     e = 1.0;
265     } else {
266     if (*cp == '=') { /* absolute setting */
267     p = NULL;
268     e = 1.0/exposure;
269     for (cp++; isspace(*cp); cp++)
270     ;
271     if (*cp == '\0') { /* interactive */
272     sprintf(buf, "exposure (%lf): ", exposure);
273     (*dev->comout)(buf);
274 greg 1.18 (*dev->comin)(buf, NULL);
275 greg 1.1 for (cp = buf; isspace(*cp); cp++)
276     ;
277     if (*cp == '\0')
278     return;
279     }
280     } else { /* normalize to average */
281     p = &ptrunk;
282     e = 1.0;
283     }
284     if (*cp == '+' || *cp == '-') /* f-stops */
285     e *= pow(2.0, atof(cp));
286     else /* multiplier */
287     e *= atof(cp);
288     }
289     if (p != NULL) { /* relative setting */
290 greg 1.6 if (bright(p->v) <= FTINY) {
291 greg 1.1 error(COMMAND, "cannot normalize to zero");
292     return;
293     }
294 greg 1.6 e *= 0.5 / bright(p->v);
295 greg 1.1 }
296     if (e <= FTINY || fabs(1.0 - e) <= FTINY)
297     return;
298     scalepict(&ptrunk, e);
299     exposure *= e;
300     redraw();
301     }
302    
303    
304     setparam(s) /* get/set program parameter */
305     register char *s;
306     {
307     extern int psample;
308     extern double maxdiff;
309     extern double minweight;
310     extern int maxdepth;
311     extern double dstrsrc;
312 greg 1.5 extern double shadthresh;
313 greg 1.9 extern double shadcert;
314 greg 1.1 extern COLOR ambval;
315     extern double ambacc;
316     extern double minarad;
317     extern int ambres;
318     extern int ambdiv;
319     extern int ambssamp;
320     extern int ambounce;
321 greg 1.23 extern int directinvis;
322     extern int do_irrad;
323 greg 1.1 int i0;
324     double d0, d1, d2;
325 greg 1.23 char buf[128], ans[4];
326 greg 1.1
327     if (s[0] == '\0') {
328 greg 1.23 (*dev->comout)(
329     "aa ab ad ar as av b dc dj di dt i lr lw sp st: ");
330 greg 1.18 (*dev->comin)(buf, NULL);
331 greg 1.1 s = buf;
332     }
333     switch (s[0]) {
334     case 'l': /* limit */
335     switch (s[1]) {
336     case 'w': /* weight */
337     if (sscanf(s+2, "%lf", &d0) != 1) {
338     sprintf(buf, "limit weight (%.6g): ",
339     minweight);
340     (*dev->comout)(buf);
341 greg 1.18 (*dev->comin)(buf, NULL);
342 greg 1.1 if (sscanf(buf, "%lf", &d0) != 1)
343     break;
344     }
345     minweight = d0;
346     break;
347     case 'r': /* reflection */
348     if (sscanf(s+2, "%d", &i0) != 1) {
349     sprintf(buf, "limit reflection (%d): ",
350     maxdepth);
351     (*dev->comout)(buf);
352 greg 1.18 (*dev->comin)(buf, NULL);
353 greg 1.1 if (sscanf(buf, "%d", &i0) != 1)
354     break;
355     }
356     maxdepth = i0;
357     break;
358     default:
359     goto badparam;
360     }
361     break;
362 greg 1.5 case 'd': /* direct */
363     switch (s[1]) {
364     case 'j': /* jitter */
365     if (sscanf(s+2, "%lf", &d0) != 1) {
366     sprintf(buf, "direct jitter (%.6g): ",
367     dstrsrc);
368     (*dev->comout)(buf);
369 greg 1.18 (*dev->comin)(buf, NULL);
370 greg 1.5 if (sscanf(buf, "%lf", &d0) != 1)
371     break;
372     }
373     dstrsrc = d0;
374 greg 1.9 break;
375     case 'c': /* certainty */
376     if (sscanf(s+2, "%lf", &d0) != 1) {
377     sprintf(buf, "direct certainty (%.6g): ",
378     shadcert);
379     (*dev->comout)(buf);
380 greg 1.18 (*dev->comin)(buf, NULL);
381 greg 1.9 if (sscanf(buf, "%lf", &d0) != 1)
382     break;
383     }
384     shadcert = d0;
385 greg 1.5 break;
386 greg 1.8 case 't': /* threshold */
387 greg 1.5 if (sscanf(s+2, "%lf", &d0) != 1) {
388 greg 1.8 sprintf(buf, "direct threshold (%.6g): ",
389 greg 1.5 shadthresh);
390     (*dev->comout)(buf);
391 greg 1.18 (*dev->comin)(buf, NULL);
392 greg 1.5 if (sscanf(buf, "%lf", &d0) != 1)
393     break;
394     }
395     shadthresh = d0;
396     break;
397 greg 1.23 case 'i': /* invisibility */
398     if (sscanf(s+2, "%1s", ans) != 1) {
399     sprintf(buf, "direct invisibility (%c): ",
400     directinvis ? 'y' : 'n');
401     (*dev->comout)(buf);
402     (*dev->comin)(buf, NULL);
403     if (sscanf(buf, "%1s", ans) != 1)
404     break;
405     }
406     directinvis = tolower(ans[0]) == 'y';
407     break;
408 greg 1.5 default:
409 greg 1.1 goto badparam;
410     }
411 greg 1.23 break;
412     case 'b': /* black and white */
413     if (sscanf(s+1, "%1s", ans) != 1) {
414     sprintf(buf, "black and white (%c): ",
415     greyscale ? 'y' : 'n');
416     (*dev->comout)(buf);
417     (*dev->comin)(buf, NULL);
418     if (sscanf(buf, "%1s", ans) != 1)
419     break;
420     }
421     greyscale = tolower(ans[0]) == 'y';
422     break;
423     case 'i': /* irradiance */
424     if (sscanf(s+1, "%1s", ans) != 1) {
425     sprintf(buf, "irradiance (%c): ",
426     do_irrad ? 'y' : 'n');
427     (*dev->comout)(buf);
428     (*dev->comin)(buf, NULL);
429     if (sscanf(buf, "%1s", ans) != 1)
430     break;
431     }
432     do_irrad = tolower(ans[0]) == 'y';
433 greg 1.1 break;
434     case 'a': /* ambient */
435     switch (s[1]) {
436     case 'v': /* value */
437     if (sscanf(s+2, "%lf %lf %lf", &d0, &d1, &d2) != 3) {
438     sprintf(buf,
439     "ambient value (%.6g %.6g %.6g): ",
440     colval(ambval,RED),
441     colval(ambval,GRN),
442     colval(ambval,BLU));
443     (*dev->comout)(buf);
444 greg 1.18 (*dev->comin)(buf, NULL);
445 greg 1.1 if (sscanf(buf, "%lf %lf %lf",
446     &d0, &d1, &d2) != 3)
447     break;
448     }
449     setcolor(ambval, d0, d1, d2);
450     break;
451     case 'a': /* accuracy */
452     if (sscanf(s+2, "%lf", &d0) != 1) {
453     sprintf(buf, "ambient accuracy (%.6g): ",
454     ambacc);
455     (*dev->comout)(buf);
456 greg 1.18 (*dev->comin)(buf, NULL);
457 greg 1.1 if (sscanf(buf, "%lf", &d0) != 1)
458     break;
459     }
460     ambacc = d0;
461     break;
462     case 'd': /* divisions */
463     if (sscanf(s+2, "%d", &i0) != 1) {
464     sprintf(buf, "ambient divisions (%d): ",
465     ambdiv);
466     (*dev->comout)(buf);
467 greg 1.18 (*dev->comin)(buf, NULL);
468 greg 1.1 if (sscanf(buf, "%d", &i0) != 1)
469     break;
470     }
471     ambdiv = i0;
472     break;
473     case 's': /* samples */
474     if (sscanf(s+2, "%d", &i0) != 1) {
475     sprintf(buf, "ambient super-samples (%d): ",
476     ambssamp);
477     (*dev->comout)(buf);
478 greg 1.18 (*dev->comin)(buf, NULL);
479 greg 1.1 if (sscanf(buf, "%d", &i0) != 1)
480     break;
481     }
482     ambssamp = i0;
483     break;
484     case 'b': /* bounces */
485     if (sscanf(s+2, "%d", &i0) != 1) {
486     sprintf(buf, "ambient bounces (%d): ",
487     ambounce);
488     (*dev->comout)(buf);
489 greg 1.18 (*dev->comin)(buf, NULL);
490 greg 1.1 if (sscanf(buf, "%d", &i0) != 1)
491     break;
492     }
493     ambounce = i0;
494     break;
495     case 'r':
496     if (sscanf(s+2, "%d", &i0) != 1) {
497     sprintf(buf, "ambient resolution (%d): ",
498     ambres);
499     (*dev->comout)(buf);
500 greg 1.18 (*dev->comin)(buf, NULL);
501 greg 1.1 if (sscanf(buf, "%d", &i0) != 1)
502     break;
503     }
504     ambres = i0;
505     minarad = ambres > 0 ? thescene.cusize/ambres : 0.0;
506     break;
507     default:
508     goto badparam;
509     }
510     break;
511     case 's': /* sample */
512     switch (s[1]) {
513     case 'p': /* pixel */
514     if (sscanf(s+2, "%d", &i0) != 1) {
515     sprintf(buf, "sample pixel (%d): ", psample);
516     (*dev->comout)(buf);
517 greg 1.18 (*dev->comin)(buf, NULL);
518 greg 1.1 if (sscanf(buf, "%d", &i0) != 1)
519     break;
520     }
521     psample = i0;
522     pdepth = 0;
523     break;
524 greg 1.8 case 't': /* threshold */
525 greg 1.1 if (sscanf(s+2, "%lf", &d0) != 1) {
526 greg 1.8 sprintf(buf, "sample threshold (%.6g): ",
527 greg 1.1 maxdiff);
528     (*dev->comout)(buf);
529 greg 1.18 (*dev->comin)(buf, NULL);
530 greg 1.1 if (sscanf(buf, "%lf", &d0) != 1)
531     break;
532     }
533     maxdiff = d0;
534     pdepth = 0;
535     break;
536     default:
537     goto badparam;
538     }
539     break;
540     case '\0': /* nothing */
541     break;
542     default:;
543     badparam:
544     sprintf(errmsg, "%s: unknown variable", s);
545     error(COMMAND, errmsg);
546     break;
547     }
548     }
549    
550    
551     traceray(s) /* trace a single ray */
552     char *s;
553     {
554     char buf[128];
555     int x, y;
556     RAY thisray;
557    
558     if (sscanf(s, "%lf %lf %lf %lf %lf %lf",
559     &thisray.rorg[0], &thisray.rorg[1], &thisray.rorg[2],
560     &thisray.rdir[0], &thisray.rdir[1], &thisray.rdir[2]) != 6) {
561    
562     if (dev->getcur == NULL)
563     return;
564     (*dev->comout)("Pick ray\n");
565     if ((*dev->getcur)(&x, &y) == ABORT)
566     return;
567    
568 greg 1.21 if (viewray(thisray.rorg, thisray.rdir, &ourview,
569     (x+.5)/hresolu, (y+.5)/vresolu) < 0) {
570     error(COMMAND, "not on image");
571     return;
572     }
573    
574 greg 1.1 } else if (normalize(thisray.rdir) == 0.0) {
575     error(COMMAND, "zero ray direction");
576     return;
577     }
578    
579     rayorigin(&thisray, NULL, PRIMARY, 1.0);
580    
581     rayvalue(&thisray);
582    
583     if (thisray.ro == NULL)
584     (*dev->comout)("ray hit nothing");
585     else {
586     sprintf(buf, "ray hit %s %s \"%s\"",
587     objptr(thisray.ro->omod)->oname,
588     ofun[thisray.ro->otype].funame,
589     thisray.ro->oname);
590     (*dev->comout)(buf);
591 greg 1.18 (*dev->comin)(buf, NULL);
592 greg 1.1 if (thisray.rot >= FHUGE)
593     (*dev->comout)("at infinity");
594     else {
595     sprintf(buf, "at (%.6g %.6g %.6g)", thisray.rop[0],
596     thisray.rop[1], thisray.rop[2]);
597     (*dev->comout)(buf);
598     }
599 greg 1.18 (*dev->comin)(buf, NULL);
600 greg 1.1 sprintf(buf, "with value (%.6g %.6g %.6g)",
601     colval(thisray.rcol,RED),
602     colval(thisray.rcol,GRN),
603     colval(thisray.rcol,BLU));
604     (*dev->comout)(buf);
605     }
606 greg 1.18 (*dev->comin)(buf, NULL);
607 greg 1.1 }
608    
609    
610     writepict(s) /* write the picture to a file */
611     char *s;
612     {
613     static char buf[128];
614 greg 1.10 char *fname;
615 greg 1.1 FILE *fp;
616     COLR *scanline;
617     int y;
618    
619     if (sscanf(s, "%s", buf) != 1 && buf[0] == '\0') {
620     error(COMMAND, "no file");
621     return;
622     }
623 greg 1.10 if ((fname = getpath(buf, NULL, 0)) == NULL ||
624 greg 1.1 (fp = fopen(fname, "w")) == NULL) {
625     sprintf(errmsg, "cannot open \"%s\"", buf);
626     error(COMMAND, errmsg);
627     return;
628     }
629     (*dev->comout)("writing \"");
630     (*dev->comout)(fname);
631     (*dev->comout)("\"...\n");
632     /* write header */
633     fputs(progname, fp);
634     fprintview(&ourview, fp);
635 greg 1.11 putc('\n', fp);
636 greg 1.1 if (exposure != 1.0)
637 greg 1.13 fputexpos(exposure, fp);
638 greg 1.15 if (dev->pixaspect != 1.0)
639     fputaspect(dev->pixaspect, fp);
640 greg 1.22 fputformat(COLRFMT, fp);
641 greg 1.11 putc('\n', fp);
642 greg 1.14 fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp);
643 greg 1.1
644 greg 1.14 scanline = (COLR *)malloc(hresolu*sizeof(COLR));
645 greg 1.1 if (scanline == NULL)
646     error(SYSTEM, "out of memory in writepict");
647 greg 1.14 for (y = vresolu-1; y >= 0; y--) {
648     getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu);
649     if (fwritecolrs(scanline, hresolu, fp) < 0)
650 greg 1.1 break;
651     }
652     if (fclose(fp) < 0)
653     error(COMMAND, "write error");
654     free((char *)scanline);
655     }