--- ray/src/px/normtiff.c 2005/06/14 22:23:31 3.9 +++ ray/src/px/normtiff.c 2021/04/07 21:13:52 3.16 @@ -1,15 +1,14 @@ #ifndef lint -static const char RCSid[] = "$Id: normtiff.c,v 3.9 2005/06/14 22:23:31 greg Exp $"; +static const char RCSid[] = "$Id: normtiff.c,v 3.16 2021/04/07 21:13:52 greg Exp $"; #endif /* * Tone map SGILOG TIFF or Radiance picture and output 24-bit RGB TIFF */ -#include #include -#include -#include +#include "rtio.h" +#include "platform.h" #include "tiffio.h" #include "color.h" #include "tonemap.h" @@ -22,7 +21,7 @@ int flags = TM_F_CAMERA; /* tone-mapping flags */ RGBPRIMP rgbp = stdprims; /* display primaries */ RGBPRIMS myprims; /* overriding display primaries */ double ldmax = 100.; /* maximum display luminance */ -double lddyn = 32.; /* display dynamic range */ +double lddyn = 100.; /* display dynamic range */ double gamv = 2.2; /* display gamma value */ short ortab[8] = { /* orientation conversion table */ @@ -38,7 +37,7 @@ short ortab[8] = { /* orientation conversion table */ typedef struct { FILE *fp; /* file pointer */ - char fmt[32]; /* picture format */ + char fmt[MAXFMTLEN]; /* picture format */ double pa; /* pixel aspect ratio */ RESOLU rs; /* picture resolution */ } PICTURE; @@ -54,7 +53,7 @@ static PICTURE *openpicture(char *fname); static int tmap_picture(char *fname, PICTURE *pp); static int tmap_tiff(char *fname, TIFF *tp); static int putimage(uint16 or, uint32 xs, uint32 ys, float xr, float yr, - uint16 ru, BYTE *pd); + uint16 ru, uby8 *pd); int @@ -137,7 +136,7 @@ main( exit(rval==0 ? 0 : 1); userr: fprintf(stderr, -"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|pic} output.tif\n", +"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", argv[0]); exit(1); } @@ -184,6 +183,7 @@ openpicture( /* open/check Radiance picture file */ /* else try opening it */ if ((fp = fopen(fname, "r")) == NULL) return(NULL); + SET_FILE_BINARY(fp); /* allocate struct */ if ((pp = (PICTURE *)malloc(sizeof(PICTURE))) == NULL) return(NULL); /* serious error -- should exit? */ @@ -211,8 +211,9 @@ tmap_picture( /* tone map Radiance picture */ ) { uint16 orient; + double paspect = (pp->rs.rt & YMAJOR) ? pp->pa : 1./pp->pa; int xsiz, ysiz; - BYTE *pix; + uby8 *pix; /* read and tone map picture */ if (tmMapPicture(&pix, &xsiz, &ysiz, flags, rgbp, gamv, lddyn, ldmax, fname, pp->fp) != TM_E_OK) @@ -224,7 +225,7 @@ tmap_picture( /* tone map Radiance picture */ orient++; /* put out our image */ if (putimage(orient, (uint32)xsiz, (uint32)ysiz, - 72., 72./pp->pa, 2, pix) != 0) + 72., 72./paspect, 2, pix) != 0) return(-1); /* free data and we're done */ free((void *)pix); @@ -241,7 +242,7 @@ tmap_tiff( /* tone map SGILOG TIFF */ float xres, yres; uint16 orient, resunit, phot; int xsiz, ysiz; - BYTE *pix; + uby8 *pix; /* check to make sure it's SGILOG */ TIFFGetFieldDefaulted(tp, TIFFTAG_PHOTOMETRIC, &phot); if ((phot == PHOTOMETRIC_LOGL) | (phot == PHOTOMETRIC_MINISBLACK)) @@ -273,7 +274,7 @@ putimage( /* write out our image */ float xr, float yr, uint16 ru, - BYTE *pd + uby8 *pd ) { register int y;