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 1.5 by greg, Thu Aug 15 15:47:35 1991 UTC vs.
Revision 2.7 by greg, Fri Nov 11 11:26:20 1994 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 < extern double  atof();
19 > #include  "resolu.h"
20  
21 +
22   extern char  *malloc(), *realloc();
23  
24   int  lzcomp = 0;                        /* use Lempel-Ziv compression? */
25  
26   int  greyscale = 0;                     /* produce greyscale image? */
27  
28 < double  gamma = 2.2;                    /* gamma correction */
28 > double  gamcor = 2.2;                   /* gamma correction */
29  
30   int  bradj = 0;                         /* brightness adjustment */
31  
# Line 42 | Line 45 | char  *argv[];
45                  if (argv[i][0] == '-')
46                          switch (argv[i][1]) {
47                          case 'g':
48 <                                gamma = atof(argv[++i]);
48 >                                gamcor = atof(argv[++i]);
49                                  break;
50                          case 'z':
51                                  lzcomp = !lzcomp;
# Line 66 | Line 69 | char  *argv[];
69                  else
70                          break;
71   doneopts:
72 <        setcolrgam(gamma);
72 >        setcolrgam(gamcor);
73  
74          if (reverse)
75                  if (i != argc-2 && i != argc-1)
# Line 119 | Line 122 | char   *inpf, *outf;
122          if (!TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &hi) || hi != 8)
123                  quiterr("unsupported bits per sample");
124          if (TIFFGetField(tif, TIFFTAG_PHOTOMETRIC, &hi) &&
125 <                        hi != (nsamps==1 ? 1 : 2))
125 >                        hi != (nsamps==1 ? PHOTOMETRIC_MINISBLACK :
126 >                                        PHOTOMETRIC_RGB))
127                  quiterr("unsupported photometric interpretation");
128          if (!TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &pconfig) ||
129 <                        (pconfig != 1 && pconfig != 2))
129 >                        (pconfig != PLANARCONFIG_CONTIG &&
130 >                                pconfig != PLANARCONFIG_SEPARATE))
131                  quiterr("unsupported planar configuration");
132          if (!TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &xmax) ||
133                          !TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &ymax))
# Line 136 | Line 141 | char   *inpf, *outf;
141          if (outf != NULL && strcmp(outf, "-") &&
142                          freopen(outf, "w", stdout) == NULL)
143                  quiterr("cannot open Radiance output file");
144 +        newheader("RADIANCE", stdout);
145          fputs(progname, stdout);
146          if (bradj)
147                  printf(" -e %+d", bradj);
148          fputs(" -r\n", stdout);
149          fputformat(COLRFMT, stdout);
150          putchar('\n');
151 <        fputresolu(YDECR|YMAJOR, xmax, ymax, stdout);
151 >        fprtresolu((int)xmax, (int)ymax, stdout);
152                                                  /* convert image */
153          if (nsamps == 1)
154                  pconfig = 1;
# Line 204 | Line 210 | char   *inpf, *outf;
210          if (strcmp(inpf, "-") && freopen(inpf, "r", stdin) == NULL)
211                  quiterr("cannot open Radiance input file");
212          if (checkheader(stdin, COLRFMT, NULL) < 0 ||
213 <                        fgetresolu(&xmax, &ymax, stdin) != (YDECR|YMAJOR))
213 >                        fgetresolu(&xmax, &ymax, stdin) < 0)
214                  quiterr("bad Radiance picture");
215                                                  /* open TIFF file */
216          if ((tif = TIFFOpen(outf, "w")) == NULL)
# Line 213 | Line 219 | char   *inpf, *outf;
219          TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (unsigned long)ymax);
220          TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, greyscale ? 1 : 3);
221          TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
222 <        TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, greyscale ? 1 : 2);
223 <        TIFFSetField(tif, TIFFTAG_PLANARCONFIG, 1);
222 >        TIFFSetField(tif, TIFFTAG_PHOTOMETRIC,
223 >                        greyscale ? PHOTOMETRIC_MINISBLACK :
224 >                                PHOTOMETRIC_RGB);
225 >        TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
226          if (lzcomp)
227 <                TIFFSetField(tif, TIFFTAG_COMPRESSION, (unsigned short)5);
227 >                TIFFSetField(tif, TIFFTAG_COMPRESSION,
228 >                                (unsigned short)COMPRESSION_LZW);
229                                                  /* allocate scanlines */
230          scanin = (COLR *)malloc(xmax*sizeof(COLR));
231          scanout = (BYTE *)malloc(TIFFScanlineSize(tif));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines