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.14 by greg, Sat Feb 22 02:07:27 2003 UTC vs.
Revision 2.29 by greg, Sat Dec 23 17:27:46 2006 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 7 | Line 7 | static const char      RCSid[] = "$Id$";
7   *     4/23/86
8   */
9  
10 + #include  "platform.h"
11   #include  "standard.h"
11
12   #include  "color.h"
13
14 #include  <time.h>
15
13   #include  "resolu.h"
14 + #include  "view.h"
15  
16   #define  min(a,b)               ((a)<(b)?(a):(b))
17  
# Line 21 | Line 19 | static const char      RCSid[] = "$Id$";
19   #define  ALL            3
20   #define  BRIGHT         4
21  
24 #define  brightonly     (putprim==BRIGHT)
25
22   RESOLU  picres;                 /* resolution of picture */
27
23   int  uniq = 0;                  /* print only unique values? */
29
24   int  doexposure = 0;            /* exposure change? (>100 to print) */
31
25   int  dataonly = 0;              /* data only format? */
33
26   int  putprim = ALL;             /* what to put out */
35
27   int  reverse = 0;               /* reverse conversion? */
37
28   int  format = 'a';              /* input/output format */
29   char  *fmtid = "ascii";         /* format identifier for header */
40
30   int  header = 1;                /* do header? */
42
31   long  skipbytes = 0;            /* skip bytes in input? */
32 <
32 > int  swapbytes = 0;             /* swap bytes? */
33   int  interleave = 1;            /* file is interleaved? */
46
34   int  resolution = 1;            /* put/get resolution string? */
48
35   int  original = 0;              /* convert to original values? */
50
36   int  wrongformat = 0;           /* wrong input format? */
52
37   double  gamcor = 1.0;           /* gamma correction */
38  
39   int  ord[3] = {RED, GRN, BLU};  /* RGB ordering */
# Line 62 | Line 46 | char  *progname;
46   FILE  *fin;
47   FILE  *fin2 = NULL, *fin3 = NULL;       /* for other color channels */
48  
65 int  (*getval)(), (*putval)();
49  
50 < double
51 < rgb_bright(clr)
52 < COLOR  clr;
50 > typedef int getfunc_t(COLOR  col);
51 > typedef int putfunc_t(COLOR  col);
52 > typedef double brightfunc_t(COLOR  col);
53 >
54 > getfunc_t *getval;
55 > putfunc_t *putval;
56 > brightfunc_t *mybright;
57 >
58 > static gethfunc checkhead;
59 > static brightfunc_t rgb_bright, xyz_bright;
60 > static getfunc_t getbascii, getbint, getbdouble, getbfloat, getbbyte, getbword;
61 > static getfunc_t getcascii, getcint, getcdouble, getcfloat, getcbyte, getcword;
62 > static putfunc_t putbascii, putbint, putbdouble, putbfloat, putbbyte, putbword;
63 > static putfunc_t putcascii, putcint, putcdouble, putcfloat, putcbyte, putcword;
64 > static putfunc_t putpascii, putpint, putpdouble, putpfloat, putpbyte, putpword;
65 >
66 > static void set_io(void);
67 > static void pixtoval(void);
68 > static void valtopix(void);
69 >
70 >
71 > static double
72 > rgb_bright(
73 >        COLOR  clr
74 > )
75   {
76          return(bright(clr));
77   }
78  
79 < double
80 < xyz_bright(clr)
81 < COLOR  clr;
79 > static double
80 > xyz_bright(
81 >        COLOR  clr
82 > )
83   {
84          return(clr[CIEY]);
85   }
86  
87 < double  (*mybright)() = &rgb_bright;
88 <
89 <
90 < main(argc, argv)
91 < int  argc;
86 < char  **argv;
87 > int
88 > main(
89 >        int  argc,
90 >        char  **argv
91 > )
92   {
88        extern int  checkhead();
89        extern long  atol();
93          double  d, expval = 1.0;
94          int  i;
95  
96          progname = argv[0];
97 +        mybright = &rgb_bright; /* default */
98  
99          for (i = 1; i < argc; i++)
100                  if (argv[i][0] == '-' || argv[i][0] == '+')
# Line 167 | 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';
179 +                                        fmtid = "16-bit";
180 +                                        break;
181 +                                case 'F':               /* swapped floats */
182 +                                        swapbytes = 1;
183                                  case 'f':               /* float */
184                                          dataonly = 1;
185                                          format = 'f';
186                                          fmtid = "float";
187                                          break;
188 +                                case 'D':               /* swapped doubles */
189 +                                        swapbytes = 1;
190                                  case 'd':               /* double */
191                                          dataonly = 1;
192                                          format = 'd';
# Line 207 | Line 222 | unkopt:
222                  else
223                          break;
224                                          /* recognize special formats */
225 <        if (dataonly && format == 'b')
226 <                if (brightonly)
225 >        if (dataonly && format == 'b') {
226 >                if (putprim == ALL)
227 >                        fmtid = "24-bit_rgb";
228 >                else
229                          fmtid = "8-bit_grey";
230 +        }
231 +        if (dataonly && format == 'w') {
232 +                if (putprim == ALL)
233 +                        fmtid = "48-bit_rgb";
234                  else
235 <                        fmtid = "24-bit_rgb";
235 >                        fmtid = "16-bit_grey";
236 >        }
237                                          /* assign reverse ordering */
238          rord[ord[0]] = 0;
239          rord[ord[1]] = 1;
# Line 225 | Line 247 | unkopt:
247                                                  progname, argv[i]);
248                          quit(1);
249                  }
250 <                if (reverse && !brightonly && i == argc-3) {
250 >                if (reverse && putprim != BRIGHT && i == argc-3) {
251                          if ((fin2 = fopen(argv[i+1], "r")) == NULL) {
252                                  fprintf(stderr, "%s: can't open file \"%s\"\n",
253                                                  progname, argv[i+1]);
# Line 239 | Line 261 | unkopt:
261                          interleave = -1;
262                  } else if (i != argc-1)
263                          fin = NULL;
264 <                if (reverse && !brightonly && !interleave) {
264 >                if (reverse && putprim != BRIGHT && !interleave) {
265                          fin2 = fopen(argv[i], "r");
266                          fin3 = fopen(argv[i], "r");
267                  }
# Line 257 | Line 279 | unkopt:
279          }
280  
281          if (reverse) {
282 < #ifdef MSDOS
283 <                setmode(fileno(stdout), O_BINARY);
282 > #ifdef _WIN32
283 >                SET_FILE_BINARY(stdout);
284                  if (format != 'a' && format != 'i')
285 <                        setmode(fileno(fin), O_BINARY);
285 >                        SET_FILE_BINARY(fin);
286   #endif
287                                          /* get header */
288                  if (header) {
# Line 305 | Line 327 | unkopt:
327                  fputsresolu(&picres, stdout);   /* always put resolution */
328                  valtopix();
329          } else {
330 < #ifdef MSDOS
331 <                setmode(fileno(fin), O_BINARY);
330 > #ifdef _WIN32
331 >                SET_FILE_BINARY(fin);
332                  if (format != 'a' && format != 'i')
333 <                        setmode(fileno(stdout), O_BINARY);
333 >                        SET_FILE_BINARY(stdout);
334   #endif
335                                                  /* get header */
336                  getheader(fin, checkhead, NULL);
# Line 335 | Line 357 | unkopt:
357          }
358  
359          quit(0);
360 +        return 0; /* pro forma return */
361   }
362  
363  
364 < int
365 < checkhead(line)                         /* deal with line from header */
366 < char  *line;
364 > static int
365 > checkhead(                              /* deal with line from header */
366 >        char    *line,
367 >        void    *p
368 > )
369   {
370          char    fmt[32];
371          double  d;
372          COLOR   ctmp;
373  
374          if (formatval(fmt, line)) {
375 <                if (!strcmp(fmt, CIEFMT)) {
375 >                if (!strcmp(fmt, CIEFMT))
376                          mybright = &xyz_bright;
377 <                        if (original) {
353 <                                scalecolor(exposure, 1./WHTEFFICACY);
354 <                                doexposure++;
355 <                        }
356 <                } else if (!strcmp(fmt, COLRFMT))
377 >                else if (!strcmp(fmt, COLRFMT))
378                          mybright = &rgb_bright;
379                  else
380                          wrongformat++;
# Line 373 | Line 394 | char  *line;
394   }
395  
396  
397 < pixtoval()                              /* convert picture to values */
397 > static void
398 > pixtoval(void)                          /* convert picture to values */
399   {
400          register COLOR  *scanln;
401          int  dogamma;
402          COLOR  lastc;
403 <        FLOAT  hv[2];
403 >        RREAL  hv[2];
404          int  startprim, endprim;
405          long  startpos;
406          int  y;
# Line 410 | Line 432 | pixtoval()                             /* convert picture to values */
432                                  quit(1);
433                          }
434                          for (x = 0; x < scanlen(&picres); x++) {
435 <                                if (uniq)
435 >                                if (uniq) {
436                                          if (    colval(scanln[x],RED) ==
437                                                          colval(lastc,RED) &&
438                                                  colval(scanln[x],GRN) ==
# Line 420 | Line 442 | pixtoval()                             /* convert picture to values */
442                                                  continue;
443                                          else
444                                                  copycolor(lastc, scanln[x]);
445 +                                }
446                                  if (doexposure)
447                                          multcolor(scanln[x], exposure);
448                                  if (dogamma)
# Line 445 | Line 468 | pixtoval()                             /* convert picture to values */
468   }
469  
470  
471 < valtopix()                      /* convert values to a pixel file */
471 > static void
472 > valtopix(void)                  /* convert values to a pixel file */
473   {
474          int  dogamma;
475          register COLOR  *scanln;
# Line 497 | Line 521 | int  code;
521   }
522  
523  
524 < getcascii(col)          /* get an ascii color value from stream(s) */
525 < COLOR  col;
524 > static int
525 > getcascii(              /* get an ascii color value from stream(s) */
526 >        COLOR  col
527 > )
528   {
529          double  vd[3];
530  
# Line 516 | Line 542 | COLOR  col;
542   }
543  
544  
545 < getcdouble(col)         /* get a double color value from stream(s) */
546 < COLOR  col;
545 > static int
546 > getcdouble(             /* get a double color value from stream(s) */
547 >        COLOR  col
548 > )
549   {
550          double  vd[3];
551  
# Line 530 | Line 558 | COLOR  col;
558                          fread((char *)(vd+2), sizeof(double), 1, fin3) != 1)
559                          return(-1);
560          }
561 +        if (swapbytes)
562 +                swap64((char *)vd, 3);
563          setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]);
564          return(0);
565   }
566  
567  
568 < getcfloat(col)          /* get a float color value from stream(s) */
569 < COLOR  col;
568 > static int
569 > getcfloat(              /* get a float color value from stream(s) */
570 >        COLOR  col
571 > )
572   {
573          float  vf[3];
574  
# Line 549 | Line 581 | COLOR  col;
581                          fread((char *)(vf+2), sizeof(float), 1, fin3) != 1)
582                          return(-1);
583          }
584 +        if (swapbytes)
585 +                swap32((char *)vf, 3);
586          setcolor(col, vf[rord[RED]], vf[rord[GRN]], vf[rord[BLU]]);
587          return(0);
588   }
589  
590  
591 < getcint(col)            /* get an int color value from stream(s) */
592 < COLOR  col;
591 > static int
592 > getcint(                /* get an int color value from stream(s) */
593 >        COLOR  col
594 > )
595   {
596          int  vi[3];
597  
# Line 574 | Line 610 | COLOR  col;
610   }
611  
612  
613 < getcbyte(col)           /* get a byte color value from stream(s) */
614 < COLOR  col;
613 > static int
614 > getcbyte(               /* get a byte color value from stream(s) */
615 >        COLOR  col
616 > )
617   {
618          BYTE  vb[3];
619  
# Line 594 | Line 632 | COLOR  col;
632   }
633  
634  
635 < getbascii(col)          /* get an ascii brightness value from fin */
636 < COLOR  col;
635 > static int
636 > getcword(               /* get a 16-bit color value from stream(s) */
637 >        COLOR  col
638 > )
639   {
640 +        uint16  vw[3];
641 +
642 +        if (fin2 == NULL) {
643 +                if (fread((char *)vw, sizeof(uint16), 3, fin) != 3)
644 +                        return(-1);
645 +        } else {
646 +                if (fread((char *)vw, sizeof(uint16), 1, fin) != 1 ||
647 +                        fread((char *)(vw+1), sizeof(uint16), 1, fin2) != 1 ||
648 +                        fread((char *)(vw+2), sizeof(uint16), 1, fin3) != 1)
649 +                        return(-1);
650 +        }
651 +        if (swapbytes)
652 +                swap16((char *)vw, 3);
653 +        setcolor(col, (vw[rord[RED]]+.5)/65536.,
654 +                        (vw[rord[GRN]]+.5)/65536., (vw[rord[BLU]]+.5)/65536.);
655 +        return(0);
656 + }
657 +
658 +
659 + static int
660 + getbascii(              /* get an ascii brightness value from fin */
661 +        COLOR  col
662 + )
663 + {
664          double  vd;
665  
666          if (fscanf(fin, "%lf", &vd) != 1)
# Line 606 | Line 670 | COLOR  col;
670   }
671  
672  
673 < getbdouble(col)         /* get a double brightness value from fin */
674 < COLOR  col;
673 > static int
674 > getbdouble(             /* get a double brightness value from fin */
675 >        COLOR  col
676 > )
677   {
678          double  vd;
679  
680          if (fread((char *)&vd, sizeof(double), 1, fin) != 1)
681                  return(-1);
682 +        if (swapbytes)
683 +                swap64((char *)&vd, 1);
684          setcolor(col, vd, vd, vd);
685          return(0);
686   }
687  
688  
689 < getbfloat(col)          /* get a float brightness value from fin */
690 < COLOR  col;
689 > static int
690 > getbfloat(              /* get a float brightness value from fin */
691 >        COLOR  col
692 > )
693   {
694          float  vf;
695  
696          if (fread((char *)&vf, sizeof(float), 1, fin) != 1)
697                  return(-1);
698 +        if (swapbytes)
699 +                swap32((char *)&vf, 1);
700          setcolor(col, vf, vf, vf);
701          return(0);
702   }
703  
704  
705 < getbint(col)            /* get an int brightness value from fin */
706 < COLOR  col;
705 > static int
706 > getbint(                /* get an int brightness value from fin */
707 >        COLOR  col
708 > )
709   {
710          int  vi;
711          double  d;
# Line 644 | Line 718 | COLOR  col;
718   }
719  
720  
721 < getbbyte(col)           /* get a byte brightness value from fin */
722 < COLOR  col;
721 > static int
722 > getbbyte(               /* get a byte brightness value from fin */
723 >        COLOR  col
724 > )
725   {
726          BYTE  vb;
727          double  d;
# Line 658 | Line 734 | COLOR  col;
734   }
735  
736  
737 < putcascii(col)                  /* put an ascii color to stdout */
738 < COLOR  col;
737 > static int
738 > getbword(               /* get a 16-bit brightness value from fin */
739 >        COLOR  col
740 > )
741   {
742 +        uint16  vw;
743 +        double  d;
744 +
745 +        if (fread((char *)&vw, sizeof(uint16), 1, fin) != 1)
746 +                return(-1);
747 +        if (swapbytes)
748 +                swap16((char *)&vw, 1);
749 +        d = (vw+.5)/65536.;
750 +        setcolor(col, d, d, d);
751 +        return(0);
752 + }
753 +
754 +
755 + static int
756 + putcascii(                      /* put an ascii color to stdout */
757 +        COLOR  col
758 + )
759 + {
760          fprintf(stdout, "%15.3e %15.3e %15.3e\n",
761                          colval(col,ord[0]),
762                          colval(col,ord[1]),
# Line 670 | Line 766 | COLOR  col;
766   }
767  
768  
769 < putcfloat(col)                  /* put a float color to stdout */
770 < COLOR  col;
769 > static int
770 > putcfloat(                      /* put a float color to stdout */
771 >        COLOR  col
772 > )
773   {
774          float  vf[3];
775  
776          vf[0] = colval(col,ord[0]);
777          vf[1] = colval(col,ord[1]);
778          vf[2] = colval(col,ord[2]);
779 +        if (swapbytes)
780 +                swap32((char *)vf, 3);
781          fwrite((char *)vf, sizeof(float), 3, stdout);
782  
783          return(ferror(stdout) ? -1 : 0);
784   }
785  
786  
787 < putcdouble(col)                 /* put a double color to stdout */
788 < COLOR  col;
787 > static int
788 > putcdouble(                     /* put a double color to stdout */
789 >        COLOR  col
790 > )
791   {
792          double  vd[3];
793  
794          vd[0] = colval(col,ord[0]);
795          vd[1] = colval(col,ord[1]);
796          vd[2] = colval(col,ord[2]);
797 +        if (swapbytes)
798 +                swap64((char *)vd, 3);
799          fwrite((char *)vd, sizeof(double), 3, stdout);
800  
801          return(ferror(stdout) ? -1 : 0);
802   }
803  
804  
805 < putcint(col)                    /* put an int color to stdout */
806 < COLOR  col;
805 > static int
806 > putcint(                        /* put an int color to stdout */
807 >        COLOR  col
808 > )
809   {
810          fprintf(stdout, "%d %d %d\n",
811                          (int)(colval(col,ord[0])*256.),
# Line 710 | Line 816 | COLOR  col;
816   }
817  
818  
819 < putcbyte(col)                   /* put a byte color to stdout */
820 < COLOR  col;
819 > static int
820 > putcbyte(                       /* put a byte color to stdout */
821 >        COLOR  col
822 > )
823   {
824 <        register int  i;
824 >        long  i;
825          BYTE  vb[3];
826  
827          i = colval(col,ord[0])*256.;
# Line 728 | Line 836 | COLOR  col;
836   }
837  
838  
839 < putbascii(col)                  /* put an ascii brightness to stdout */
840 < COLOR  col;
839 > static int
840 > putcword(                       /* put a 16-bit color to stdout */
841 >        COLOR  col
842 > )
843   {
844 +        long  i;
845 +        uint16  vw[3];
846 +
847 +        i = colval(col,ord[0])*65536.;
848 +        vw[0] = min(i,65535);
849 +        i = colval(col,ord[1])*65536.;
850 +        vw[1] = min(i,65535);
851 +        i = colval(col,ord[2])*65536.;
852 +        vw[2] = min(i,65535);
853 +        if (swapbytes)
854 +                swap16((char *)vw, 3);
855 +        fwrite((char *)vw, sizeof(uint16), 3, stdout);
856 +
857 +        return(ferror(stdout) ? -1 : 0);
858 + }
859 +
860 +
861 + static int
862 + putbascii(                      /* put an ascii brightness to stdout */
863 +        COLOR  col
864 + )
865 + {
866          fprintf(stdout, "%15.3e\n", (*mybright)(col));
867  
868          return(ferror(stdout) ? -1 : 0);
869   }
870  
871  
872 < putbfloat(col)                  /* put a float brightness to stdout */
873 < COLOR  col;
872 > static int
873 > putbfloat(                      /* put a float brightness to stdout */
874 >        COLOR  col
875 > )
876   {
877          float  vf;
878  
879          vf = (*mybright)(col);
880 +        if (swapbytes)
881 +                swap32((char *)&vf, 1);
882          fwrite((char *)&vf, sizeof(float), 1, stdout);
883  
884          return(ferror(stdout) ? -1 : 0);
885   }
886  
887  
888 < putbdouble(col)                 /* put a double brightness to stdout */
889 < COLOR  col;
888 > static int
889 > putbdouble(                     /* put a double brightness to stdout */
890 >        COLOR  col
891 > )
892   {
893          double  vd;
894  
895          vd = (*mybright)(col);
896 +        if (swapbytes)
897 +                swap64((char *)&vd, 1);
898          fwrite((char *)&vd, sizeof(double), 1, stdout);
899  
900          return(ferror(stdout) ? -1 : 0);
901   }
902  
903  
904 < putbint(col)                    /* put an int brightness to stdout */
905 < COLOR  col;
904 > static int
905 > putbint(                        /* put an int brightness to stdout */
906 >        COLOR  col
907 > )
908   {
909          fprintf(stdout, "%d\n", (int)((*mybright)(col)*256.));
910  
# Line 770 | Line 912 | COLOR  col;
912   }
913  
914  
915 < putbbyte(col)                   /* put a byte brightness to stdout */
916 < COLOR  col;
915 > static int
916 > putbbyte(                       /* put a byte brightness to stdout */
917 >        COLOR  col
918 > )
919   {
920          register int  i;
921          BYTE  vb;
# Line 784 | Line 928 | COLOR  col;
928   }
929  
930  
931 < putpascii(col)                  /* put an ascii primary to stdout */
932 < COLOR  col;
931 > static int
932 > putbword(                       /* put a 16-bit brightness to stdout */
933 >        COLOR  col
934 > )
935   {
936 +        long  i;
937 +        uint16  vw;
938 +
939 +        i = (*mybright)(col)*65536.;
940 +        vw = min(i,65535);
941 +        if (swapbytes)
942 +                swap16((char *)&vw, 1);
943 +        fwrite((char *)&vw, sizeof(uint16), 1, stdout);
944 +
945 +        return(ferror(stdout) ? -1 : 0);
946 + }
947 +
948 +
949 + static int
950 + putpascii(                      /* put an ascii primary to stdout */
951 +        COLOR  col
952 + )
953 + {
954          fprintf(stdout, "%15.3e\n", colval(col,putprim));
955  
956          return(ferror(stdout) ? -1 : 0);
957   }
958  
959  
960 < putpfloat(col)                  /* put a float primary to stdout */
961 < COLOR  col;
960 > static int
961 > putpfloat(                      /* put a float primary to stdout */
962 >        COLOR  col
963 > )
964   {
965          float  vf;
966  
967          vf = colval(col,putprim);
968 +        if (swapbytes)
969 +                swap32((char *)&vf, 1);
970          fwrite((char *)&vf, sizeof(float), 1, stdout);
971  
972          return(ferror(stdout) ? -1 : 0);
973   }
974  
975  
976 < putpdouble(col)                 /* put a double primary to stdout */
977 < COLOR  col;
976 > static int
977 > putpdouble(                     /* put a double primary to stdout */
978 >        COLOR  col
979 > )
980   {
981          double  vd;
982  
983          vd = colval(col,putprim);
984 +        if (swapbytes)
985 +                swap64((char *)&vd, 1);
986          fwrite((char *)&vd, sizeof(double), 1, stdout);
987  
988          return(ferror(stdout) ? -1 : 0);
989   }
990  
991  
992 < putpint(col)                    /* put an int primary to stdout */
993 < COLOR  col;
992 > static int
993 > putpint(                        /* put an int primary to stdout */
994 >        COLOR  col
995 > )
996   {
997          fprintf(stdout, "%d\n", (int)(colval(col,putprim)*256.));
998  
# Line 826 | Line 1000 | COLOR  col;
1000   }
1001  
1002  
1003 < putpbyte(col)                   /* put a byte primary to stdout */
1004 < COLOR  col;
1003 > static int
1004 > putpbyte(                       /* put a byte primary to stdout */
1005 >        COLOR  col
1006 > )
1007   {
1008 <        register int  i;
1008 >        long  i;
1009          BYTE  vb;
1010  
1011          i = colval(col,putprim)*256.;
# Line 840 | Line 1016 | COLOR  col;
1016   }
1017  
1018  
1019 < set_io()                        /* set put and get functions */
1019 > static int
1020 > putpword(                       /* put a 16-bit primary to stdout */
1021 >        COLOR  col
1022 > )
1023   {
1024 +        long  i;
1025 +        uint16  vw;
1026 +
1027 +        i = colval(col,putprim)*65536.;
1028 +        vw = min(i,65535);
1029 +        if (swapbytes)
1030 +                swap16((char *)&vw, 1);
1031 +        fwrite((char *)&vw, sizeof(uint16), 1, stdout);
1032 +
1033 +        return(ferror(stdout) ? -1 : 0);
1034 + }
1035 +
1036 +
1037 + static void
1038 + set_io(void)                    /* set put and get functions */
1039 + {
1040          switch (format) {
1041          case 'a':                                       /* ascii */
1042                  if (putprim == BRIGHT) {
# Line 945 | Line 1140 | set_io()                       /* set put and get functions */
1140                          }
1141                  }
1142                  return;
1143 +        case 'w':                                       /* 16-bit */
1144 +                if (putprim == BRIGHT) {
1145 +                        getval = getbword;
1146 +                        putval = putbword;
1147 +                } else if (putprim != ALL) {
1148 +                        getval = getbword;
1149 +                        putval = putpword;
1150 +                } else {
1151 +                        getval = getcword;
1152 +                        putval = putcword;
1153 +                        if (reverse && !interleave) {
1154 +                                if (fin2 == NULL)
1155 +                                        goto namerr;
1156 +                                if (fseek(fin2,
1157 +                                (long)sizeof(uint16)*picres.xr*picres.yr, 1))
1158 +                                        goto seekerr;
1159 +                                if (fseek(fin3,
1160 +                                (long)sizeof(uint16)*2*picres.xr*picres.yr, 1))
1161 +                                        goto seekerr;
1162 +                        }
1163 +                }
1164 +                return;
1165          }
1166 < badopt:
1166 > /* badopt: */ /* label not used */
1167          fprintf(stderr, "%s: botched file type\n", progname);
1168          quit(1);
1169   namerr:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines