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

Comparing ray/src/px/normtiff.c (file contents):
Revision 3.7 by schorsch, Fri Jan 2 11:42:37 2004 UTC vs.
Revision 3.13 by greg, Fri May 20 02:06:39 2011 UTC

# Line 10 | Line 10 | static const char      RCSid[] = "$Id$";
10   #include <time.h>
11   #include <string.h>
12  
13 + #include "platform.h"
14   #include "tiffio.h"
15   #include "color.h"
16   #include "tonemap.h"
17 + #include "tmaptiff.h"
18   #include "resolu.h"
19  
20  
# Line 42 | Line 44 | typedef struct {
44          RESOLU  rs;             /* picture resolution */
45   } PICTURE;
46  
47 < extern PICTURE  *openpicture();
47 > uint16  comp = COMPRESSION_NONE;        /* TIFF compression mode */
48  
49   #define closepicture(p)         (fclose((p)->fp),free((void *)(p)))
50  
51   static gethfunc headline;
52  
53 + static int headline(char *s, void *pp);
54 + static PICTURE *openpicture(char *fname);
55 + static int tmap_picture(char *fname, PICTURE *pp);
56 + static int tmap_tiff(char *fname, TIFF *tp);
57 + static int putimage(uint16 or, uint32 xs, uint32 ys, float xr, float yr,
58 +        uint16 ru, uby8 *pd);
59  
60 +
61   int
62   main(
63          int     argc,
# Line 88 | Line 97 | main(
97                          if (argc-i < 2) goto userr;
98                          lddyn = atof(argv[++i]);
99                          break;
100 +                case 'z':                       /* LZW compression */
101 +                        comp = COMPRESSION_LZW;
102 +                        break;
103                  case 'p':                       /* set display primaries */
104                          if (argc-i < 9) goto userr;
105                          myprims[RED][CIEX] = atof(argv[++i]);
# Line 126 | Line 138 | main(
138          exit(rval==0 ? 0 : 1);
139   userr:
140          fprintf(stderr,
141 < "Usage: %s [-h][-s][-c][-l][-b][-g gv][-d ld][-u lm][-p xr yr xg yg xb yb xw yw] input.{tif|pic} output.tif\n",
141 > "Usage: %s [-h][-s][-c][-l][-b][-g gv][-d ld][-u lm][-z][-p xr yr xg yg xb yb xw yw] input.{tif|hdr} output.tif\n",
142                          argv[0]);
143          exit(1);
144   }
# Line 151 | Line 163 | headline(                              /* process line from header */
163   }
164  
165  
166 < PICTURE *
167 < openpicture(fname)                      /* open/check Radiance picture file */
168 < char    *fname;
166 > static PICTURE *
167 > openpicture(                    /* open/check Radiance picture file */
168 >        char    *fname
169 > )
170   {
171          FILE    *fp;
172          register PICTURE        *pp;
# Line 172 | Line 185 | char   *fname;
185                                          /* else try opening it */
186          if ((fp = fopen(fname, "r")) == NULL)
187                  return(NULL);
188 +        SET_FILE_BINARY(fp);
189                                          /* allocate struct */
190          if ((pp = (PICTURE *)malloc(sizeof(PICTURE))) == NULL)
191                  return(NULL);           /* serious error -- should exit? */
# Line 192 | Line 206 | char   *fname;
206   }
207  
208  
209 < int
210 < tmap_picture(fname, pp)                 /* tone map Radiance picture */
211 < char    *fname;
212 < register PICTURE        *pp;
209 > static int
210 > tmap_picture(                   /* tone map Radiance picture */
211 >        char    *fname,
212 >        register PICTURE        *pp
213 > )
214   {
215          uint16  orient;
216 +        double  paspect = (pp->rs.rt & YMAJOR) ? pp->pa : 1./pp->pa;
217          int     xsiz, ysiz;
218 <        BYTE    *pix;
218 >        uby8    *pix;
219                                          /* read and tone map picture */
220          if (tmMapPicture(&pix, &xsiz, &ysiz, flags,
221                          rgbp, gamv, lddyn, ldmax, fname, pp->fp) != TM_E_OK)
# Line 211 | Line 227 | register PICTURE       *pp;
227          orient++;
228                                          /* put out our image */
229          if (putimage(orient, (uint32)xsiz, (uint32)ysiz,
230 <                        72., 72./pp->pa, 2, pix) != 0)
230 >                        72., 72./paspect, 2, pix) != 0)
231                  return(-1);
232                                          /* free data and we're done */
233          free((void *)pix);
# Line 219 | Line 235 | register PICTURE       *pp;
235   }
236  
237  
238 < tmap_tiff(fname, tp)                    /* tone map SGILOG TIFF */
239 < char    *fname;
240 < TIFF    *tp;
238 > static int
239 > tmap_tiff(                      /* tone map SGILOG TIFF */
240 >        char    *fname,
241 >        TIFF    *tp
242 > )
243   {
244          float   xres, yres;
245          uint16  orient, resunit, phot;
246          int     xsiz, ysiz;
247 <        BYTE    *pix;
247 >        uby8    *pix;
248                                          /* check to make sure it's SGILOG */
249          TIFFGetFieldDefaulted(tp, TIFFTAG_PHOTOMETRIC, &phot);
250          if ((phot == PHOTOMETRIC_LOGL) | (phot == PHOTOMETRIC_MINISBLACK))
# Line 250 | Line 268 | TIFF   *tp;
268   }
269  
270  
271 < putimage(or, xs, ys, xr, yr, ru, pd)    /* write out our image */
272 < uint16  or;
273 < uint32  xs, ys;
274 < float   xr, yr;
275 < uint16 ru;
276 < BYTE    *pd;
271 > static int
272 > putimage(       /* write out our image */
273 >        uint16  or,
274 >        uint32  xs,
275 >        uint32  ys,
276 >        float   xr,
277 >        float   yr,
278 >        uint16  ru,
279 >        uby8    *pd
280 > )
281   {
282          register int    y;
283          uint32  rowsperstrip;
# Line 278 | Line 300 | BYTE   *pd;
300          TIFFSetField(tifout, TIFFTAG_IMAGEWIDTH, xs);
301          TIFFSetField(tifout, TIFFTAG_IMAGELENGTH, ys);
302          TIFFSetField(tifout, TIFFTAG_RESOLUTIONUNIT, ru);
303 +        TIFFSetField(tifout, TIFFTAG_COMPRESSION, comp);
304          TIFFSetField(tifout, TIFFTAG_XRESOLUTION, xr);
305          TIFFSetField(tifout, TIFFTAG_YRESOLUTION, yr);
306          TIFFSetField(tifout, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines