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.15 by greg, Tue Feb 25 16:22:05 2003 UTC vs.
Revision 2.16 by greg, Tue Feb 25 16:47:23 2003 UTC

# Line 1 | Line 1
1   #ifndef lint
2 < static const char       RCSid[] = "$Id$";
2 > static const char RCSid[] = "$Id$";
3   #endif
4   /*
5   *  pvalue.c - program to print pixel values.
# Line 44 | Line 44 | int  header = 1;               /* do header? */
44  
45   long  skipbytes = 0;            /* skip bytes in input? */
46  
47 + int  swapbytes = 0;             /* swap bytes in 16-bit words? */
48 +
49   int  interleave = 1;            /* file is interleaved? */
50  
51   int  resolution = 1;            /* put/get resolution string? */
# Line 169 | Line 171 | char  **argv;
171                                          format = 'b';
172                                          fmtid = "byte";
173                                          break;
174 +                                case 'W':               /* 16-bit swapped */
175 +                                        swapbytes = 1;
176                                  case 'w':               /* 16-bit */
177                                          dataonly = 1;
178                                          format = 'w';
# Line 509 | Line 513 | int  code;
513   }
514  
515  
516 + swap16(wp, n)           /* swap n 16-bit words */
517 + register uint16  *wp;
518 + int  n;
519 + {
520 +        while (n-- > 0) {
521 +                *wp = *wp << 8 | ((*wp >> 8) & 0xff);
522 +                wp++;
523 +        }
524 + }
525 +
526   getcascii(col)          /* get an ascii color value from stream(s) */
527   COLOR  col;
528   {
# Line 620 | Line 634 | COLOR  col;
634                          fread((char *)(vw+2), sizeof(uint16), 1, fin3) != 1)
635                          return(-1);
636          }
637 +        if (swapbytes)
638 +                swap16(vw, 3);
639          setcolor(col, (vw[rord[RED]]+.5)/65536.,
640                          (vw[rord[GRN]]+.5)/65536., (vw[rord[BLU]]+.5)/65536.);
641          return(0);
# Line 698 | Line 714 | COLOR  col;
714  
715          if (fread((char *)&vw, sizeof(uint16), 1, fin) != 1)
716                  return(-1);
717 +        if (swapbytes)
718 +                swap16(&vw, 1);
719          d = (vw+.5)/65536.;
720          setcolor(col, d, d, d);
721          return(0);
# Line 786 | Line 804 | COLOR  col;
804          vw[1] = min(i,65535);
805          i = colval(col,ord[2])*65536.;
806          vw[2] = min(i,65535);
807 +        if (swapbytes)
808 +                swap16(vw, 3);
809          fwrite((char *)vw, sizeof(uint16), 3, stdout);
810  
811          return(ferror(stdout) ? -1 : 0);
# Line 856 | Line 876 | COLOR  col;
876  
877          i = (*mybright)(col)*65536.;
878          vw = min(i,65535);
879 +        if (swapbytes)
880 +                swap16(&vw, 1);
881          fwrite((char *)&vw, sizeof(uint16), 1, stdout);
882  
883          return(ferror(stdout) ? -1 : 0);
# Line 926 | Line 948 | COLOR  col;
948  
949          i = colval(col,putprim)*65536.;
950          vw = min(i,65535);
951 +        if (swapbytes)
952 +                swap16(&vw, 1);
953          fwrite((char *)&vw, sizeof(uint16), 1, stdout);
954  
955          return(ferror(stdout) ? -1 : 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines