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

Comparing ray/src/px/ra_tiff.c (file contents):
Revision 2.1 by greg, Tue Nov 12 16:05:41 1991 UTC vs.
Revision 2.8 by greg, Mon Oct 30 10:56:57 1995 UTC

# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10  
11   #include  <stdio.h>
12  
13 + #include  <math.h>
14 +
15   #include  "tiffio.h"
16  
17   #include  "color.h"
18  
19   #include  "resolu.h"
20  
19 extern double  atof();
21  
22 + #define  GAMCOR         2.2             /* default gamma */
23 +
24   extern char  *malloc(), *realloc();
25  
26   int  lzcomp = 0;                        /* use Lempel-Ziv compression? */
27  
28   int  greyscale = 0;                     /* produce greyscale image? */
29  
30 < double  gamma = 2.2;                    /* gamma correction */
30 > double  gamcor = GAMCOR;                /* gamma correction */
31  
32   int  bradj = 0;                         /* brightness adjustment */
33  
# Line 44 | Line 47 | char  *argv[];
47                  if (argv[i][0] == '-')
48                          switch (argv[i][1]) {
49                          case 'g':
50 <                                gamma = atof(argv[++i]);
50 >                                gamcor = atof(argv[++i]);
51                                  break;
52                          case 'z':
53                                  lzcomp = !lzcomp;
# Line 68 | Line 71 | char  *argv[];
71                  else
72                          break;
73   doneopts:
74 <        setcolrgam(gamma);
74 >        setcolrgam(gamcor);
75  
76          if (reverse)
77                  if (i != argc-2 && i != argc-1)
# Line 121 | Line 124 | char   *inpf, *outf;
124          if (!TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &hi) || hi != 8)
125                  quiterr("unsupported bits per sample");
126          if (TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &hi) &&
127 <                        hi != (nsamps==1 ? 1 : 2))
127 >                        hi != (nsamps==1 ? PHOTOMETRIC_MINISBLACK :
128 >                                        PHOTOMETRIC_RGB))
129                  quiterr("unsupported photometric interpretation");
130          if (!TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &pconfig) ||
131 <                        (pconfig != 1 && pconfig != 2))
131 >                        (pconfig != PLANARCONFIG_CONTIG &&
132 >                                pconfig != PLANARCONFIG_SEPARATE))
133                  quiterr("unsupported planar configuration");
134          if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &xmax) ||
135                          !TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &ymax))
# Line 138 | Line 143 | char   *inpf, *outf;
143          if (outf != NULL && strcmp(outf, "-") &&
144                          freopen(outf, "w", stdout) == NULL)
145                  quiterr("cannot open Radiance output file");
146 +        newheader("RADIANCE", stdout);
147          fputs(progname, stdout);
148          if (bradj)
149                  printf(" -e %+d", bradj);
150 +        if (gamcor != GAMCOR)
151 +                printf(" -g %f", gamcor);
152          fputs(" -r\n", stdout);
153          fputformat(COLRFMT, stdout);
154          putchar('\n');
155 <        fprtresolu(xmax, ymax, stdout);
155 >        fprtresolu((int)xmax, (int)ymax, stdout);
156                                                  /* convert image */
157          if (nsamps == 1)
158                  pconfig = 1;
# Line 215 | Line 223 | char   *inpf, *outf;
223          TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (unsigned long)ymax);
224          TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, greyscale ? 1 : 3);
225          TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
226 <        TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, greyscale ? 1 : 2);
227 <        TIFFSetField(tif, TIFFTAG_PLANARCONFIG, 1);
226 >        TIFFSetField(tif, TIFFTAG_PHOTOMETRIC,
227 >                        greyscale ? PHOTOMETRIC_MINISBLACK :
228 >                                PHOTOMETRIC_RGB);
229 >        TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
230          if (lzcomp)
231 <                TIFFSetField(tif, TIFFTAG_COMPRESSION, (unsigned short)5);
231 >                TIFFSetField(tif, TIFFTAG_COMPRESSION,
232 >                                (unsigned short)COMPRESSION_LZW);
233                                                  /* allocate scanlines */
234          scanin = (COLR *)malloc(xmax*sizeof(COLR));
235          scanout = (BYTE *)malloc(TIFFScanlineSize(tif));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines