--- ray/src/common/tonemap.h 2005/01/07 20:33:02 3.17 +++ ray/src/common/tonemap.h 2005/11/15 06:53:00 3.21 @@ -1,4 +1,4 @@ -/* RCSid $Id: tonemap.h,v 3.17 2005/01/07 20:33:02 greg Exp $ */ +/* RCSid $Id: tonemap.h,v 3.21 2005/11/15 06:53:00 greg Exp $ */ /* * Header file for tone mapping functions. * @@ -14,7 +14,7 @@ extern "C" { #endif /**** Argument Macros ****/ - /* Flags of what to do */ + /* flags of what to do */ #define TM_F_HCONTR 01 /* human contrast sensitivity */ #define TM_F_MESOPIC 02 /* mesopic color sensitivity */ #define TM_F_LINEAR 04 /* linear brightness mapping */ @@ -66,13 +66,11 @@ extern "C" { #endif extern char *tmErrorMessage[]; /* error messages */ -extern int tmLastError; /* last error incurred by library */ -extern char *tmLastFunction; /* error-generating function name */ typedef short TMbright; /* encoded luminance type */ /* basic tone mapping data structure */ -typedef struct tmStruct { +typedef struct { int flags; /* flags of what to do */ RGBPRIMP monpri; /* monitor RGB primaries */ double mongam; /* monitor gamma value (approx.) */ @@ -80,12 +78,15 @@ typedef struct tmStruct { int cdiv[3]; /* computed color divisors */ RGBPRIMP inppri; /* current input primaries */ double inpsf; /* current input scalefactor */ + MEM_PTR inpdat; /* current input client data */ COLORMAT cmat; /* color conversion matrix */ TMbright hbrmin, hbrmax; /* histogram brightness limits */ int *histo; /* input histogram */ TMbright mbrmin, mbrmax; /* mapped brightness limits */ unsigned short *lumap; /* computed luminance map */ MEM_PTR pd[TM_MAXPKG]; /* pointers to private data */ + int lastError; /* last error incurred */ + const char *lastFunc; /* error-generating function name */ } TMstruct; /* conversion package functions */ @@ -117,6 +118,11 @@ extern int tmNumPkgs; /* number of registered packages /**** Library Function Calls ****/ +extern TMbright +tmCvLuminance(double lum); +/* + Convert a single luminance value to an encoded brightness value. + */ extern TMstruct * tmInit(int flags, RGBPRIMP monpri, double gamval); @@ -131,13 +137,14 @@ tmInit(int flags, RGBPRIMP monpri, double gamval); */ extern int -tmSetSpace(TMstruct *tms, RGBPRIMP pri, double sf); +tmSetSpace(TMstruct *tms, RGBPRIMP pri, double sf, MEM_PTR dat); /* Set color primaries and scale factor for incoming scanlines. tms - tone mapping structure pointer. pri - RGB color input primaries (Note 1). sf - scale factor to get to luminance in cd/m^2. + dat - application-specific data (NULL if not needed) returns - 0 on success, TM_E_* code on failure. */ @@ -175,6 +182,7 @@ tmFixedMapping(TMstruct *tms, double expmult, double g tms - tone mapping structure pointer. expmult - the fixed exposure multiplier to use. gamval - display gamma response (0. for default). + returns - 0 on success, TM_E_* on error. */ @@ -214,6 +222,7 @@ tmDup(TMstruct *orig); Duplicate the given tone mapping into a new struct. orig - tone mapping structure to duplicate. + returns - pointer to new struct, or NULL on error. */