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