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.8 by schorsch, Sun Mar 28 20:33:14 2004 UTC vs.
Revision 3.16 by greg, Wed Apr 7 21:13:52 2021 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   * Tone map SGILOG TIFF or Radiance picture and output 24-bit RGB TIFF
6   */
7  
8 #include <stdio.h>
8   #include <math.h>
10 #include <time.h>
11 #include <string.h>
9  
10 + #include "rtio.h"
11 + #include "platform.h"
12   #include "tiffio.h"
13   #include "color.h"
14   #include "tonemap.h"
# Line 22 | Line 21 | int    flags = TM_F_CAMERA;            /* tone-mapping flags */
21   RGBPRIMP        rgbp = stdprims;        /* display primaries */
22   RGBPRIMS        myprims;                /* overriding display primaries */
23   double  ldmax = 100.;                   /* maximum display luminance */
24 < double  lddyn = 32.;                    /* display dynamic range */
24 > double  lddyn = 100.;                   /* display dynamic range */
25   double  gamv = 2.2;                     /* display gamma value */
26  
27   short   ortab[8] = {            /* orientation conversion table */
# Line 38 | Line 37 | short  ortab[8] = {            /* orientation conversion table */
37  
38   typedef struct {
39          FILE    *fp;            /* file pointer */
40 <        char    fmt[32];        /* picture format */
40 >        char    fmt[MAXFMTLEN]; /* picture format */
41          double  pa;             /* pixel aspect ratio */
42          RESOLU  rs;             /* picture resolution */
43   } PICTURE;
44  
45 < //extern PICTURE        *openpicture();
45 > uint16  comp = COMPRESSION_NONE;        /* TIFF compression mode */
46  
47   #define closepicture(p)         (fclose((p)->fp),free((void *)(p)))
48  
49   static gethfunc headline;
50  
51 < static int headline(char        *s, void *pp);
52 < static PICTURE * openpicture(char       *fname);
53 < static int tmap_picture(char    *fname, PICTURE *pp);
54 < static int tmap_tiff(char       *fname, TIFF    *tp);
55 < static int putimage(uint16      or, uint32      xs, uint32      ys, float       xr, float       yr,
56 <        uint16 ru, BYTE *pd);
51 > static int headline(char *s, void *pp);
52 > static PICTURE *openpicture(char *fname);
53 > static int tmap_picture(char *fname, PICTURE *pp);
54 > static int tmap_tiff(char *fname, TIFF *tp);
55 > static int putimage(uint16 or, uint32 xs, uint32 ys, float xr, float yr,
56 >        uint16 ru, uby8 *pd);
57  
58  
59   int
# Line 96 | Line 95 | main(
95                          if (argc-i < 2) goto userr;
96                          lddyn = atof(argv[++i]);
97                          break;
98 +                case 'z':                       /* LZW compression */
99 +                        comp = COMPRESSION_LZW;
100 +                        break;
101                  case 'p':                       /* set display primaries */
102                          if (argc-i < 9) goto userr;
103                          myprims[RED][CIEX] = atof(argv[++i]);
# Line 134 | Line 136 | main(
136          exit(rval==0 ? 0 : 1);
137   userr:
138          fprintf(stderr,
139 < "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",
139 > "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",
140                          argv[0]);
141          exit(1);
142   }
# Line 181 | Line 183 | openpicture(                   /* open/check Radiance picture file */
183                                          /* else try opening it */
184          if ((fp = fopen(fname, "r")) == NULL)
185                  return(NULL);
186 +        SET_FILE_BINARY(fp);
187                                          /* allocate struct */
188          if ((pp = (PICTURE *)malloc(sizeof(PICTURE))) == NULL)
189                  return(NULL);           /* serious error -- should exit? */
# Line 208 | Line 211 | tmap_picture(                  /* tone map Radiance picture */
211   )
212   {
213          uint16  orient;
214 +        double  paspect = (pp->rs.rt & YMAJOR) ? pp->pa : 1./pp->pa;
215          int     xsiz, ysiz;
216 <        BYTE    *pix;
216 >        uby8    *pix;
217                                          /* read and tone map picture */
218          if (tmMapPicture(&pix, &xsiz, &ysiz, flags,
219                          rgbp, gamv, lddyn, ldmax, fname, pp->fp) != TM_E_OK)
# Line 221 | Line 225 | tmap_picture(                  /* tone map Radiance picture */
225          orient++;
226                                          /* put out our image */
227          if (putimage(orient, (uint32)xsiz, (uint32)ysiz,
228 <                        72., 72./pp->pa, 2, pix) != 0)
228 >                        72., 72./paspect, 2, pix) != 0)
229                  return(-1);
230                                          /* free data and we're done */
231          free((void *)pix);
# Line 238 | Line 242 | tmap_tiff(                     /* tone map SGILOG TIFF */
242          float   xres, yres;
243          uint16  orient, resunit, phot;
244          int     xsiz, ysiz;
245 <        BYTE    *pix;
245 >        uby8    *pix;
246                                          /* check to make sure it's SGILOG */
247          TIFFGetFieldDefaulted(tp, TIFFTAG_PHOTOMETRIC, &phot);
248          if ((phot == PHOTOMETRIC_LOGL) | (phot == PHOTOMETRIC_MINISBLACK))
# Line 269 | Line 273 | putimage(      /* write out our image */
273          uint32  ys,
274          float   xr,
275          float   yr,
276 <        uint16 ru,
277 <        BYTE    *pd
276 >        uint16  ru,
277 >        uby8    *pd
278   )
279   {
280          register int    y;
# Line 294 | Line 298 | putimage(      /* write out our image */
298          TIFFSetField(tifout, TIFFTAG_IMAGEWIDTH, xs);
299          TIFFSetField(tifout, TIFFTAG_IMAGELENGTH, ys);
300          TIFFSetField(tifout, TIFFTAG_RESOLUTIONUNIT, ru);
301 +        TIFFSetField(tifout, TIFFTAG_COMPRESSION, comp);
302          TIFFSetField(tifout, TIFFTAG_XRESOLUTION, xr);
303          TIFFSetField(tifout, TIFFTAG_YRESOLUTION, yr);
304          TIFFSetField(tifout, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines