--- ray/src/px/normtiff.c 2003/02/22 02:07:27 3.4 +++ ray/src/px/normtiff.c 2004/03/28 20:33:14 3.8 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: normtiff.c,v 3.4 2003/02/22 02:07:27 greg Exp $"; +static const char RCSid[] = "$Id: normtiff.c,v 3.8 2004/03/28 20:33:14 schorsch Exp $"; #endif /* * Tone map SGILOG TIFF or Radiance picture and output 24-bit RGB TIFF @@ -8,9 +8,12 @@ static const char RCSid[] = "$Id: normtiff.c,v 3.4 200 #include #include #include +#include + #include "tiffio.h" #include "color.h" #include "tonemap.h" +#include "tmaptiff.h" #include "resolu.h" @@ -40,14 +43,25 @@ typedef struct { RESOLU rs; /* picture resolution */ } PICTURE; -extern PICTURE *openpicture(); +//extern PICTURE *openpicture(); #define closepicture(p) (fclose((p)->fp),free((void *)(p))) +static gethfunc headline; -main(argc, argv) -int argc; -char *argv[]; +static int headline(char *s, void *pp); +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); + + +int +main( + int argc, + char *argv[] +) { PICTURE *pin = NULL; TIFF *tin = NULL; @@ -126,10 +140,11 @@ userr: } -int -headline(s, pp) /* process line from header */ -char *s; -register PICTURE *pp; +static int +headline( /* process line from header */ + char *s, + void *pp +) { register char *cp; @@ -137,16 +152,17 @@ register PICTURE *pp; if (*cp & 0x80) return(-1); /* non-ascii in header */ if (isaspect(s)) - pp->pa *= aspectval(s); + ((PICTURE *)pp)->pa *= aspectval(s); else - formatval(pp->fmt, s); + formatval(((PICTURE *)pp)->fmt, s); return(0); } -PICTURE * -openpicture(fname) /* open/check Radiance picture file */ -char *fname; +static PICTURE * +openpicture( /* open/check Radiance picture file */ + char *fname +) { FILE *fp; register PICTURE *pp; @@ -170,7 +186,7 @@ char *fname; return(NULL); /* serious error -- should exit? */ pp->fp = fp; pp->fmt[0] = '\0'; pp->pa = 1.; /* load header */ - if (getheader(fp, headline, (char *)pp) < 0) { + if (getheader(fp, headline, pp) < 0) { closepicture(pp); return(NULL); } @@ -185,10 +201,11 @@ char *fname; } -int -tmap_picture(fname, pp) /* tone map Radiance picture */ -char *fname; -register PICTURE *pp; +static int +tmap_picture( /* tone map Radiance picture */ + char *fname, + register PICTURE *pp +) { uint16 orient; int xsiz, ysiz; @@ -212,9 +229,11 @@ register PICTURE *pp; } -tmap_tiff(fname, tp) /* tone map SGILOG TIFF */ -char *fname; -TIFF *tp; +static int +tmap_tiff( /* tone map SGILOG TIFF */ + char *fname, + TIFF *tp +) { float xres, yres; uint16 orient, resunit, phot; @@ -222,14 +241,7 @@ TIFF *tp; BYTE *pix; /* check to make sure it's SGILOG */ TIFFGetFieldDefaulted(tp, TIFFTAG_PHOTOMETRIC, &phot); - if (phot != PHOTOMETRIC_LOGLUV && phot != PHOTOMETRIC_LOGL) { - if (!(flags & TM_F_NOSTDERR)) { - fputs(fname, stderr); - fputs(": TIFF must be in SGILOG format\n", stderr); - } - return(-1); - } - if (phot == PHOTOMETRIC_LOGL) + if ((phot == PHOTOMETRIC_LOGL) | (phot == PHOTOMETRIC_MINISBLACK)) flags |= TM_F_BW; /* read and tone map TIFF */ if (tmMapTIFF(&pix, &xsiz, &ysiz, flags, @@ -250,12 +262,16 @@ TIFF *tp; } -putimage(or, xs, ys, xr, yr, ru, pd) /* write out our image */ -uint16 or; -uint32 xs, ys; -float xr, yr; -uint16 ru; -BYTE *pd; +static int +putimage( /* write out our image */ + uint16 or, + uint32 xs, + uint32 ys, + float xr, + float yr, + uint16 ru, + BYTE *pd +) { register int y; uint32 rowsperstrip;