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.36 by greg, Mon Jul 15 23:42:44 2019 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  pvalue.c - program to print pixel values.
6   *
7   *     4/23/86
8   */
9  
10 + #include  "platform.h"
11   #include  "standard.h"
14
12   #include  "color.h"
16
13   #include  "resolu.h"
14 + #include  "view.h"
15  
16   #define  min(a,b)               ((a)<(b)?(a):(b))
17  
# Line 22 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19   #define  ALL            3
20   #define  BRIGHT         4
21  
25 #define  brightonly     (putprim==BRIGHT)
26
22   RESOLU  picres;                 /* resolution of picture */
28
23   int  uniq = 0;                  /* print only unique values? */
30
24   int  doexposure = 0;            /* exposure change? (>100 to print) */
32
25   int  dataonly = 0;              /* data only format? */
34
26   int  putprim = ALL;             /* what to put out */
36
27   int  reverse = 0;               /* reverse conversion? */
38
28   int  format = 'a';              /* input/output format */
29   char  *fmtid = "ascii";         /* format identifier for header */
41
30   int  header = 1;                /* do header? */
43
31   long  skipbytes = 0;            /* skip bytes in input? */
32 <
32 > int  swapbytes = 0;             /* swap bytes? */
33 > int  interleave = 1;            /* file is interleaved? */
34   int  resolution = 1;            /* put/get resolution string? */
47
35   int  original = 0;              /* convert to original values? */
49
36   int  wrongformat = 0;           /* wrong input format? */
51
37   double  gamcor = 1.0;           /* gamma correction */
38  
39 + RGBPRIMP  outprims = stdprims;  /* output primaries for reverse conversion */
40 + RGBPRIMS  myprims;
41 +
42   int  ord[3] = {RED, GRN, BLU};  /* RGB ordering */
43   int  rord[4];                   /* reverse ordering */
44  
# Line 61 | Line 49 | char  *progname;
49   FILE  *fin;
50   FILE  *fin2 = NULL, *fin3 = NULL;       /* for other color channels */
51  
64 int  (*getval)(), (*putval)();
52  
53 + typedef int getfunc_t(COLOR  col);
54 + typedef int putfunc_t(COLOR  col);
55 + typedef double brightfunc_t(COLOR  col);
56  
57 < main(argc, argv)
58 < int  argc;
59 < char  **argv;
57 > getfunc_t *getval;
58 > putfunc_t *putval;
59 > brightfunc_t *mybright;
60 >
61 > static gethfunc checkhead;
62 > static brightfunc_t rgb_bright, xyz_bright;
63 > static getfunc_t getbascii, getbint, getbdouble, getbfloat, getbbyte, getbword;
64 > static getfunc_t getcascii, getcint, getcdouble, getcfloat, getcbyte, getcword;
65 > static putfunc_t putbascii, putbint, putbdouble, putbfloat, putbbyte, putbword;
66 > static putfunc_t putcascii, putcint, putcdouble, putcfloat, putcbyte, putcword;
67 > static putfunc_t putpascii, putpint, putpdouble, putpfloat, putpbyte, putpword;
68 >
69 > static void set_io(void);
70 > static void pixtoval(void);
71 > static void valtopix(void);
72 >
73 >
74 > static double
75 > rgb_bright(
76 >        COLOR  clr
77 > )
78   {
79 <        extern int  checkhead();
80 <        extern long  atol();
73 <        double  d, expval = 1.0;
74 <        int  i;
79 >        return(bright(clr));
80 > }
81  
82 + static double
83 + xyz_bright(
84 +        COLOR  clr
85 + )
86 + {
87 +        return(clr[CIEY]);
88 + }
89 +
90 + int
91 + main(
92 +        int  argc,
93 +        char  **argv
94 + )
95 + {
96 +        const char      *inpmode = "r";
97 +        double          d, expval = 1.0;
98 +        int             i;
99 +
100          progname = argv[0];
101 +        mybright = &rgb_bright; /* default */
102  
103          for (i = 1; i < argc; i++)
104                  if (argv[i][0] == '-' || argv[i][0] == '+')
# Line 119 | Line 144 | char  **argv;
144                          case 'r':               /* reverse conversion */
145                                  reverse = argv[i][0] == '-';
146                                  break;
147 +                        case 'n':               /* non-interleaved RGB */
148 +                                interleave = argv[i][0] == '+';
149 +                                break;
150                          case 'b':               /* brightness values */
151                                  putprim = argv[i][0] == '-' ? BRIGHT : ALL;
152                                  break;
153 <                        case 'p':               /* put primary */
153 >                        case 'p':               /* primary controls */
154                                  switch (argv[i][2]) {
155 +                                /* these two options affect -r conversion */
156 +                                case '\0':
157 +                                        myprims[RED][CIEX] = atof(argv[++i]);
158 +                                        myprims[RED][CIEY] = atof(argv[++i]);
159 +                                        myprims[GRN][CIEX] = atof(argv[++i]);
160 +                                        myprims[GRN][CIEY] = atof(argv[++i]);
161 +                                        myprims[BLU][CIEX] = atof(argv[++i]);
162 +                                        myprims[BLU][CIEY] = atof(argv[++i]);
163 +                                        myprims[WHT][CIEX] = atof(argv[++i]);
164 +                                        myprims[WHT][CIEY] = atof(argv[++i]);
165 +                                        outprims = myprims;
166 +                                        break;
167 +                                case 'x': case 'X': outprims = NULL; break;
168 +                                /* the following options affect +r only */
169                                  case 'r': case 'R': putprim = RED; break;
170                                  case 'g': case 'G': putprim = GRN; break;
171                                  case 'b': case 'B': putprim = BLU; break;
# Line 147 | Line 189 | char  **argv;
189                                          format = 'b';
190                                          fmtid = "byte";
191                                          break;
192 +                                case 'W':               /* 16-bit swapped */
193 +                                        swapbytes = 1;
194 +                                case 'w':               /* 16-bit */
195 +                                        dataonly = 1;
196 +                                        format = 'w';
197 +                                        fmtid = "16-bit";
198 +                                        break;
199 +                                case 'F':               /* swapped floats */
200 +                                        swapbytes = 1;
201                                  case 'f':               /* float */
202                                          dataonly = 1;
203                                          format = 'f';
204                                          fmtid = "float";
205                                          break;
206 +                                case 'D':               /* swapped doubles */
207 +                                        swapbytes = 1;
208                                  case 'd':               /* double */
209                                          dataonly = 1;
210                                          format = 'd';
# Line 165 | Line 218 | char  **argv;
218                          case 'X':               /* x resolution */
219                                  resolution = 0;
220                                  if (argv[i][0] == '-')
221 <                                        picres.or |= XDECR;
221 >                                        picres.rt |= XDECR;
222                                  picres.xr = atoi(argv[++i]);
223                                  break;
224                          case 'y':               /* y resolution */
225                          case 'Y':               /* y resolution */
226                                  resolution = 0;
227                                  if (argv[i][0] == '-')
228 <                                        picres.or |= YDECR;
228 >                                        picres.rt |= YDECR;
229                                  if (picres.xr == 0)
230 <                                        picres.or |= YMAJOR;
230 >                                        picres.rt |= YMAJOR;
231                                  picres.yr = atoi(argv[++i]);
232                                  break;
233                          default:
# Line 187 | Line 240 | unkopt:
240                  else
241                          break;
242                                          /* recognize special formats */
243 <        if (dataonly && format == 'b')
244 <                if (brightonly)
243 >        if (dataonly && format == 'b') {
244 >                if (putprim == ALL)
245 >                        fmtid = "24-bit_rgb";
246 >                else
247                          fmtid = "8-bit_grey";
248 +        }
249 +        if (dataonly && format == 'w') {
250 +                if (putprim == ALL)
251 +                        fmtid = "48-bit_rgb";
252                  else
253 <                        fmtid = "24-bit_rgb";
253 >                        fmtid = "16-bit_grey";
254 >        }
255 >        if (!reverse || (format != 'a') & (format != 'i'))
256 >                inpmode = "rb";
257                                          /* assign reverse ordering */
258          rord[ord[0]] = 0;
259          rord[ord[1]] = 1;
260          rord[ord[2]] = 2;
261                                          /* get input */
262          if (i == argc) {
263 +                long    n = skipbytes;
264 +                if (inpmode[1] == 'b')
265 +                        SET_FILE_BINARY(stdin);
266 +                while (n-- > 0)
267 +                        if (getchar() == EOF) {
268 +                                fprintf(stderr,
269 +                                "%s: cannot skip %ld bytes on standard input\n",
270 +                                                progname, skipbytes);
271 +                                quit(1);
272 +                        }
273                  fin = stdin;
274          } else if (i < argc) {
275 <                if ((fin = fopen(argv[i], "r")) == NULL) {
275 >                if ((fin = fopen(argv[i], inpmode)) == NULL) {
276                          fprintf(stderr, "%s: can't open file \"%s\"\n",
277                                                  progname, argv[i]);
278                          quit(1);
279                  }
280 <                if (skipbytes && fseek(fin, skipbytes, 0))
281 <                        goto seekerr;
210 <                if (reverse && !brightonly && i == argc-3) {
211 <                        if ((fin2 = fopen(argv[i+1], "r")) == NULL) {
280 >                if (reverse && putprim != BRIGHT && i == argc-3) {
281 >                        if ((fin2 = fopen(argv[i+1], inpmode)) == NULL) {
282                                  fprintf(stderr, "%s: can't open file \"%s\"\n",
283                                                  progname, argv[i+1]);
284                                  quit(1);
285                          }
286 <                        if ((fin3 = fopen(argv[i+2], "r")) == NULL) {
286 >                        if ((fin3 = fopen(argv[i+2], inpmode)) == NULL) {
287                                  fprintf(stderr, "%s: can't open file \"%s\"\n",
288                                                  progname, argv[i+2]);
289                                  quit(1);
290                          }
291 <                        if (skipbytes && (fseek(fin2, skipbytes, 0) ||
222 <                                        fseek(fin3, skipbytes, 0)))
223 <                                goto seekerr;
291 >                        interleave = -1;
292                  } else if (i != argc-1)
293                          fin = NULL;
294 +                if (reverse && putprim != BRIGHT && !interleave) {
295 +                        fin2 = fopen(argv[i], inpmode);
296 +                        fin3 = fopen(argv[i], inpmode);
297 +                }
298 +                if (skipbytes && (fseek(fin, skipbytes, SEEK_SET) || (fin2 != NULL &&
299 +                                fseek(fin2, skipbytes, SEEK_SET) |
300 +                                fseek(fin3, skipbytes, SEEK_SET)))) {
301 +                        fprintf(stderr, "%s: cannot skip %ld bytes on input\n",
302 +                                        progname, skipbytes);
303 +                        quit(1);
304 +                }
305          }
306          if (fin == NULL) {
307                  fprintf(stderr, "%s: bad # file arguments\n", progname);
308                  quit(1);
309          }
310  
232        set_io();
233
311          if (reverse) {
312 < #ifdef MSDOS
236 <                setmode(fileno(stdout), O_BINARY);
237 <                if (format != 'a' && format != 'i')
238 <                        setmode(fileno(fin), O_BINARY);
239 < #endif
312 >                SET_FILE_BINARY(stdout);
313                                          /* get header */
314                  if (header) {
315                          if (checkheader(fin, fmtid, stdout) < 0) {
# Line 259 | Line 332 | unkopt:
332                  if (resolution && fin2 != NULL) {
333                          RESOLU  pres2;
334                          if (!fgetsresolu(&pres2, fin2) ||
335 <                                        pres2.or != picres.or ||
335 >                                        pres2.rt != picres.rt ||
336                                          pres2.xr != picres.xr ||
337                                          pres2.yr != picres.yr ||
338                                          !fgetsresolu(&pres2, fin3) ||
339 <                                        pres2.or != picres.or ||
339 >                                        pres2.rt != picres.rt ||
340                                          pres2.xr != picres.xr ||
341                                          pres2.yr != picres.yr) {
342                                  fprintf(stderr, "%s: resolution mismatch\n",
# Line 275 | Line 348 | unkopt:
348                  printargs(i, argv, stdout);
349                  if (expval < .99 || expval > 1.01)
350                          fputexpos(expval, stdout);
351 <                fputformat(COLRFMT, stdout);
351 >                if (outprims != NULL) {
352 >                        if (outprims != stdprims)
353 >                                fputprims(outprims, stdout);
354 >                        fputformat(COLRFMT, stdout);
355 >                } else                          /* XYZ data */
356 >                        fputformat(CIEFMT, stdout);
357                  putchar('\n');
358                  fputsresolu(&picres, stdout);   /* always put resolution */
359                  valtopix();
360          } else {
361 < #ifdef MSDOS
362 <                setmode(fileno(fin), O_BINARY);
285 <                if (format != 'a' && format != 'i')
286 <                        setmode(fileno(stdout), O_BINARY);
287 < #endif
361 >                if ((format != 'a') & (format != 'i'))
362 >                        SET_FILE_BINARY(stdout);
363                                                  /* get header */
364                  getheader(fin, checkhead, NULL);
365                  if (wrongformat) {
366 <                        fprintf(stderr, "%s: input not a Radiance picture\n",
366 >                        fprintf(stderr,
367 >                                "%s: input not a Radiance RGBE picture\n",
368                                          progname);
369                          quit(1);
370                  }
# Line 309 | Line 385 | unkopt:
385          }
386  
387          quit(0);
388 < seekerr:
313 <        fprintf(stderr, "%s: cannot skip %ld bytes on input\n",
314 <                        progname, skipbytes);
315 <        quit(1);
388 >        return 0; /* pro forma return */
389   }
390  
391  
392 < checkhead(line)                         /* deal with line from header */
393 < char  *line;
392 > static int
393 > checkhead(                              /* deal with line from header */
394 >        char    *line,
395 >        void    *p
396 > )
397   {
398 <        char    fmt[32];
398 >        char    fmt[MAXFMTLEN];
399          double  d;
400          COLOR   ctmp;
401  
402 <        if (formatval(fmt, line))
403 <                wrongformat = strcmp(fmt, COLRFMT);
404 <        else if (original && isexpos(line)) {
402 >        if (formatval(fmt, line)) {
403 >                if (!strcmp(fmt, CIEFMT))
404 >                        mybright = &xyz_bright;
405 >                else if (!strcmp(fmt, COLRFMT))
406 >                        mybright = &rgb_bright;
407 >                else
408 >                        wrongformat++;
409 >        } else if (original && isexpos(line)) {
410                  d = 1.0/exposval(line);
411                  scalecolor(exposure, d);
412                  doexposure++;
# Line 337 | Line 418 | char  *line;
418                  doexposure++;
419          } else if (header)
420                  fputs(line, stdout);
421 +        return(0);
422   }
423  
424  
425 < pixtoval()                              /* convert picture to values */
425 > static void
426 > pixtoval(void)                          /* convert picture to values */
427   {
428 <        register COLOR  *scanln;
428 >        COLOR   *scanln;
429          int  dogamma;
430          COLOR  lastc;
431 <        FLOAT  hv[2];
432 <        int  y;
433 <        register int  x;
431 >        RREAL  hv[2];
432 >        int  startprim, endprim;
433 >        long  startpos;
434 >        int  x, y;
435  
436          scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR));
437          if (scanln == NULL) {
# Line 355 | Line 439 | pixtoval()                             /* convert picture to values */
439                  quit(1);
440          }
441          dogamma = gamcor < .95 || gamcor > 1.05;
442 <        setcolor(lastc, 0.0, 0.0, 0.0);
443 <        for (y = 0; y < numscans(&picres); y++) {
444 <                if (freadscan(scanln, scanlen(&picres), fin) < 0) {
445 <                        fprintf(stderr, "%s: read error\n", progname);
442 >        if ((putprim == ALL) & !interleave) {
443 >                startprim = RED; endprim = BLU;
444 >                startpos = ftell(fin);
445 >        } else {
446 >                startprim = putprim; endprim = putprim;
447 >        }
448 >        for (putprim = startprim; putprim <= endprim; putprim++) {
449 >                if (putprim != startprim && fseek(fin, startpos, SEEK_SET)) {
450 >                        fprintf(stderr, "%s: seek error on input file\n",
451 >                                        progname);
452                          quit(1);
453                  }
454 <                for (x = 0; x < scanlen(&picres); x++) {
455 <                        if (uniq)
456 <                                if (    colval(scanln[x],RED) ==
457 <                                                colval(lastc,RED) &&
458 <                                        colval(scanln[x],GRN) ==
369 <                                                colval(lastc,GRN) &&
370 <                                        colval(scanln[x],BLU) ==
371 <                                                colval(lastc,BLU)       )
372 <                                        continue;
373 <                                else
374 <                                        copycolor(lastc, scanln[x]);
375 <                        if (doexposure)
376 <                                multcolor(scanln[x], exposure);
377 <                        if (dogamma)
378 <                                setcolor(scanln[x],
379 <                                pow(colval(scanln[x],RED), 1.0/gamcor),
380 <                                pow(colval(scanln[x],GRN), 1.0/gamcor),
381 <                                pow(colval(scanln[x],BLU), 1.0/gamcor));
382 <                        if (!dataonly) {
383 <                                pix2loc(hv, &picres, x, y);
384 <                                printf("%7d %7d ", (int)(hv[0]*picres.xr),
385 <                                                (int)(hv[1]*picres.yr));
386 <                        }
387 <                        if ((*putval)(scanln[x], stdout) < 0) {
388 <                                fprintf(stderr, "%s: write error\n", progname);
454 >                set_io();
455 >                setcolor(lastc, 0.0, 0.0, 0.0);
456 >                for (y = 0; y < numscans(&picres); y++) {
457 >                        if (freadscan(scanln, scanlen(&picres), fin) < 0) {
458 >                                fprintf(stderr, "%s: read error\n", progname);
459                                  quit(1);
460                          }
461 +                        for (x = 0; x < scanlen(&picres); x++) {
462 +                                if (uniq) {
463 +                                        if (    colval(scanln[x],RED) ==
464 +                                                        colval(lastc,RED) &&
465 +                                                colval(scanln[x],GRN) ==
466 +                                                        colval(lastc,GRN) &&
467 +                                                colval(scanln[x],BLU) ==
468 +                                                        colval(lastc,BLU)       )
469 +                                                continue;
470 +                                        else
471 +                                                copycolor(lastc, scanln[x]);
472 +                                }
473 +                                if (doexposure)
474 +                                        multcolor(scanln[x], exposure);
475 +                                if (dogamma)
476 +                                        setcolor(scanln[x],
477 +                                        pow(colval(scanln[x],RED), 1.0/gamcor),
478 +                                        pow(colval(scanln[x],GRN), 1.0/gamcor),
479 +                                        pow(colval(scanln[x],BLU), 1.0/gamcor));
480 +                                if (!dataonly) {
481 +                                        pix2loc(hv, &picres, x, y);
482 +                                        printf("%7d %7d ",
483 +                                                        (int)(hv[0]*picres.xr),
484 +                                                        (int)(hv[1]*picres.yr));
485 +                                }
486 +                                if ((*putval)(scanln[x]) < 0) {
487 +                                        fprintf(stderr, "%s: write error\n",
488 +                                                        progname);
489 +                                        quit(1);
490 +                                }
491 +                        }
492                  }
493          }
494 <        free((char *)scanln);
494 >        free((void *)scanln);
495   }
496  
497  
498 < valtopix()                      /* convert values to a pixel file */
498 > static void
499 > valtopix(void)                  /* convert values to a pixel file */
500   {
501 <        int  dogamma;
502 <        register COLOR  *scanln;
503 <        int  y;
504 <        register int  x;
501 >        int     dogamma;
502 >        COLOR   *scanln;
503 >        COLR    rgbe;
504 >        int     x, y;
505  
506          scanln = (COLOR *)malloc(scanlen(&picres)*sizeof(COLOR));
507          if (scanln == NULL) {
# Line 407 | Line 509 | valtopix()                     /* convert values to a pixel file */
509                  quit(1);
510          }
511          dogamma = gamcor < .95 || gamcor > 1.05;
512 +        set_io();
513          for (y = 0; y < numscans(&picres); y++) {
514                  for (x = 0; x < scanlen(&picres); x++) {
515                          if (!dataonly) {
# Line 416 | Line 519 | valtopix()                     /* convert values to a pixel file */
519                                          fscanf(fin3, "%*d %*d");
520                                  }
521                          }
522 <                        if ((*getval)(scanln[x], fin, fin2, fin3) < 0) {
522 >                        if ((*getval)(scanln[x]) < 0) {
523                                  fprintf(stderr, "%s: read error\n", progname);
524                                  quit(1);
525                          }
# Line 427 | Line 530 | valtopix()                     /* convert values to a pixel file */
530                                          pow(colval(scanln[x],BLU), gamcor));
531                          if (doexposure)
532                                  multcolor(scanln[x], exposure);
533 +                        if (uniq) {             /* uncompressed? */
534 +                                setcolr(rgbe,   scanln[x][RED],
535 +                                                scanln[x][GRN],
536 +                                                scanln[x][BLU]);
537 +                                if (putbinary(rgbe, sizeof(COLR), 1, stdout) != 1)
538 +                                        goto writerr;
539 +                        }
540                  }
541 <                if (fwritescan(scanln, scanlen(&picres), stdout) < 0) {
542 <                        fprintf(stderr, "%s: write error\n", progname);
543 <                        quit(1);
434 <                }
541 >                                                /* write scan if compressed */
542 >                if (!uniq && fwritescan(scanln, scanlen(&picres), stdout) < 0)
543 >                        goto writerr;
544          }
545 <        free((char *)scanln);
545 >        free((void *)scanln);
546 >        return;
547 > writerr:
548 >        fprintf(stderr, "%s: write error\n", progname);
549 >        quit(1);
550   }
551  
552  
553 + void
554   quit(code)
555   int  code;
556   {
# Line 444 | Line 558 | int  code;
558   }
559  
560  
561 < getcascii(col, f1, f2, f3)      /* get an ascii color value from stream(s) */
562 < COLOR  col;
563 < FILE  *f1, *f2, *f3;
561 > static int
562 > getcascii(              /* get an ascii color value from stream(s) */
563 >        COLOR  col
564 > )
565   {
566          double  vd[3];
567  
568 <        if (f2 == NULL) {
569 <                if (fscanf(f1, "%lf %lf %lf", &vd[0], &vd[1], &vd[2]) != 3)
568 >        if (fin2 == NULL) {
569 >                if (fscanf(fin, "%lf %lf %lf", &vd[0], &vd[1], &vd[2]) != 3)
570                          return(-1);
571          } else {
572 <                if (fscanf(f1, "%lf", &vd[0]) != 1 ||
573 <                                fscanf(f2, "%lf", &vd[1]) != 1 ||
574 <                                fscanf(f3, "%lf", &vd[2]) != 1)
572 >                if (fscanf(fin, "%lf", &vd[0]) != 1 ||
573 >                                fscanf(fin2, "%lf", &vd[1]) != 1 ||
574 >                                fscanf(fin3, "%lf", &vd[2]) != 1)
575                          return(-1);
576          }
577          setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]);
# Line 464 | Line 579 | FILE  *f1, *f2, *f3;
579   }
580  
581  
582 < getcdouble(col, f1, f2, f3)     /* get a double color value from stream(s) */
583 < COLOR  col;
584 < FILE  *f1, *f2, *f3;
582 > static int
583 > getcdouble(             /* get a double color value from stream(s) */
584 >        COLOR  col
585 > )
586   {
587          double  vd[3];
588  
589 <        if (f2 == NULL) {
590 <                if (fread((char *)vd, sizeof(double), 3, f1) != 3)
589 >        if (fin2 == NULL) {
590 >                if (getbinary(vd, sizeof(double), 3, fin) != 3)
591                          return(-1);
592          } else {
593 <                if (fread((char *)vd, sizeof(double), 1, f1) != 1 ||
594 <                        fread((char *)(vd+1), sizeof(double), 1, f2) != 1 ||
595 <                        fread((char *)(vd+2), sizeof(double), 1, f3) != 1)
593 >                if (getbinary(vd, sizeof(double), 1, fin) != 1 ||
594 >                        getbinary(vd+1, sizeof(double), 1, fin2) != 1 ||
595 >                        getbinary(vd+2, sizeof(double), 1, fin3) != 1)
596                          return(-1);
597          }
598 +        if (swapbytes)
599 +                swap64((char *)vd, 3);
600          setcolor(col, vd[rord[RED]], vd[rord[GRN]], vd[rord[BLU]]);
601          return(0);
602   }
603  
604  
605 < getcfloat(col, f1, f2, f3)      /* get a float color value from stream(s) */
606 < COLOR  col;
607 < FILE  *f1, *f2, *f3;
605 > static int
606 > getcfloat(              /* get a float color value from stream(s) */
607 >        COLOR  col
608 > )
609   {
610          float  vf[3];
611  
612 <        if (f2 == NULL) {
613 <                if (fread((char *)vf, sizeof(float), 3, f1) != 3)
612 >        if (fin2 == NULL) {
613 >                if (getbinary(vf, sizeof(float), 3, fin) != 3)
614                          return(-1);
615          } else {
616 <                if (fread((char *)vf, sizeof(float), 1, f1) != 1 ||
617 <                        fread((char *)(vf+1), sizeof(float), 1, f2) != 1 ||
618 <                        fread((char *)(vf+2), sizeof(float), 1, f3) != 1)
616 >                if (getbinary(vf, sizeof(float), 1, fin) != 1 ||
617 >                        getbinary(vf+1, sizeof(float), 1, fin2) != 1 ||
618 >                        getbinary(vf+2, sizeof(float), 1, fin3) != 1)
619                          return(-1);
620          }
621 +        if (swapbytes)
622 +                swap32((char *)vf, 3);
623          setcolor(col, vf[rord[RED]], vf[rord[GRN]], vf[rord[BLU]]);
624          return(0);
625   }
626  
627  
628 < getcint(col, f1, f2, f3)        /* get an int color value from stream(s) */
629 < COLOR  col;
630 < FILE  *f1, *f2, *f3;
628 > static int
629 > getcint(                /* get an int color value from stream(s) */
630 >        COLOR  col
631 > )
632   {
633          int  vi[3];
634  
635 <        if (f2 == NULL) {
636 <                if (fscanf(f1, "%d %d %d", &vi[0], &vi[1], &vi[2]) != 3)
635 >        if (fin2 == NULL) {
636 >                if (fscanf(fin, "%d %d %d", &vi[0], &vi[1], &vi[2]) != 3)
637                          return(-1);
638          } else {
639 <                if (fscanf(f1, "%d", &vi[0]) != 1 ||
640 <                                fscanf(f2, "%d", &vi[1]) != 1 ||
641 <                                fscanf(f3, "%d", &vi[2]) != 1)
639 >                if (fscanf(fin, "%d", &vi[0]) != 1 ||
640 >                                fscanf(fin2, "%d", &vi[1]) != 1 ||
641 >                                fscanf(fin3, "%d", &vi[2]) != 1)
642                          return(-1);
643          }
644          setcolor(col, (vi[rord[RED]]+.5)/256.,
# Line 525 | Line 647 | FILE  *f1, *f2, *f3;
647   }
648  
649  
650 < getcbyte(col, f1, f2, f3)       /* get a byte color value from stream(s) */
651 < COLOR  col;
652 < FILE  *f1, *f2, *f3;
650 > static int
651 > getcbyte(               /* get a byte color value from stream(s) */
652 >        COLOR  col
653 > )
654   {
655 <        BYTE  vb[3];
655 >        uby8  vb[3];
656  
657 <        if (f2 == NULL) {
658 <                if (fread((char *)vb, sizeof(BYTE), 3, f1) != 3)
657 >        if (fin2 == NULL) {
658 >                if (getbinary(vb, sizeof(uby8), 3, fin) != 3)
659                          return(-1);
660          } else {
661 <                if (fread((char *)vb, sizeof(BYTE), 1, f1) != 1 ||
662 <                        fread((char *)(vb+1), sizeof(BYTE), 1, f2) != 1 ||
663 <                        fread((char *)(vb+2), sizeof(BYTE), 1, f3) != 1)
661 >                if (getbinary(vb, sizeof(uby8), 1, fin) != 1 ||
662 >                        getbinary(vb+1, sizeof(uby8), 1, fin2) != 1 ||
663 >                        getbinary(vb+2, sizeof(uby8), 1, fin3) != 1)
664                          return(-1);
665          }
666          setcolor(col, (vb[rord[RED]]+.5)/256.,
# Line 546 | Line 669 | FILE  *f1, *f2, *f3;
669   }
670  
671  
672 < getbascii(col, fp)              /* get an ascii brightness value from fp */
673 < COLOR  col;
674 < FILE  *fp;
672 > static int
673 > getcword(               /* get a 16-bit color value from stream(s) */
674 >        COLOR  col
675 > )
676   {
677 +        uint16  vw[3];
678 +
679 +        if (fin2 == NULL) {
680 +                if (getbinary(vw, sizeof(uint16), 3, fin) != 3)
681 +                        return(-1);
682 +        } else {
683 +                if (getbinary(vw, sizeof(uint16), 1, fin) != 1 ||
684 +                        getbinary(vw+1, sizeof(uint16), 1, fin2) != 1 ||
685 +                        getbinary(vw+2, sizeof(uint16), 1, fin3) != 1)
686 +                        return(-1);
687 +        }
688 +        if (swapbytes)
689 +                swap16((char *)vw, 3);
690 +        setcolor(col, (vw[rord[RED]]+.5)/65536.,
691 +                        (vw[rord[GRN]]+.5)/65536., (vw[rord[BLU]]+.5)/65536.);
692 +        return(0);
693 + }
694 +
695 +
696 + static int
697 + getbascii(              /* get an ascii brightness value from fin */
698 +        COLOR  col
699 + )
700 + {
701          double  vd;
702  
703 <        if (fscanf(fp, "%lf", &vd) != 1)
703 >        if (fscanf(fin, "%lf", &vd) != 1)
704                  return(-1);
705          setcolor(col, vd, vd, vd);
706          return(0);
707   }
708  
709  
710 < getbdouble(col, fp)             /* get a double brightness value from fp */
711 < COLOR  col;
712 < FILE  *fp;
710 > static int
711 > getbdouble(             /* get a double brightness value from fin */
712 >        COLOR  col
713 > )
714   {
715          double  vd;
716  
717 <        if (fread((char *)&vd, sizeof(double), 1, fp) != 1)
717 >        if (getbinary(&vd, sizeof(double), 1, fin) != 1)
718                  return(-1);
719 +        if (swapbytes)
720 +                swap64((char *)&vd, 1);
721          setcolor(col, vd, vd, vd);
722          return(0);
723   }
724  
725  
726 < getbfloat(col, fp)              /* get a float brightness value from fp */
727 < COLOR  col;
728 < FILE  *fp;
726 > static int
727 > getbfloat(              /* get a float brightness value from fin */
728 >        COLOR  col
729 > )
730   {
731          float  vf;
732  
733 <        if (fread((char *)&vf, sizeof(float), 1, fp) != 1)
733 >        if (getbinary(&vf, sizeof(float), 1, fin) != 1)
734                  return(-1);
735 +        if (swapbytes)
736 +                swap32((char *)&vf, 1);
737          setcolor(col, vf, vf, vf);
738          return(0);
739   }
740  
741  
742 < getbint(col, fp)                /* get an int brightness value from fp */
743 < COLOR  col;
744 < FILE  *fp;
742 > static int
743 > getbint(                /* get an int brightness value from fin */
744 >        COLOR  col
745 > )
746   {
747          int  vi;
748          double  d;
749  
750 <        if (fscanf(fp, "%d", &vi) != 1)
750 >        if (fscanf(fin, "%d", &vi) != 1)
751                  return(-1);
752          d = (vi+.5)/256.;
753          setcolor(col, d, d, d);
# Line 600 | Line 755 | FILE  *fp;
755   }
756  
757  
758 < getbbyte(col, fp)               /* get a byte brightness value from fp */
759 < COLOR  col;
760 < FILE  *fp;
758 > static int
759 > getbbyte(               /* get a byte brightness value from fin */
760 >        COLOR  col
761 > )
762   {
763 <        BYTE  vb;
763 >        uby8  vb;
764          double  d;
765  
766 <        if (fread((char *)&vb, sizeof(BYTE), 1, fp) != 1)
766 >        if (getbinary(&vb, sizeof(uby8), 1, fin) != 1)
767                  return(-1);
768          d = (vb+.5)/256.;
769          setcolor(col, d, d, d);
# Line 615 | Line 771 | FILE  *fp;
771   }
772  
773  
774 < putcascii(col, fp)                      /* put an ascii color to fp */
775 < COLOR  col;
776 < FILE  *fp;
774 > static int
775 > getbword(               /* get a 16-bit brightness value from fin */
776 >        COLOR  col
777 > )
778   {
779 <        fprintf(fp, "%15.3e %15.3e %15.3e\n",
779 >        uint16  vw;
780 >        double  d;
781 >
782 >        if (getbinary(&vw, sizeof(uint16), 1, fin) != 1)
783 >                return(-1);
784 >        if (swapbytes)
785 >                swap16((char *)&vw, 1);
786 >        d = (vw+.5)/65536.;
787 >        setcolor(col, d, d, d);
788 >        return(0);
789 > }
790 >
791 >
792 > static int
793 > putcascii(                      /* put an ascii color to stdout */
794 >        COLOR  col
795 > )
796 > {
797 >        fprintf(stdout, "%15.3e %15.3e %15.3e\n",
798                          colval(col,ord[0]),
799                          colval(col,ord[1]),
800                          colval(col,ord[2]));
801  
802 <        return(ferror(fp) ? -1 : 0);
802 >        return(ferror(stdout) ? -1 : 0);
803   }
804  
805  
806 < putcfloat(col, fp)                      /* put a float color to fp */
807 < COLOR  col;
808 < FILE  *fp;
806 > static int
807 > putcfloat(                      /* put a float color to stdout */
808 >        COLOR  col
809 > )
810   {
811          float  vf[3];
812  
813          vf[0] = colval(col,ord[0]);
814          vf[1] = colval(col,ord[1]);
815          vf[2] = colval(col,ord[2]);
816 <        fwrite((char *)vf, sizeof(float), 3, fp);
816 >        if (swapbytes)
817 >                swap32((char *)vf, 3);
818 >        putbinary(vf, sizeof(float), 3, stdout);
819  
820 <        return(ferror(fp) ? -1 : 0);
820 >        return(ferror(stdout) ? -1 : 0);
821   }
822  
823  
824 < putcdouble(col, fp)                     /* put a double color to fp */
825 < COLOR  col;
826 < FILE  *fp;
824 > static int
825 > putcdouble(                     /* put a double color to stdout */
826 >        COLOR  col
827 > )
828   {
829          double  vd[3];
830  
831          vd[0] = colval(col,ord[0]);
832          vd[1] = colval(col,ord[1]);
833          vd[2] = colval(col,ord[2]);
834 <        fwrite((char *)vd, sizeof(double), 3, fp);
834 >        if (swapbytes)
835 >                swap64((char *)vd, 3);
836 >        putbinary(vd, sizeof(double), 3, stdout);
837  
838 <        return(ferror(fp) ? -1 : 0);
838 >        return(ferror(stdout) ? -1 : 0);
839   }
840  
841  
842 < putcint(col, fp)                        /* put an int color to fp */
843 < COLOR  col;
844 < FILE  *fp;
842 > static int
843 > putcint(                        /* put an int color to stdout */
844 >        COLOR  col
845 > )
846   {
847 <        fprintf(fp, "%d %d %d\n",
847 >        fprintf(stdout, "%d %d %d\n",
848                          (int)(colval(col,ord[0])*256.),
849                          (int)(colval(col,ord[1])*256.),
850                          (int)(colval(col,ord[2])*256.));
851  
852 <        return(ferror(fp) ? -1 : 0);
852 >        return(ferror(stdout) ? -1 : 0);
853   }
854  
855  
856 < putcbyte(col, fp)                       /* put a byte color to fp */
857 < COLOR  col;
858 < FILE  *fp;
856 > static int
857 > putcbyte(                       /* put a byte color to stdout */
858 >        COLOR  col
859 > )
860   {
861 <        register int  i;
862 <        BYTE  vb[3];
861 >        long  i;
862 >        uby8  vb[3];
863  
864          i = colval(col,ord[0])*256.;
865          vb[0] = min(i,255);
# Line 684 | Line 867 | FILE  *fp;
867          vb[1] = min(i,255);
868          i = colval(col,ord[2])*256.;
869          vb[2] = min(i,255);
870 <        fwrite((char *)vb, sizeof(BYTE), 3, fp);
870 >        putbinary(vb, sizeof(uby8), 3, stdout);
871  
872 <        return(ferror(fp) ? -1 : 0);
872 >        return(ferror(stdout) ? -1 : 0);
873   }
874  
875  
876 < putbascii(col, fp)                      /* put an ascii brightness to fp */
877 < COLOR  col;
878 < FILE  *fp;
876 > static int
877 > putcword(                       /* put a 16-bit color to stdout */
878 >        COLOR  col
879 > )
880   {
881 <        fprintf(fp, "%15.3e\n", bright(col));
881 >        long  i;
882 >        uint16  vw[3];
883  
884 <        return(ferror(fp) ? -1 : 0);
884 >        i = colval(col,ord[0])*65536.;
885 >        vw[0] = min(i,65535);
886 >        i = colval(col,ord[1])*65536.;
887 >        vw[1] = min(i,65535);
888 >        i = colval(col,ord[2])*65536.;
889 >        vw[2] = min(i,65535);
890 >        if (swapbytes)
891 >                swap16((char *)vw, 3);
892 >        putbinary(vw, sizeof(uint16), 3, stdout);
893 >
894 >        return(ferror(stdout) ? -1 : 0);
895   }
896  
897  
898 < putbfloat(col, fp)                      /* put a float brightness to fp */
899 < COLOR  col;
900 < FILE  *fp;
898 > static int
899 > putbascii(                      /* put an ascii brightness to stdout */
900 >        COLOR  col
901 > )
902   {
903 +        fprintf(stdout, "%15.3e\n", (*mybright)(col));
904 +
905 +        return(ferror(stdout) ? -1 : 0);
906 + }
907 +
908 +
909 + static int
910 + putbfloat(                      /* put a float brightness to stdout */
911 +        COLOR  col
912 + )
913 + {
914          float  vf;
915  
916 <        vf = bright(col);
917 <        fwrite((char *)&vf, sizeof(float), 1, fp);
916 >        vf = (*mybright)(col);
917 >        if (swapbytes)
918 >                swap32((char *)&vf, 1);
919 >        putbinary(&vf, sizeof(float), 1, stdout);
920  
921 <        return(ferror(fp) ? -1 : 0);
921 >        return(ferror(stdout) ? -1 : 0);
922   }
923  
924  
925 < putbdouble(col, fp)                     /* put a double brightness to fp */
926 < COLOR  col;
927 < FILE  *fp;
925 > static int
926 > putbdouble(                     /* put a double brightness to stdout */
927 >        COLOR  col
928 > )
929   {
930          double  vd;
931  
932 <        vd = bright(col);
933 <        fwrite((char *)&vd, sizeof(double), 1, fp);
932 >        vd = (*mybright)(col);
933 >        if (swapbytes)
934 >                swap64((char *)&vd, 1);
935 >        putbinary(&vd, sizeof(double), 1, stdout);
936  
937 <        return(ferror(fp) ? -1 : 0);
937 >        return(ferror(stdout) ? -1 : 0);
938   }
939  
940  
941 < putbint(col, fp)                        /* put an int brightness to fp */
942 < COLOR  col;
943 < FILE  *fp;
941 > static int
942 > putbint(                        /* put an int brightness to stdout */
943 >        COLOR  col
944 > )
945   {
946 <        fprintf(fp, "%d\n", (int)(bright(col)*256.));
946 >        fprintf(stdout, "%d\n", (int)((*mybright)(col)*256.));
947  
948 <        return(ferror(fp) ? -1 : 0);
948 >        return(ferror(stdout) ? -1 : 0);
949   }
950  
951  
952 < putbbyte(col, fp)                       /* put a byte brightness to fp */
953 < COLOR  col;
954 < FILE  *fp;
952 > static int
953 > putbbyte(                       /* put a byte brightness to stdout */
954 >        COLOR  col
955 > )
956   {
957 <        register int  i;
958 <        BYTE  vb;
957 >        int  i;
958 >        uby8  vb;
959  
960 <        i = bright(col)*256.;
960 >        i = (*mybright)(col)*256.;
961          vb = min(i,255);
962 <        fwrite((char *)&vb, sizeof(BYTE), 1, fp);
962 >        putbinary(&vb, sizeof(uby8), 1, stdout);
963  
964 <        return(ferror(fp) ? -1 : 0);
964 >        return(ferror(stdout) ? -1 : 0);
965   }
966  
967  
968 < putpascii(col, fp)                      /* put an ascii primary to fp */
969 < COLOR  col;
970 < FILE  *fp;
968 > static int
969 > putbword(                       /* put a 16-bit brightness to stdout */
970 >        COLOR  col
971 > )
972   {
973 <        fprintf(fp, "%15.3e\n", colval(col,putprim));
973 >        long  i;
974 >        uint16  vw;
975  
976 <        return(ferror(fp) ? -1 : 0);
976 >        i = (*mybright)(col)*65536.;
977 >        vw = min(i,65535);
978 >        if (swapbytes)
979 >                swap16((char *)&vw, 1);
980 >        putbinary(&vw, sizeof(uint16), 1, stdout);
981 >
982 >        return(ferror(stdout) ? -1 : 0);
983   }
984  
985  
986 < putpfloat(col, fp)                      /* put a float primary to fp */
987 < COLOR  col;
988 < FILE  *fp;
986 > static int
987 > putpascii(                      /* put an ascii primary to stdout */
988 >        COLOR  col
989 > )
990   {
991 +        fprintf(stdout, "%15.3e\n", colval(col,putprim));
992 +
993 +        return(ferror(stdout) ? -1 : 0);
994 + }
995 +
996 +
997 + static int
998 + putpfloat(                      /* put a float primary to stdout */
999 +        COLOR  col
1000 + )
1001 + {
1002          float  vf;
1003  
1004          vf = colval(col,putprim);
1005 <        fwrite((char *)&vf, sizeof(float), 1, fp);
1005 >        if (swapbytes)
1006 >                swap32((char *)&vf, 1);
1007 >        putbinary(&vf, sizeof(float), 1, stdout);
1008  
1009 <        return(ferror(fp) ? -1 : 0);
1009 >        return(ferror(stdout) ? -1 : 0);
1010   }
1011  
1012  
1013 < putpdouble(col, fp)                     /* put a double primary to fp */
1014 < COLOR  col;
1015 < FILE  *fp;
1013 > static int
1014 > putpdouble(                     /* put a double primary to stdout */
1015 >        COLOR  col
1016 > )
1017   {
1018          double  vd;
1019  
1020          vd = colval(col,putprim);
1021 <        fwrite((char *)&vd, sizeof(double), 1, fp);
1021 >        if (swapbytes)
1022 >                swap64((char *)&vd, 1);
1023 >        putbinary(&vd, sizeof(double), 1, stdout);
1024  
1025 <        return(ferror(fp) ? -1 : 0);
1025 >        return(ferror(stdout) ? -1 : 0);
1026   }
1027  
1028  
1029 < putpint(col, fp)                        /* put an int primary to fp */
1030 < COLOR  col;
1031 < FILE  *fp;
1029 > static int
1030 > putpint(                        /* put an int primary to stdout */
1031 >        COLOR  col
1032 > )
1033   {
1034 <        fprintf(fp, "%d\n", (int)(colval(col,putprim)*256.));
1034 >        fprintf(stdout, "%d\n", (int)(colval(col,putprim)*256.));
1035  
1036 <        return(ferror(fp) ? -1 : 0);
1036 >        return(ferror(stdout) ? -1 : 0);
1037   }
1038  
1039  
1040 < putpbyte(col, fp)                       /* put a byte primary to fp */
1041 < COLOR  col;
1042 < FILE  *fp;
1040 > static int
1041 > putpbyte(                       /* put a byte primary to stdout */
1042 >        COLOR  col
1043 > )
1044   {
1045 <        register int  i;
1046 <        BYTE  vb;
1045 >        long  i;
1046 >        uby8  vb;
1047  
1048          i = colval(col,putprim)*256.;
1049          vb = min(i,255);
1050 <        fwrite((char *)&vb, sizeof(BYTE), 1, fp);
1050 >        putbinary(&vb, sizeof(uby8), 1, stdout);
1051  
1052 <        return(ferror(fp) ? -1 : 0);
1052 >        return(ferror(stdout) ? -1 : 0);
1053   }
1054  
1055  
1056 < set_io()                        /* set put and get functions */
1056 > static int
1057 > putpword(                       /* put a 16-bit primary to stdout */
1058 >        COLOR  col
1059 > )
1060   {
1061 +        long  i;
1062 +        uint16  vw;
1063 +
1064 +        i = colval(col,putprim)*65536.;
1065 +        vw = min(i,65535);
1066 +        if (swapbytes)
1067 +                swap16((char *)&vw, 1);
1068 +        putbinary(&vw, sizeof(uint16), 1, stdout);
1069 +
1070 +        return(ferror(stdout) ? -1 : 0);
1071 + }
1072 +
1073 +
1074 + static void
1075 + set_io(void)                    /* set put and get functions */
1076 + {
1077          switch (format) {
1078          case 'a':                                       /* ascii */
1079                  if (putprim == BRIGHT) {
# Line 825 | Line 1085 | set_io()                       /* set put and get functions */
1085                  } else {
1086                          getval = getcascii;
1087                          putval = putcascii;
1088 +                        if (reverse && !interleave) {
1089 +                                fprintf(stderr,
1090 +                                "%s: ASCII input files must be interleaved\n",
1091 +                                                progname);
1092 +                                quit(1);
1093 +                        }
1094                  }
1095                  return;
1096          case 'f':                                       /* binary float */
# Line 837 | Line 1103 | set_io()                       /* set put and get functions */
1103                  } else {
1104                          getval = getcfloat;
1105                          putval = putcfloat;
1106 +                        if (reverse && !interleave) {
1107 +                                if (fin2 == NULL)
1108 +                                        goto namerr;
1109 +                                if (fseek(fin2,
1110 +                                (long)sizeof(float)*picres.xr*picres.yr, SEEK_CUR))
1111 +                                        goto seekerr;
1112 +                                if (fseek(fin3,
1113 +                                (long)sizeof(float)*2*picres.xr*picres.yr, SEEK_CUR))
1114 +                                        goto seekerr;
1115 +                        }
1116                  }
1117                  return;
1118          case 'd':                                       /* binary double */
# Line 849 | Line 1125 | set_io()                       /* set put and get functions */
1125                  } else {
1126                          getval = getcdouble;
1127                          putval = putcdouble;
1128 +                        if (reverse && !interleave) {
1129 +                                if (fin2 == NULL)
1130 +                                        goto namerr;
1131 +                                if (fseek(fin2,
1132 +                                (long)sizeof(double)*picres.xr*picres.yr, SEEK_CUR))
1133 +                                        goto seekerr;
1134 +                                if (fseek(fin3,
1135 +                                (long)sizeof(double)*2*picres.xr*picres.yr, SEEK_CUR))
1136 +                                        goto seekerr;
1137 +                        }
1138                  }
1139                  return;
1140          case 'i':                                       /* integer */
# Line 861 | Line 1147 | set_io()                       /* set put and get functions */
1147                  } else {
1148                          getval = getcint;
1149                          putval = putcint;
1150 +                        if (reverse && !interleave) {
1151 +                                fprintf(stderr,
1152 +                                "%s: integer input files must be interleaved\n",
1153 +                                                progname);
1154 +                                quit(1);
1155 +                        }
1156                  }
1157                  return;
1158          case 'b':                                       /* byte */
# Line 873 | Line 1165 | set_io()                       /* set put and get functions */
1165                  } else {
1166                          getval = getcbyte;
1167                          putval = putcbyte;
1168 +                        if (reverse && !interleave) {
1169 +                                if (fin2 == NULL)
1170 +                                        goto namerr;
1171 +                                if (fseek(fin2,
1172 +                                (long)sizeof(uby8)*picres.xr*picres.yr, SEEK_CUR))
1173 +                                        goto seekerr;
1174 +                                if (fseek(fin3,
1175 +                                (long)sizeof(uby8)*2*picres.xr*picres.yr, SEEK_CUR))
1176 +                                        goto seekerr;
1177 +                        }
1178                  }
1179                  return;
1180 +        case 'w':                                       /* 16-bit */
1181 +                if (putprim == BRIGHT) {
1182 +                        getval = getbword;
1183 +                        putval = putbword;
1184 +                } else if (putprim != ALL) {
1185 +                        getval = getbword;
1186 +                        putval = putpword;
1187 +                } else {
1188 +                        getval = getcword;
1189 +                        putval = putcword;
1190 +                        if (reverse && !interleave) {
1191 +                                if (fin2 == NULL)
1192 +                                        goto namerr;
1193 +                                if (fseek(fin2,
1194 +                                (long)sizeof(uint16)*picres.xr*picres.yr, SEEK_CUR))
1195 +                                        goto seekerr;
1196 +                                if (fseek(fin3,
1197 +                                (long)sizeof(uint16)*2*picres.xr*picres.yr, SEEK_CUR))
1198 +                                        goto seekerr;
1199 +                        }
1200 +                }
1201 +                return;
1202          }
1203 + /* badopt: */ /* label not used */
1204 +        fprintf(stderr, "%s: botched file type\n", progname);
1205 +        quit(1);
1206 + namerr:
1207 +        fprintf(stderr, "%s: non-interleaved file(s) must be named\n",
1208 +                        progname);
1209 +        quit(1);
1210 + seekerr:
1211 +        fprintf(stderr, "%s: cannot seek on interleaved input file\n",
1212 +                        progname);
1213 +        quit(1);
1214   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines