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

Comparing ray/src/px/pvalue.c (file contents):
Revision 2.10 by greg, Wed Jan 8 07:43:49 1997 UTC vs.
Revision 2.11 by greg, Wed Jan 8 08:00:23 1997 UTC

# Line 384 | Line 384 | pixtoval()                             /* convert picture to values */
384                                  printf("%7d %7d ", (int)(hv[0]*picres.xr),
385                                                  (int)(hv[1]*picres.yr));
386                          }
387 <                        if ((*putval)(scanln[x], stdout) < 0) {
387 >                        if ((*putval)(scanln[x]) < 0) {
388                                  fprintf(stderr, "%s: write error\n", progname);
389                                  quit(1);
390                          }
# Line 416 | Line 416 | valtopix()                     /* convert values to a pixel file */
416                                          fscanf(fin3, "%*d %*d");
417                                  }
418                          }
419 <                        if ((*getval)(scanln[x], fin, fin2, fin3) < 0) {
419 >                        if ((*getval)(scanln[x]) < 0) {
420                                  fprintf(stderr, "%s: read error\n", progname);
421                                  quit(1);
422                          }
# Line 444 | Line 444 | int  code;
444   }
445  
446  
447 < getcascii(col, f1, f2, f3)      /* get an ascii color value from stream(s) */
447 > getcascii(col)          /* get an ascii color value from stream(s) */
448   COLOR  col;
449 FILE  *f1, *f2, *f3;
449   {
450          double  vd[3];
451  
452 <        if (f2 == NULL) {
453 <                if (fscanf(f1, "%lf %lf %lf", &vd[0], &vd[1], &vd[2]) != 3)
452 >        if (fin2 == NULL) {
453 >                if (fscanf(fin, "%lf %lf %lf", &vd[0], &vd[1], &vd[2]) != 3)
454                          return(-1);
455          } else {
456 <                if (fscanf(f1, "%lf", &vd[0]) != 1 ||
457 <                                fscanf(f2, "%lf", &vd[1]) != 1 ||
458 <                                fscanf(f3, "%lf", &vd[2]) != 1)
456 >                if (fscanf(fin, "%lf", &vd[0]) != 1 ||
457 >                                fscanf(fin2, "%lf", &vd[1]) != 1 ||
458 >                                fscanf(fin3, "%lf", &vd[2]) != 1)
459                          return(-1);
460          }
461          setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]);
# Line 464 | Line 463 | FILE  *f1, *f2, *f3;
463   }
464  
465  
466 < getcdouble(col, f1, f2, f3)     /* get a double color value from stream(s) */
466 > getcdouble(col)         /* get a double color value from stream(s) */
467   COLOR  col;
469 FILE  *f1, *f2, *f3;
468   {
469          double  vd[3];
470  
471 <        if (f2 == NULL) {
472 <                if (fread((char *)vd, sizeof(double), 3, f1) != 3)
471 >        if (fin2 == NULL) {
472 >                if (fread((char *)vd, sizeof(double), 3, fin) != 3)
473                          return(-1);
474          } else {
475 <                if (fread((char *)vd, sizeof(double), 1, f1) != 1 ||
476 <                        fread((char *)(vd+1), sizeof(double), 1, f2) != 1 ||
477 <                        fread((char *)(vd+2), sizeof(double), 1, f3) != 1)
475 >                if (fread((char *)vd, sizeof(double), 1, fin) != 1 ||
476 >                        fread((char *)(vd+1), sizeof(double), 1, fin2) != 1 ||
477 >                        fread((char *)(vd+2), sizeof(double), 1, fin3) != 1)
478                          return(-1);
479          }
480          setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]);
# Line 484 | Line 482 | FILE  *f1, *f2, *f3;
482   }
483  
484  
485 < getcfloat(col, f1, f2, f3)      /* get a float color value from stream(s) */
485 > getcfloat(col)          /* get a float color value from stream(s) */
486   COLOR  col;
489 FILE  *f1, *f2, *f3;
487   {
488          float  vf[3];
489  
490 <        if (f2 == NULL) {
491 <                if (fread((char *)vf, sizeof(float), 3, f1) != 3)
490 >        if (fin2 == NULL) {
491 >                if (fread((char *)vf, sizeof(float), 3, fin) != 3)
492                          return(-1);
493          } else {
494 <                if (fread((char *)vf, sizeof(float), 1, f1) != 1 ||
495 <                        fread((char *)(vf+1), sizeof(float), 1, f2) != 1 ||
496 <                        fread((char *)(vf+2), sizeof(float), 1, f3) != 1)
494 >                if (fread((char *)vf, sizeof(float), 1, fin) != 1 ||
495 >                        fread((char *)(vf+1), sizeof(float), 1, fin2) != 1 ||
496 >                        fread((char *)(vf+2), sizeof(float), 1, fin3) != 1)
497                          return(-1);
498          }
499          setcolor(col, vf[rord[RED]], vf[rord[GRN]], vf[rord[BLU]]);
# Line 504 | Line 501 | FILE  *f1, *f2, *f3;
501   }
502  
503  
504 < getcint(col, f1, f2, f3)        /* get an int color value from stream(s) */
504 > getcint(col)            /* get an int color value from stream(s) */
505   COLOR  col;
509 FILE  *f1, *f2, *f3;
506   {
507          int  vi[3];
508  
509 <        if (f2 == NULL) {
510 <                if (fscanf(f1, "%d %d %d", &vi[0], &vi[1], &vi[2]) != 3)
509 >        if (fin2 == NULL) {
510 >                if (fscanf(fin, "%d %d %d", &vi[0], &vi[1], &vi[2]) != 3)
511                          return(-1);
512          } else {
513 <                if (fscanf(f1, "%d", &vi[0]) != 1 ||
514 <                                fscanf(f2, "%d", &vi[1]) != 1 ||
515 <                                fscanf(f3, "%d", &vi[2]) != 1)
513 >                if (fscanf(fin, "%d", &vi[0]) != 1 ||
514 >                                fscanf(fin2, "%d", &vi[1]) != 1 ||
515 >                                fscanf(fin3, "%d", &vi[2]) != 1)
516                          return(-1);
517          }
518          setcolor(col, (vi[rord[RED]]+.5)/256.,
# Line 525 | Line 521 | FILE  *f1, *f2, *f3;
521   }
522  
523  
524 < getcbyte(col, f1, f2, f3)       /* get a byte color value from stream(s) */
524 > getcbyte(col)           /* get a byte color value from stream(s) */
525   COLOR  col;
530 FILE  *f1, *f2, *f3;
526   {
527          BYTE  vb[3];
528  
529 <        if (f2 == NULL) {
530 <                if (fread((char *)vb, sizeof(BYTE), 3, f1) != 3)
529 >        if (fin2 == NULL) {
530 >                if (fread((char *)vb, sizeof(BYTE), 3, fin) != 3)
531                          return(-1);
532          } else {
533 <                if (fread((char *)vb, sizeof(BYTE), 1, f1) != 1 ||
534 <                        fread((char *)(vb+1), sizeof(BYTE), 1, f2) != 1 ||
535 <                        fread((char *)(vb+2), sizeof(BYTE), 1, f3) != 1)
533 >                if (fread((char *)vb, sizeof(BYTE), 1, fin) != 1 ||
534 >                        fread((char *)(vb+1), sizeof(BYTE), 1, fin2) != 1 ||
535 >                        fread((char *)(vb+2), sizeof(BYTE), 1, fin3) != 1)
536                          return(-1);
537          }
538          setcolor(col, (vb[rord[RED]]+.5)/256.,
# Line 546 | Line 541 | FILE  *f1, *f2, *f3;
541   }
542  
543  
544 < getbascii(col, fp)              /* get an ascii brightness value from fp */
544 > getbascii(col)          /* get an ascii brightness value from fin */
545   COLOR  col;
551 FILE  *fp;
546   {
547          double  vd;
548  
549 <        if (fscanf(fp, "%lf", &vd) != 1)
549 >        if (fscanf(fin, "%lf", &vd) != 1)
550                  return(-1);
551          setcolor(col, vd, vd, vd);
552          return(0);
553   }
554  
555  
556 < getbdouble(col, fp)             /* get a double brightness value from fp */
556 > getbdouble(col)         /* get a double brightness value from fin */
557   COLOR  col;
564 FILE  *fp;
558   {
559          double  vd;
560  
561 <        if (fread((char *)&vd, sizeof(double), 1, fp) != 1)
561 >        if (fread((char *)&vd, sizeof(double), 1, fin) != 1)
562                  return(-1);
563          setcolor(col, vd, vd, vd);
564          return(0);
565   }
566  
567  
568 < getbfloat(col, fp)              /* get a float brightness value from fp */
568 > getbfloat(col)          /* get a float brightness value from fin */
569   COLOR  col;
577 FILE  *fp;
570   {
571          float  vf;
572  
573 <        if (fread((char *)&vf, sizeof(float), 1, fp) != 1)
573 >        if (fread((char *)&vf, sizeof(float), 1, fin) != 1)
574                  return(-1);
575          setcolor(col, vf, vf, vf);
576          return(0);
577   }
578  
579  
580 < getbint(col, fp)                /* get an int brightness value from fp */
580 > getbint(col)            /* get an int brightness value from fin */
581   COLOR  col;
590 FILE  *fp;
582   {
583          int  vi;
584          double  d;
585  
586 <        if (fscanf(fp, "%d", &vi) != 1)
586 >        if (fscanf(fin, "%d", &vi) != 1)
587                  return(-1);
588          d = (vi+.5)/256.;
589          setcolor(col, d, d, d);
# Line 600 | Line 591 | FILE  *fp;
591   }
592  
593  
594 < getbbyte(col, fp)               /* get a byte brightness value from fp */
594 > getbbyte(col)           /* get a byte brightness value from fin */
595   COLOR  col;
605 FILE  *fp;
596   {
597          BYTE  vb;
598          double  d;
599  
600 <        if (fread((char *)&vb, sizeof(BYTE), 1, fp) != 1)
600 >        if (fread((char *)&vb, sizeof(BYTE), 1, fin) != 1)
601                  return(-1);
602          d = (vb+.5)/256.;
603          setcolor(col, d, d, d);
# Line 615 | Line 605 | FILE  *fp;
605   }
606  
607  
608 < putcascii(col, fp)                      /* put an ascii color to fp */
608 > putcascii(col)                  /* put an ascii color to stdout */
609   COLOR  col;
620 FILE  *fp;
610   {
611 <        fprintf(fp, "%15.3e %15.3e %15.3e\n",
611 >        fprintf(stdout, "%15.3e %15.3e %15.3e\n",
612                          colval(col,ord[0]),
613                          colval(col,ord[1]),
614                          colval(col,ord[2]));
615  
616 <        return(ferror(fp) ? -1 : 0);
616 >        return(ferror(stdout) ? -1 : 0);
617   }
618  
619  
620 < putcfloat(col, fp)                      /* put a float color to fp */
620 > putcfloat(col)                  /* put a float color to stdout */
621   COLOR  col;
633 FILE  *fp;
622   {
623          float  vf[3];
624  
625          vf[0] = colval(col,ord[0]);
626          vf[1] = colval(col,ord[1]);
627          vf[2] = colval(col,ord[2]);
628 <        fwrite((char *)vf, sizeof(float), 3, fp);
628 >        fwrite((char *)vf, sizeof(float), 3, stdout);
629  
630 <        return(ferror(fp) ? -1 : 0);
630 >        return(ferror(stdout) ? -1 : 0);
631   }
632  
633  
634 < putcdouble(col, fp)                     /* put a double color to fp */
634 > putcdouble(col)                 /* put a double color to stdout */
635   COLOR  col;
648 FILE  *fp;
636   {
637          double  vd[3];
638  
639          vd[0] = colval(col,ord[0]);
640          vd[1] = colval(col,ord[1]);
641          vd[2] = colval(col,ord[2]);
642 <        fwrite((char *)vd, sizeof(double), 3, fp);
642 >        fwrite((char *)vd, sizeof(double), 3, stdout);
643  
644 <        return(ferror(fp) ? -1 : 0);
644 >        return(ferror(stdout) ? -1 : 0);
645   }
646  
647  
648 < putcint(col, fp)                        /* put an int color to fp */
648 > putcint(col)                    /* put an int color to stdout */
649   COLOR  col;
663 FILE  *fp;
650   {
651 <        fprintf(fp, "%d %d %d\n",
651 >        fprintf(stdout, "%d %d %d\n",
652                          (int)(colval(col,ord[0])*256.),
653                          (int)(colval(col,ord[1])*256.),
654                          (int)(colval(col,ord[2])*256.));
655  
656 <        return(ferror(fp) ? -1 : 0);
656 >        return(ferror(stdout) ? -1 : 0);
657   }
658  
659  
660 < putcbyte(col, fp)                       /* put a byte color to fp */
660 > putcbyte(col)                   /* put a byte color to stdout */
661   COLOR  col;
676 FILE  *fp;
662   {
663          register int  i;
664          BYTE  vb[3];
# Line 684 | Line 669 | FILE  *fp;
669          vb[1] = min(i,255);
670          i = colval(col,ord[2])*256.;
671          vb[2] = min(i,255);
672 <        fwrite((char *)vb, sizeof(BYTE), 3, fp);
672 >        fwrite((char *)vb, sizeof(BYTE), 3, stdout);
673  
674 <        return(ferror(fp) ? -1 : 0);
674 >        return(ferror(stdout) ? -1 : 0);
675   }
676  
677  
678 < putbascii(col, fp)                      /* put an ascii brightness to fp */
678 > putbascii(col)                  /* put an ascii brightness to stdout */
679   COLOR  col;
695 FILE  *fp;
680   {
681 <        fprintf(fp, "%15.3e\n", bright(col));
681 >        fprintf(stdout, "%15.3e\n", bright(col));
682  
683 <        return(ferror(fp) ? -1 : 0);
683 >        return(ferror(stdout) ? -1 : 0);
684   }
685  
686  
687 < putbfloat(col, fp)                      /* put a float brightness to fp */
687 > putbfloat(col)                  /* put a float brightness to stdout */
688   COLOR  col;
705 FILE  *fp;
689   {
690          float  vf;
691  
692          vf = bright(col);
693 <        fwrite((char *)&vf, sizeof(float), 1, fp);
693 >        fwrite((char *)&vf, sizeof(float), 1, stdout);
694  
695 <        return(ferror(fp) ? -1 : 0);
695 >        return(ferror(stdout) ? -1 : 0);
696   }
697  
698  
699 < putbdouble(col, fp)                     /* put a double brightness to fp */
699 > putbdouble(col)                 /* put a double brightness to stdout */
700   COLOR  col;
718 FILE  *fp;
701   {
702          double  vd;
703  
704          vd = bright(col);
705 <        fwrite((char *)&vd, sizeof(double), 1, fp);
705 >        fwrite((char *)&vd, sizeof(double), 1, stdout);
706  
707 <        return(ferror(fp) ? -1 : 0);
707 >        return(ferror(stdout) ? -1 : 0);
708   }
709  
710  
711 < putbint(col, fp)                        /* put an int brightness to fp */
711 > putbint(col)                    /* put an int brightness to stdout */
712   COLOR  col;
731 FILE  *fp;
713   {
714 <        fprintf(fp, "%d\n", (int)(bright(col)*256.));
714 >        fprintf(stdout, "%d\n", (int)(bright(col)*256.));
715  
716 <        return(ferror(fp) ? -1 : 0);
716 >        return(ferror(stdout) ? -1 : 0);
717   }
718  
719  
720 < putbbyte(col, fp)                       /* put a byte brightness to fp */
720 > putbbyte(col)                   /* put a byte brightness to stdout */
721   COLOR  col;
741 FILE  *fp;
722   {
723          register int  i;
724          BYTE  vb;
725  
726          i = bright(col)*256.;
727          vb = min(i,255);
728 <        fwrite((char *)&vb, sizeof(BYTE), 1, fp);
728 >        fwrite((char *)&vb, sizeof(BYTE), 1, stdout);
729  
730 <        return(ferror(fp) ? -1 : 0);
730 >        return(ferror(stdout) ? -1 : 0);
731   }
732  
733  
734 < putpascii(col, fp)                      /* put an ascii primary to fp */
734 > putpascii(col)                  /* put an ascii primary to stdout */
735   COLOR  col;
756 FILE  *fp;
736   {
737 <        fprintf(fp, "%15.3e\n", colval(col,putprim));
737 >        fprintf(stdout, "%15.3e\n", colval(col,putprim));
738  
739 <        return(ferror(fp) ? -1 : 0);
739 >        return(ferror(stdout) ? -1 : 0);
740   }
741  
742  
743 < putpfloat(col, fp)                      /* put a float primary to fp */
743 > putpfloat(col)                  /* put a float primary to stdout */
744   COLOR  col;
766 FILE  *fp;
745   {
746          float  vf;
747  
748          vf = colval(col,putprim);
749 <        fwrite((char *)&vf, sizeof(float), 1, fp);
749 >        fwrite((char *)&vf, sizeof(float), 1, stdout);
750  
751 <        return(ferror(fp) ? -1 : 0);
751 >        return(ferror(stdout) ? -1 : 0);
752   }
753  
754  
755 < putpdouble(col, fp)                     /* put a double primary to fp */
755 > putpdouble(col)                 /* put a double primary to stdout */
756   COLOR  col;
779 FILE  *fp;
757   {
758          double  vd;
759  
760          vd = colval(col,putprim);
761 <        fwrite((char *)&vd, sizeof(double), 1, fp);
761 >        fwrite((char *)&vd, sizeof(double), 1, stdout);
762  
763 <        return(ferror(fp) ? -1 : 0);
763 >        return(ferror(stdout) ? -1 : 0);
764   }
765  
766  
767 < putpint(col, fp)                        /* put an int primary to fp */
767 > putpint(col)                    /* put an int primary to stdout */
768   COLOR  col;
792 FILE  *fp;
769   {
770 <        fprintf(fp, "%d\n", (int)(colval(col,putprim)*256.));
770 >        fprintf(stdout, "%d\n", (int)(colval(col,putprim)*256.));
771  
772 <        return(ferror(fp) ? -1 : 0);
772 >        return(ferror(stdout) ? -1 : 0);
773   }
774  
775  
776 < putpbyte(col, fp)                       /* put a byte primary to fp */
776 > putpbyte(col)                   /* put a byte primary to stdout */
777   COLOR  col;
802 FILE  *fp;
778   {
779          register int  i;
780          BYTE  vb;
781  
782          i = colval(col,putprim)*256.;
783          vb = min(i,255);
784 <        fwrite((char *)&vb, sizeof(BYTE), 1, fp);
784 >        fwrite((char *)&vb, sizeof(BYTE), 1, stdout);
785  
786 <        return(ferror(fp) ? -1 : 0);
786 >        return(ferror(stdout) ? -1 : 0);
787   }
788  
789  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines