ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rv2.c
(Generate patch)

Comparing ray/src/rt/rv2.c (file contents):
Revision 1.14 by greg, Mon Jan 8 13:38:05 1990 UTC vs.
Revision 2.7 by greg, Tue Feb 18 16:38:51 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1987 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 18 | Line 18 | 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 */
# Line 63 | Line 74 | char  *s;
74                  }
75                  fputs(progname, fp);
76                  fprintview(&ourview, fp);
77 +                fputs(sskip(s), fp);
78                  fputs("\n", fp);
79                  fclose(fp);
80                  return;
81          }
82          sprintf(buf, "view type (%c): ", ourview.type);
83          (*dev->comout)(buf);
84 <        (*dev->comin)(buf);
85 <        if (buf[0] == CTRL(C)) return;
84 >        (*dev->comin)(buf, NULL);
85 >        if (buf[0] == CTRL('C')) return;
86          if (buf[0] && buf[0] != ourview.type) {
87                  nv.type = buf[0];
88                  change++;
# Line 79 | Line 91 | char  *s;
91          sprintf(buf, "view point (%.6g %.6g %.6g): ",
92                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
93          (*dev->comout)(buf);
94 <        (*dev->comin)(buf);
95 <        if (buf[0] == CTRL(C)) return;
96 <        if (sscanf(buf, "%lf %lf %lf", &nv.vp[0], &nv.vp[1], &nv.vp[2]) == 3)
94 >        (*dev->comin)(buf, NULL);
95 >        if (buf[0] == CTRL('C')) return;
96 >        if (sscanvec(buf, nv.vp))
97                  change++;
98          else
99                  VCOPY(nv.vp, ourview.vp);
100          sprintf(buf, "view direction (%.6g %.6g %.6g): ",
101                          ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]);
102          (*dev->comout)(buf);
103 <        (*dev->comin)(buf);
104 <        if (buf[0] == CTRL(C)) return;
105 <        if (sscanf(buf,"%lf %lf %lf",&nv.vdir[0],&nv.vdir[1],&nv.vdir[2]) == 3)
103 >        (*dev->comin)(buf, NULL);
104 >        if (buf[0] == CTRL('C')) return;
105 >        if (sscanvec(buf, nv.vdir))
106                  change++;
107          else
108                  VCOPY(nv.vdir, ourview.vdir);
109          sprintf(buf, "view up (%.6g %.6g %.6g): ",
110                          ourview.vup[0], ourview.vup[1], ourview.vup[2]);
111          (*dev->comout)(buf);
112 <        (*dev->comin)(buf);
113 <        if (buf[0] == CTRL(C)) return;
114 <        if (sscanf(buf,"%lf %lf %lf",&nv.vup[0],&nv.vup[1],&nv.vup[2]) == 3)
112 >        (*dev->comin)(buf, NULL);
113 >        if (buf[0] == CTRL('C')) return;
114 >        if (sscanvec(buf, nv.vup))
115                  change++;
116          else
117                  VCOPY(nv.vup, ourview.vup);
118          sprintf(buf, "view horiz and vert size (%.6g %.6g): ",
119                          ourview.horiz, ourview.vert);
120          (*dev->comout)(buf);
121 <        (*dev->comin)(buf);
122 <        if (buf[0] == CTRL(C)) return;
121 >        (*dev->comin)(buf, NULL);
122 >        if (buf[0] == CTRL('C')) return;
123          if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2)
124                  change++;
125          else {
# Line 116 | Line 128 | char  *s;
128          sprintf(buf, "view shift and lift (%.6g %.6g): ",
129                          ourview.hoff, ourview.voff);
130          (*dev->comout)(buf);
131 <        (*dev->comin)(buf);
132 <        if (buf[0] == CTRL(C)) return;
131 >        (*dev->comin)(buf, NULL);
132 >        if (buf[0] == CTRL('C')) return;
133          if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2)
134                  change++;
135          else {
# Line 137 | Line 149 | char  *s;
149          VIEW  nv;
150  
151          if (sscanf(s, "%s", buf) == 1) {        /* get parameters from a file */
152 <                copyview(&nv, &stdview);
152 >                copystruct(&nv, &stdview);
153                  if ((fname = getpath(buf, NULL, 0)) == NULL ||
154 <                                (success = viewfile(fname, &nv)) == -1) {
154 >                                (success = viewfile(fname, &nv, NULL)) == -1) {
155                          sprintf(errmsg, "cannot open \"%s\"", buf);
156                          error(COMMAND, errmsg);
157                          return;
# Line 150 | Line 162 | char  *s;
162                          newview(&nv);
163                  return;
164          }
165 <        if (oldview.horiz == 0) {       /* no old view! */
165 >        if (oldview.type == 0) {        /* no old view! */
166                  error(COMMAND, "no previous view");
167                  return;
168          }
169 <        copyview(&nv, &ourview);
170 <        copyview(&ourview, &oldview);
171 <        copyview(&oldview, &nv);
169 >        copystruct(&nv, &ourview);
170 >        copystruct(&ourview, &oldview);
171 >        copystruct(&oldview, &nv);
172          newimage();
173   }
174  
# Line 170 | Line 182 | char  *s;
182  
183          if (getinterest(s, 1, nv.vdir, &zfact) < 0)
184                  return;
185 +        nv.type = ourview.type;
186          VCOPY(nv.vp, ourview.vp);
187          VCOPY(nv.vup, ourview.vup);
188          nv.hoff = ourview.hoff; nv.voff = ourview.voff;
189 <        if ((nv.type = ourview.type) == VT_PAR) {
190 <                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 <        }
189 >        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
190 >        zoomview(&nv, zfact);
191          newview(&nv);
192   }
193  
# Line 211 | Line 217 | char  *s;
217                  error(COMMAND, "missing angle");
218                  return;
219          }
220 +        nv.type = ourview.type;
221          VCOPY(nv.vp, ourview.vp);
222          VCOPY(nv.vup, ourview.vup);
223          nv.hoff = ourview.hoff; nv.voff = ourview.voff;
# Line 220 | Line 227 | char  *s;
227                  normalize(v1);
228                  spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.));
229          }
230 <        if ((nv.type = ourview.type) == VT_PAR) {
231 <                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 <        }
230 >        nv.horiz = ourview.horiz; nv.vert = ourview.vert;
231 >        zoomview(&nv, zfact);
232          newview(&nv);
233   }
234  
# Line 253 | Line 253 | register char  *s;
253   getexposure(s)                          /* get new exposure */
254   char  *s;
255   {
256        double  atof(), pow(), fabs();
256          char  buf[128];
257          register char  *cp;
258          register PNODE  *p;
# Line 282 | Line 281 | char  *s;
281                          if (*cp == '\0') {      /* interactive */
282                                  sprintf(buf, "exposure (%lf): ", exposure);
283                                  (*dev->comout)(buf);
284 <                                (*dev->comin)(buf);
284 >                                (*dev->comin)(buf, NULL);
285                                  for (cp = buf; isspace(*cp); cp++)
286                                          ;
287                                  if (*cp == '\0')
# Line 298 | Line 297 | char  *s;
297                          e *= atof(cp);
298          }
299          if (p != NULL) {                /* relative setting */
300 <                if (bright(p->v) <= FTINY) {
300 >                if (bright(p->v) < 1e-25) {
301                          error(COMMAND, "cannot normalize to zero");
302                          return;
303                  }
# Line 312 | Line 311 | char  *s;
311   }
312  
313  
314 + getparam(str, dsc, typ, ptr)            /* get variable from user */
315 + char  *str, *dsc;
316 + int  typ;
317 + register union {int i; double d; COLOR C;}  *ptr;
318 + {
319 +        extern char  *index();
320 +        int  i0;
321 +        double  d0, d1, d2;
322 +        char  buf[48];
323 +
324 +        switch (typ) {
325 +        case 'i':                       /* integer */
326 +                if (sscanf(str, "%d", &i0) != 1) {
327 +                        (*dev->comout)(dsc);
328 +                        sprintf(buf, " (%d): ", ptr->i);
329 +                        (*dev->comout)(buf);
330 +                        (*dev->comin)(buf, NULL);
331 +                        if (sscanf(buf, "%d", &i0) != 1)
332 +                                return(0);
333 +                }
334 +                ptr->i = i0;
335 +                return(1);
336 +        case 'r':                       /* real */
337 +                if (sscanf(str, "%lf", &d0) != 1) {
338 +                        (*dev->comout)(dsc);
339 +                        sprintf(buf, " (%.6g): ", ptr->d);
340 +                        (*dev->comout)(buf);
341 +                        (*dev->comin)(buf, NULL);
342 +                        if (sscanf(buf, "%lf", &d0) != 1)
343 +                                return(0);
344 +                }
345 +                ptr->d = d0;
346 +                return(1);
347 +        case 'b':                       /* boolean */
348 +                if (sscanf(str, "%1s", buf) != 1) {
349 +                        (*dev->comout)(dsc);
350 +                        sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n');
351 +                        (*dev->comout)(buf);
352 +                        (*dev->comin)(buf, NULL);
353 +                        if (buf[0] == '\0' ||
354 +                                        index("yY+1tTnN-0fF", buf[0]) == NULL)
355 +                                return(0);
356 +                }
357 +                ptr->i = index("yY+1tT", buf[0]) != NULL;
358 +                return(1);
359 +        case 'C':                       /* color */
360 +                if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) {
361 +                        (*dev->comout)(dsc);
362 +                        sprintf(buf, " (%.6g %.6g %.6g): ",
363 +                                        colval(ptr->C,RED),
364 +                                        colval(ptr->C,GRN),
365 +                                        colval(ptr->C,BLU));
366 +                        (*dev->comout)(buf);
367 +                        (*dev->comin)(buf, NULL);
368 +                        if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3)
369 +                                return(0);
370 +                }
371 +                setcolor(ptr->C, d0, d1, d2);
372 +                return(1);
373 +        }
374 + }
375 +
376 +
377   setparam(s)                             /* get/set program parameter */
378   register char  *s;
379   {
# Line 329 | Line 391 | register char  *s;
391          extern int  ambdiv;
392          extern int  ambssamp;
393          extern int  ambounce;
394 <        int  i0;
395 <        double  d0, d1, d2;
394 >        extern int  directinvis;
395 >        extern double  srcsizerat;
396 >        extern int  do_irrad;
397 >        extern double  specjitter;
398 >        extern double  specthresh;
399          char  buf[128];
400          
401          if (s[0] == '\0') {
402 <                (*dev->comout)("aa ab ad ar as av dc dj dt lr lw sp st: ");
403 <                (*dev->comin)(buf);
402 >                (*dev->comout)(
403 >                "aa ab ad ar as av b dc di dj ds dt i lr lw ps pt sj st: ");
404 >                (*dev->comin)(buf, NULL);
405                  s = buf;
406          }
407          switch (s[0]) {
408          case 'l':                       /* limit */
409                  switch (s[1]) {
410                  case 'w':                       /* weight */
411 <                        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;
411 >                        getparam(s+2, "limit weight", 'r', &minweight);
412                          break;
413                  case 'r':                       /* reflection */
414 <                        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;
414 >                        getparam(s+2, "limit reflection", 'i', &maxdepth);
415                          break;
416                  default:
417                          goto badparam;
# Line 370 | Line 420 | register char  *s;
420          case 'd':                       /* direct */
421                  switch (s[1]) {
422                  case 'j':                       /* jitter */
423 <                        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;
423 >                        getparam(s+2, "direct jitter", 'r', &dstrsrc);
424                          break;
425                  case 'c':                       /* certainty */
426 <                        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;
426 >                        getparam(s+2, "direct certainty", 'r', &shadcert);
427                          break;
428                  case 't':                       /* threshold */
429 <                        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;
429 >                        getparam(s+2, "direct threshold", 'r', &shadthresh);
430                          break;
431 +                case 'i':                       /* invisibility */
432 +                        getparam(s+2, "direct invisibility",
433 +                                        'b', &directinvis);
434 +                        break;
435 +                case 's':                       /* sampling */
436 +                        getparam(s+2, "direct sampling", 'r', &srcsizerat);
437 +                        break;
438                  default:
439                          goto badparam;
440                  }
441                  break;
442 +        case 'b':                       /* black and white */
443 +                getparam(s+1, "black and white", 'b', &greyscale);
444 +                break;
445 +        case 'i':                       /* irradiance */
446 +                getparam(s+1, "irradiance", 'b', &do_irrad);
447 +                break;
448          case 'a':                       /* ambient */
449                  switch (s[1]) {
450                  case 'v':                       /* value */
451 <                        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);
451 >                        getparam(s+2, "ambient value", 'C', ambval);
452                          break;
453                  case 'a':                       /* accuracy */
454 <                        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;
454 >                        getparam(s+2, "ambient accuracy", 'r', &ambacc);
455                          break;
456                  case 'd':                       /* divisions */
457 <                        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;
457 >                        getparam(s+2, "ambient divisions", 'i', &ambdiv);
458                          break;
459                  case 's':                       /* samples */
460 <                        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;
460 >                        getparam(s+2, "ambient super-samples", 'i', &ambssamp);
461                          break;
462                  case 'b':                       /* bounces */
463 <                        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;
463 >                        getparam(s+2, "ambient bounces", 'i', &ambounce);
464                          break;
465                  case 'r':
466 <                        if (sscanf(s+2, "%d", &i0) != 1) {
467 <                                sprintf(buf, "ambient resolution (%d): ",
468 <                                                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;
466 >                        if (getparam(s+2, "ambient resolution", 'i', &ambres))
467 >                                minarad = ambres > 0 ?
468 >                                                thescene.cusize/ambres : 0.0;
469                          break;
470                  default:
471                          goto badparam;
472                  }
473                  break;
474 <        case 's':                       /* sample */
474 >        case 'p':                       /* pixel */
475                  switch (s[1]) {
476 <                case 'p':                       /* pixel */
477 <                        if (sscanf(s+2, "%d", &i0) != 1) {
478 <                                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;
476 >                case 's':                       /* sample */
477 >                        if (getparam(s+2, "pixel sample", 'i', &psample))
478 >                                pdepth = 0;
479                          break;
480                  case 't':                       /* threshold */
481 <                        if (sscanf(s+2, "%lf", &d0) != 1) {
482 <                                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;
481 >                        if (getparam(s+2, "pixel threshold", 'r', &maxdiff))
482 >                                pdepth = 0;
483                          break;
484                  default:
485                          goto badparam;
486                  }
487                  break;
488 +        case 's':                       /* specular */
489 +                switch (s[1]) {
490 +                case 'j':                       /* jitter */
491 +                        getparam(s+2, "specular jitter", 'r', &specjitter);
492 +                        break;
493 +                case 't':                       /* threshold */
494 +                        getparam(s+2, "specular threshold", 'r', &specthresh);
495 +                        break;
496 +                default:
497 +                        goto badparam;
498 +                }
499 +                break;
500          case '\0':                      /* nothing */
501                  break;
502          default:;
503   badparam:
504 +                *sskip(s) = '\0';
505                  sprintf(errmsg, "%s: unknown variable", s);
506                  error(COMMAND, errmsg);
507                  break;
# Line 530 | Line 516 | char  *s;
516          int  x, y;
517          RAY  thisray;
518  
519 <        if (sscanf(s, "%lf %lf %lf %lf %lf %lf",
520 <                &thisray.rorg[0], &thisray.rorg[1], &thisray.rorg[2],
535 <                &thisray.rdir[0], &thisray.rdir[1], &thisray.rdir[2]) != 6) {
519 >        if (!sscanvec(s, thisray.rorg) ||
520 >                        !sscanvec(sskip(sskip(sskip(s))), thisray.rdir)) {
521  
522                  if (dev->getcur == NULL)
523                          return;
# Line 540 | Line 525 | char  *s;
525                  if ((*dev->getcur)(&x, &y) == ABORT)
526                          return;
527  
528 <                viewray(thisray.rorg, thisray.rdir, &ourview,
529 <                                (x+.5)/hresolu, (y+.5)/vresolu);
530 <                
528 >                if (viewray(thisray.rorg, thisray.rdir, &ourview,
529 >                                (x+.5)/hresolu, (y+.5)/vresolu) < 0) {
530 >                        error(COMMAND, "not on image");
531 >                        return;
532 >                }
533 >
534          } else if (normalize(thisray.rdir) == 0.0) {
535                  error(COMMAND, "zero ray direction");
536                  return;
# Line 560 | Line 548 | char  *s;
548                                  ofun[thisray.ro->otype].funame,
549                                  thisray.ro->oname);
550                  (*dev->comout)(buf);
551 <                (*dev->comin)(buf);
551 >                (*dev->comin)(buf, NULL);
552                  if (thisray.rot >= FHUGE)
553                          (*dev->comout)("at infinity");
554                  else {
# Line 568 | Line 556 | char  *s;
556                                          thisray.rop[1], thisray.rop[2]);
557                          (*dev->comout)(buf);
558                  }
559 <                (*dev->comin)(buf);
560 <                sprintf(buf, "with value (%.6g %.6g %.6g)",
559 >                (*dev->comin)(buf, NULL);
560 >                sprintf(buf, "value (%.5g %.5g %.5g) (%.1fL)",
561                                  colval(thisray.rcol,RED),
562                                  colval(thisray.rcol,GRN),
563 <                                colval(thisray.rcol,BLU));
563 >                                colval(thisray.rcol,BLU),
564 >                                luminance(thisray.rcol));
565                  (*dev->comout)(buf);
566          }
567 <        (*dev->comin)(buf);
567 >        (*dev->comin)(buf, NULL);
568   }
569  
570  
# Line 604 | Line 593 | char  *s;
593                                                  /* write header */
594          fputs(progname, fp);
595          fprintview(&ourview, fp);
596 <        putc('\n', fp);
596 >        if (octname != NULL)
597 >                fprintf(fp, " %s\n", octname);
598 >        else
599 >                putc('\n', fp);
600 >        fprintf(fp, "SOFTWARE= %s\n", VersionID);
601          if (exposure != 1.0)
602                  fputexpos(exposure, fp);
603 +        if (dev->pixaspect != 1.0)
604 +                fputaspect(dev->pixaspect, fp);
605 +        fputformat(COLRFMT, fp);
606          putc('\n', fp);
607 <        fputresolu(YMAJOR|YDECR, hresolu, vresolu, fp);
607 >        fprtresolu(hresolu, vresolu, fp);
608  
609          scanline = (COLR *)malloc(hresolu*sizeof(COLR));
610 <        if (scanline == NULL)
611 <                error(SYSTEM, "out of memory in writepict");
610 >        if (scanline == NULL) {
611 >                error(COMMAND, "not enough memory!");
612 >                fclose(fp);
613 >                unlink(fname);
614 >                return;
615 >        }
616          for (y = vresolu-1; y >= 0; y--) {
617                  getpictcolrs(y, scanline, &ptrunk, hresolu, vresolu);
618                  if (fwritecolrs(scanline, hresolu, fp) < 0)
619                          break;
620          }
621 +        free((char *)scanline);
622          if (fclose(fp) < 0)
623                  error(COMMAND, "write error");
623        free((char *)scanline);
624   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines