1 |
< |
/* Copyright (c) 1987 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
18 |
|
|
19 |
|
#include "rpaint.h" |
20 |
|
|
21 |
+ |
#include "resolu.h" |
22 |
+ |
|
23 |
|
#include <ctype.h> |
24 |
|
|
25 |
< |
#define CTRL(c) ('c'-'@') |
25 |
> |
#define CTRL(c) ((c)-'@') |
26 |
|
|
27 |
+ |
#ifdef SMLFLT |
28 |
+ |
#define sscanvec(s,v) (sscanf(s,"%f %f %f",v,v+1,v+2)==3) |
29 |
+ |
#else |
30 |
+ |
#define sscanvec(s,v) (sscanf(s,"%lf %lf %lf",v,v+1,v+2)==3) |
31 |
+ |
#endif |
32 |
+ |
|
33 |
+ |
|
34 |
+ |
extern char VersionID[]; |
35 |
|
extern char *progname; |
36 |
+ |
extern char *octname; |
37 |
|
|
38 |
|
|
39 |
|
getframe(s) /* get a new frame */ |
65 |
|
int change = 0; |
66 |
|
VIEW nv; |
67 |
|
|
68 |
+ |
while (isspace(*s)) |
69 |
+ |
s++; |
70 |
+ |
if (*s == '-') { /* command line parameters */ |
71 |
+ |
copystruct(&nv, &ourview); |
72 |
+ |
if (sscanview(&nv, s)) |
73 |
+ |
newview(&nv); |
74 |
+ |
else |
75 |
+ |
error(COMMAND, "bad view option(s)"); |
76 |
+ |
return; |
77 |
+ |
} |
78 |
|
if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ |
79 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
80 |
|
(fp = fopen(fname, "a")) == NULL) { |
92 |
|
sprintf(buf, "view type (%c): ", ourview.type); |
93 |
|
(*dev->comout)(buf); |
94 |
|
(*dev->comin)(buf, NULL); |
95 |
< |
if (buf[0] == CTRL(C)) return; |
95 |
> |
if (buf[0] == CTRL('C')) return; |
96 |
|
if (buf[0] && buf[0] != ourview.type) { |
97 |
|
nv.type = buf[0]; |
98 |
|
change++; |
102 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
103 |
|
(*dev->comout)(buf); |
104 |
|
(*dev->comin)(buf, NULL); |
105 |
< |
if (buf[0] == CTRL(C)) return; |
106 |
< |
if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3) |
105 |
> |
if (buf[0] == CTRL('C')) return; |
106 |
> |
if (sscanvec(buf, nv.vp)) |
107 |
|
change++; |
108 |
|
else |
109 |
|
VCOPY(nv.vp, ourview.vp); |
111 |
|
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
112 |
|
(*dev->comout)(buf); |
113 |
|
(*dev->comin)(buf, NULL); |
114 |
< |
if (buf[0] == CTRL(C)) return; |
115 |
< |
if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3) |
114 |
> |
if (buf[0] == CTRL('C')) return; |
115 |
> |
if (sscanvec(buf, nv.vdir)) |
116 |
|
change++; |
117 |
|
else |
118 |
|
VCOPY(nv.vdir, ourview.vdir); |
120 |
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
121 |
|
(*dev->comout)(buf); |
122 |
|
(*dev->comin)(buf, NULL); |
123 |
< |
if (buf[0] == CTRL(C)) return; |
124 |
< |
if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3) |
123 |
> |
if (buf[0] == CTRL('C')) return; |
124 |
> |
if (sscanvec(buf, nv.vup)) |
125 |
|
change++; |
126 |
|
else |
127 |
|
VCOPY(nv.vup, ourview.vup); |
129 |
|
ourview.horiz, ourview.vert); |
130 |
|
(*dev->comout)(buf); |
131 |
|
(*dev->comin)(buf, NULL); |
132 |
< |
if (buf[0] == CTRL(C)) return; |
132 |
> |
if (buf[0] == CTRL('C')) return; |
133 |
|
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) |
134 |
|
change++; |
135 |
|
else { |
139 |
|
ourview.hoff, ourview.voff); |
140 |
|
(*dev->comout)(buf); |
141 |
|
(*dev->comin)(buf, NULL); |
142 |
< |
if (buf[0] == CTRL(C)) return; |
142 |
> |
if (buf[0] == CTRL('C')) return; |
143 |
|
if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) |
144 |
|
change++; |
145 |
|
else { |
161 |
|
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
162 |
|
copystruct(&nv, &stdview); |
163 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
164 |
< |
(success = viewfile(fname, &nv, 0, 0)) == -1) { |
164 |
> |
(success = viewfile(fname, &nv, NULL)) == -1) { |
165 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
166 |
|
error(COMMAND, errmsg); |
167 |
|
return; |
186 |
|
getaim(s) /* aim camera */ |
187 |
|
char *s; |
188 |
|
{ |
168 |
– |
extern double tan(), atan(); |
189 |
|
double zfact; |
190 |
|
VIEW nv; |
191 |
|
|
216 |
|
getrotate(s) /* rotate camera */ |
217 |
|
char *s; |
218 |
|
{ |
199 |
– |
extern double normalize(), tan(), atan(); |
219 |
|
VIEW nv; |
220 |
|
FVECT v1; |
221 |
|
double angle, elev, zfact; |
261 |
|
getexposure(s) /* get new exposure */ |
262 |
|
char *s; |
263 |
|
{ |
245 |
– |
double atof(), pow(), fabs(); |
264 |
|
char buf[128]; |
265 |
|
register char *cp; |
266 |
|
register PNODE *p; |
305 |
|
e *= atof(cp); |
306 |
|
} |
307 |
|
if (p != NULL) { /* relative setting */ |
308 |
< |
if (bright(p->v) <= FTINY) { |
308 |
> |
if (bright(p->v) < 1e-25) { |
309 |
|
error(COMMAND, "cannot normalize to zero"); |
310 |
|
return; |
311 |
|
} |
319 |
|
} |
320 |
|
|
321 |
|
|
322 |
+ |
getparam(str, dsc, typ, ptr) /* get variable from user */ |
323 |
+ |
char *str, *dsc; |
324 |
+ |
int typ; |
325 |
+ |
register union {int i; double d; COLOR C;} *ptr; |
326 |
+ |
{ |
327 |
+ |
extern char *index(); |
328 |
+ |
int i0; |
329 |
+ |
double d0, d1, d2; |
330 |
+ |
char buf[48]; |
331 |
+ |
|
332 |
+ |
switch (typ) { |
333 |
+ |
case 'i': /* integer */ |
334 |
+ |
if (sscanf(str, "%d", &i0) != 1) { |
335 |
+ |
(*dev->comout)(dsc); |
336 |
+ |
sprintf(buf, " (%d): ", ptr->i); |
337 |
+ |
(*dev->comout)(buf); |
338 |
+ |
(*dev->comin)(buf, NULL); |
339 |
+ |
if (sscanf(buf, "%d", &i0) != 1) |
340 |
+ |
return(0); |
341 |
+ |
} |
342 |
+ |
ptr->i = i0; |
343 |
+ |
return(1); |
344 |
+ |
case 'r': /* real */ |
345 |
+ |
if (sscanf(str, "%lf", &d0) != 1) { |
346 |
+ |
(*dev->comout)(dsc); |
347 |
+ |
sprintf(buf, " (%.6g): ", ptr->d); |
348 |
+ |
(*dev->comout)(buf); |
349 |
+ |
(*dev->comin)(buf, NULL); |
350 |
+ |
if (sscanf(buf, "%lf", &d0) != 1) |
351 |
+ |
return(0); |
352 |
+ |
} |
353 |
+ |
ptr->d = d0; |
354 |
+ |
return(1); |
355 |
+ |
case 'b': /* boolean */ |
356 |
+ |
if (sscanf(str, "%1s", buf) != 1) { |
357 |
+ |
(*dev->comout)(dsc); |
358 |
+ |
sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n'); |
359 |
+ |
(*dev->comout)(buf); |
360 |
+ |
(*dev->comin)(buf, NULL); |
361 |
+ |
if (buf[0] == '\0' || |
362 |
+ |
index("yY+1tTnN-0fF", buf[0]) == NULL) |
363 |
+ |
return(0); |
364 |
+ |
} |
365 |
+ |
ptr->i = index("yY+1tT", buf[0]) != NULL; |
366 |
+ |
return(1); |
367 |
+ |
case 'C': /* color */ |
368 |
+ |
if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) { |
369 |
+ |
(*dev->comout)(dsc); |
370 |
+ |
sprintf(buf, " (%.6g %.6g %.6g): ", |
371 |
+ |
colval(ptr->C,RED), |
372 |
+ |
colval(ptr->C,GRN), |
373 |
+ |
colval(ptr->C,BLU)); |
374 |
+ |
(*dev->comout)(buf); |
375 |
+ |
(*dev->comin)(buf, NULL); |
376 |
+ |
if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3) |
377 |
+ |
return(0); |
378 |
+ |
} |
379 |
+ |
setcolor(ptr->C, d0, d1, d2); |
380 |
+ |
return(1); |
381 |
+ |
} |
382 |
+ |
} |
383 |
+ |
|
384 |
+ |
|
385 |
|
setparam(s) /* get/set program parameter */ |
386 |
|
register char *s; |
387 |
|
{ |
394 |
|
extern double shadcert; |
395 |
|
extern COLOR ambval; |
396 |
|
extern double ambacc; |
316 |
– |
extern double minarad; |
397 |
|
extern int ambres; |
398 |
|
extern int ambdiv; |
399 |
|
extern int ambssamp; |
400 |
|
extern int ambounce; |
401 |
< |
int i0; |
402 |
< |
double d0, d1, d2; |
401 |
> |
extern int directinvis; |
402 |
> |
extern double srcsizerat; |
403 |
> |
extern int do_irrad; |
404 |
> |
extern double specjitter; |
405 |
> |
extern double specthresh; |
406 |
|
char buf[128]; |
407 |
|
|
408 |
|
if (s[0] == '\0') { |
409 |
< |
(*dev->comout)("aa ab ad ar as av dc dj dt lr lw sp st: "); |
409 |
> |
(*dev->comout)( |
410 |
> |
"aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st: "); |
411 |
|
(*dev->comin)(buf, NULL); |
412 |
|
s = buf; |
413 |
|
} |
415 |
|
case 'l': /* limit */ |
416 |
|
switch (s[1]) { |
417 |
|
case 'w': /* weight */ |
418 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
335 |
< |
sprintf(buf, "limit weight (%.6g): ", |
336 |
< |
minweight); |
337 |
< |
(*dev->comout)(buf); |
338 |
< |
(*dev->comin)(buf, NULL); |
339 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
340 |
< |
break; |
341 |
< |
} |
342 |
< |
minweight = d0; |
418 |
> |
getparam(s+2, "limit weight", 'r', &minweight); |
419 |
|
break; |
420 |
|
case 'r': /* reflection */ |
421 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
346 |
< |
sprintf(buf, "limit reflection (%d): ", |
347 |
< |
maxdepth); |
348 |
< |
(*dev->comout)(buf); |
349 |
< |
(*dev->comin)(buf, NULL); |
350 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
351 |
< |
break; |
352 |
< |
} |
353 |
< |
maxdepth = i0; |
421 |
> |
getparam(s+2, "limit reflection", 'i', &maxdepth); |
422 |
|
break; |
423 |
|
default: |
424 |
|
goto badparam; |
427 |
|
case 'd': /* direct */ |
428 |
|
switch (s[1]) { |
429 |
|
case 'j': /* jitter */ |
430 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
363 |
< |
sprintf(buf, "direct jitter (%.6g): ", |
364 |
< |
dstrsrc); |
365 |
< |
(*dev->comout)(buf); |
366 |
< |
(*dev->comin)(buf, NULL); |
367 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
368 |
< |
break; |
369 |
< |
} |
370 |
< |
dstrsrc = d0; |
430 |
> |
getparam(s+2, "direct jitter", 'r', &dstrsrc); |
431 |
|
break; |
432 |
|
case 'c': /* certainty */ |
433 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
374 |
< |
sprintf(buf, "direct certainty (%.6g): ", |
375 |
< |
shadcert); |
376 |
< |
(*dev->comout)(buf); |
377 |
< |
(*dev->comin)(buf, NULL); |
378 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
379 |
< |
break; |
380 |
< |
} |
381 |
< |
shadcert = d0; |
433 |
> |
getparam(s+2, "direct certainty", 'r', &shadcert); |
434 |
|
break; |
435 |
|
case 't': /* threshold */ |
436 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
385 |
< |
sprintf(buf, "direct threshold (%.6g): ", |
386 |
< |
shadthresh); |
387 |
< |
(*dev->comout)(buf); |
388 |
< |
(*dev->comin)(buf, NULL); |
389 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
390 |
< |
break; |
391 |
< |
} |
392 |
< |
shadthresh = d0; |
436 |
> |
getparam(s+2, "direct threshold", 'r', &shadthresh); |
437 |
|
break; |
438 |
+ |
case 'i': /* invisibility */ |
439 |
+ |
getparam(s+2, "direct invisibility", |
440 |
+ |
'b', &directinvis); |
441 |
+ |
break; |
442 |
+ |
case 's': /* sampling */ |
443 |
+ |
getparam(s+2, "direct sampling", 'r', &srcsizerat); |
444 |
+ |
break; |
445 |
|
default: |
446 |
|
goto badparam; |
447 |
|
} |
448 |
|
break; |
449 |
+ |
case 'b': /* black and white */ |
450 |
+ |
getparam(s+1, "black and white", 'b', &greyscale); |
451 |
+ |
break; |
452 |
+ |
case 'i': /* irradiance */ |
453 |
+ |
getparam(s+1, "irradiance", 'b', &do_irrad); |
454 |
+ |
break; |
455 |
|
case 'a': /* ambient */ |
456 |
|
switch (s[1]) { |
457 |
|
case 'v': /* value */ |
458 |
< |
if (sscanf(s+2, "%lf %lf %lf", &d0, &d1, &d2) != 3) { |
402 |
< |
sprintf(buf, |
403 |
< |
"ambient value (%.6g %.6g %.6g): ", |
404 |
< |
colval(ambval,RED), |
405 |
< |
colval(ambval,GRN), |
406 |
< |
colval(ambval,BLU)); |
407 |
< |
(*dev->comout)(buf); |
408 |
< |
(*dev->comin)(buf, NULL); |
409 |
< |
if (sscanf(buf, "%lf %lf %lf", |
410 |
< |
&d0, &d1, &d2) != 3) |
411 |
< |
break; |
412 |
< |
} |
413 |
< |
setcolor(ambval, d0, d1, d2); |
458 |
> |
getparam(s+2, "ambient value", 'C', (COLOR *)ambval); |
459 |
|
break; |
460 |
|
case 'a': /* accuracy */ |
461 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
417 |
< |
sprintf(buf, "ambient accuracy (%.6g): ", |
418 |
< |
ambacc); |
419 |
< |
(*dev->comout)(buf); |
420 |
< |
(*dev->comin)(buf, NULL); |
421 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
422 |
< |
break; |
423 |
< |
} |
424 |
< |
ambacc = d0; |
461 |
> |
getparam(s+2, "ambient accuracy", 'r', &ambacc); |
462 |
|
break; |
463 |
|
case 'd': /* divisions */ |
464 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
428 |
< |
sprintf(buf, "ambient divisions (%d): ", |
429 |
< |
ambdiv); |
430 |
< |
(*dev->comout)(buf); |
431 |
< |
(*dev->comin)(buf, NULL); |
432 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
433 |
< |
break; |
434 |
< |
} |
435 |
< |
ambdiv = i0; |
464 |
> |
getparam(s+2, "ambient divisions", 'i', &ambdiv); |
465 |
|
break; |
466 |
|
case 's': /* samples */ |
467 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
439 |
< |
sprintf(buf, "ambient super-samples (%d): ", |
440 |
< |
ambssamp); |
441 |
< |
(*dev->comout)(buf); |
442 |
< |
(*dev->comin)(buf, NULL); |
443 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
444 |
< |
break; |
445 |
< |
} |
446 |
< |
ambssamp = i0; |
467 |
> |
getparam(s+2, "ambient super-samples", 'i', &ambssamp); |
468 |
|
break; |
469 |
|
case 'b': /* bounces */ |
470 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
450 |
< |
sprintf(buf, "ambient bounces (%d): ", |
451 |
< |
ambounce); |
452 |
< |
(*dev->comout)(buf); |
453 |
< |
(*dev->comin)(buf, NULL); |
454 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
455 |
< |
break; |
456 |
< |
} |
457 |
< |
ambounce = i0; |
470 |
> |
getparam(s+2, "ambient bounces", 'i', &ambounce); |
471 |
|
break; |
472 |
|
case 'r': |
473 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
474 |
< |
sprintf(buf, "ambient resolution (%d): ", |
462 |
< |
ambres); |
463 |
< |
(*dev->comout)(buf); |
464 |
< |
(*dev->comin)(buf, NULL); |
465 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
466 |
< |
break; |
467 |
< |
} |
468 |
< |
ambres = i0; |
469 |
< |
minarad = ambres > 0 ? thescene.cusize/ambres : 0.0; |
473 |
> |
if (getparam(s+2, "ambient resolution", 'i', &ambres)) |
474 |
> |
setambres(ambres); |
475 |
|
break; |
476 |
|
default: |
477 |
|
goto badparam; |
478 |
|
} |
479 |
|
break; |
480 |
< |
case 's': /* sample */ |
480 |
> |
case 'p': /* pixel */ |
481 |
|
switch (s[1]) { |
482 |
< |
case 'p': /* pixel */ |
483 |
< |
if (sscanf(s+2, "%d", &i0) != 1) { |
484 |
< |
sprintf(buf, "sample pixel (%d): ", psample); |
480 |
< |
(*dev->comout)(buf); |
481 |
< |
(*dev->comin)(buf, NULL); |
482 |
< |
if (sscanf(buf, "%d", &i0) != 1) |
483 |
< |
break; |
484 |
< |
} |
485 |
< |
psample = i0; |
486 |
< |
pdepth = 0; |
482 |
> |
case 's': /* sample */ |
483 |
> |
if (getparam(s+2, "pixel sample", 'i', &psample)) |
484 |
> |
pdepth = 0; |
485 |
|
break; |
486 |
|
case 't': /* threshold */ |
487 |
< |
if (sscanf(s+2, "%lf", &d0) != 1) { |
488 |
< |
sprintf(buf, "sample threshold (%.6g): ", |
491 |
< |
maxdiff); |
492 |
< |
(*dev->comout)(buf); |
493 |
< |
(*dev->comin)(buf, NULL); |
494 |
< |
if (sscanf(buf, "%lf", &d0) != 1) |
495 |
< |
break; |
496 |
< |
} |
497 |
< |
maxdiff = d0; |
498 |
< |
pdepth = 0; |
487 |
> |
if (getparam(s+2, "pixel threshold", 'r', &maxdiff)) |
488 |
> |
pdepth = 0; |
489 |
|
break; |
490 |
|
default: |
491 |
|
goto badparam; |
492 |
|
} |
493 |
|
break; |
494 |
+ |
case 's': /* specular */ |
495 |
+ |
switch (s[1]) { |
496 |
+ |
case 'j': /* jitter */ |
497 |
+ |
getparam(s+2, "specular jitter", 'r', &specjitter); |
498 |
+ |
break; |
499 |
+ |
case 't': /* threshold */ |
500 |
+ |
getparam(s+2, "specular threshold", 'r', &specthresh); |
501 |
+ |
break; |
502 |
+ |
default: |
503 |
+ |
goto badparam; |
504 |
+ |
} |
505 |
+ |
break; |
506 |
|
case '\0': /* nothing */ |
507 |
|
break; |
508 |
|
default:; |
509 |
|
badparam: |
510 |
+ |
*sskip(s) = '\0'; |
511 |
|
sprintf(errmsg, "%s: unknown variable", s); |
512 |
|
error(COMMAND, errmsg); |
513 |
|
break; |
522 |
|
int x, y; |
523 |
|
RAY thisray; |
524 |
|
|
525 |
< |
if (sscanf(s, "%lf %lf %lf %lf %lf %lf", |
526 |
< |
&thisray.rorg[0], &thisray.rorg[1], &thisray.rorg[2], |
524 |
< |
&thisray.rdir[0], &thisray.rdir[1], &thisray.rdir[2]) != 6) { |
525 |
> |
if (!sscanvec(s, thisray.rorg) || |
526 |
> |
!sscanvec(sskip(sskip(sskip(s))), thisray.rdir)) { |
527 |
|
|
528 |
|
if (dev->getcur == NULL) |
529 |
|
return; |
563 |
|
(*dev->comout)(buf); |
564 |
|
} |
565 |
|
(*dev->comin)(buf, NULL); |
566 |
< |
sprintf(buf, "with value (%.6g %.6g %.6g)", |
566 |
> |
sprintf(buf, "value (%.5g %.5g %.5g) (%.1fL)", |
567 |
|
colval(thisray.rcol,RED), |
568 |
|
colval(thisray.rcol,GRN), |
569 |
< |
colval(thisray.rcol,BLU)); |
569 |
> |
colval(thisray.rcol,BLU), |
570 |
> |
luminance(thisray.rcol)); |
571 |
|
(*dev->comout)(buf); |
572 |
|
} |
573 |
|
(*dev->comin)(buf, NULL); |
593 |
|
error(COMMAND, errmsg); |
594 |
|
return; |
595 |
|
} |
596 |
+ |
#ifdef MSDOS |
597 |
+ |
setmode(fileno(fp), O_BINARY); |
598 |
+ |
#endif |
599 |
|
(*dev->comout)("writing \""); |
600 |
|
(*dev->comout)(fname); |
601 |
|
(*dev->comout)("\"...\n"); |
602 |
|
/* write header */ |
603 |
|
fputs(progname, fp); |
604 |
|
fprintview(&ourview, fp); |
605 |
< |
putc('\n', fp); |
605 |
> |
if (octname != NULL) |
606 |
> |
fprintf(fp, " %s\n", octname); |
607 |
> |
else |
608 |
> |
putc('\n', fp); |
609 |
> |
fprintf(fp, "SOFTWARE= %s\n", VersionID); |
610 |
|
if (exposure != 1.0) |
611 |
|
fputexpos(exposure, fp); |
612 |
|
if (dev->pixaspect != 1.0) |
613 |
|
fputaspect(dev->pixaspect, fp); |
614 |
+ |
fputformat(COLRFMT, fp); |
615 |
|
putc('\n', fp); |
616 |
< |
fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp); |
616 |
> |
fprtresolu(hresolu, vresolu, fp); |
617 |
|
|
618 |
|
scanline = (COLR *)malloc(hresolu*sizeof(COLR)); |
619 |
< |
if (scanline == NULL) |
620 |
< |
error(SYSTEM, "out of memory in writepict"); |
619 |
> |
if (scanline == NULL) { |
620 |
> |
error(COMMAND, "not enough memory!"); |
621 |
> |
fclose(fp); |
622 |
> |
unlink(fname); |
623 |
> |
return; |
624 |
> |
} |
625 |
|
for (y = vresolu-1; y >= 0; y--) { |
626 |
|
getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu); |
627 |
|
if (fwritecolrs(scanline, hresolu, fp) < 0) |
628 |
|
break; |
629 |
|
} |
630 |
+ |
free((char *)scanline); |
631 |
|
if (fclose(fp) < 0) |
632 |
|
error(COMMAND, "write error"); |
617 |
– |
free((char *)scanline); |
633 |
|
} |