IccMAX 2.1.27
Color Profile Tools
Loading...
Searching...
No Matches
CIccToneMapFunc Class Reference

#include <IccMpeBasic.h>

+ Inheritance diagram for CIccToneMapFunc:

Public Member Functions

 CIccToneMapFunc ()
 
virtual ~CIccToneMapFunc ()
 
icFloatNumber Apply (icFloatNumber lumValue, icFloatNumber pixelValue) const
 
bool Begin ()
 
void Describe (std::string &sDescription, int nVerboseness=0)
 
virtual const char * GetClassName () const
 
virtual icToneFunctionSignature GetType () const
 
virtual CIccToneMapFuncNewCopy () const
 
CIccToneMapFuncoperator= (const CIccToneMapFunc &toneMap)
 
bool Read (icUInt32Number size, CIccIO *pIO)
 
bool SetFunction (icUInt16Number nFunc, icUInt8Number, icFloatNumber *pParams)
 
icValidateStatus Validate (std::string &sFuncReport, int nVerboseness=0) const
 
bool Write (CIccIO *pIO)
 

Protected Member Functions

int NumArgs () const
 

Protected Attributes

icUInt16Number m_nFunctionType
 
icUInt8Number m_nParameters
 
icUInt32Number m_nReserved
 
icUInt16Number m_nReserved2
 
icFloatNumberm_params
 

Detailed Description

Class: CIccToneMapFunc

Purpose: The parametric function to apply a tone map based on mapped luminance and channel value

Constructor & Destructor Documentation

◆ CIccToneMapFunc()

CIccToneMapFunc::CIccToneMapFunc ( )
3898{
3899 m_nFunctionType = 0;
3900 m_nParameters = 0;
3901 m_params = NULL;
3902 m_nReserved = 0;
3903 m_nReserved2 = 0;
3904}
icUInt16Number m_nReserved2
Definition IccMpeBasic.h:535
icUInt32Number m_nReserved
Definition IccMpeBasic.h:534
icUInt16Number m_nFunctionType
Definition IccMpeBasic.h:531
icUInt8Number m_nParameters
Definition IccMpeBasic.h:532
icFloatNumber * m_params
Definition IccMpeBasic.h:533

References m_nFunctionType, m_nParameters, m_nReserved, m_nReserved2, and m_params.

Referenced by NewCopy(), and CIccMpeToneMap::NewToneMapFunc().

+ Here is the caller graph for this function:

◆ ~CIccToneMapFunc()

CIccToneMapFunc::~CIccToneMapFunc ( )
virtual
3908{
3909 if (m_params)
3910 free(m_params);
3911}

References m_params.

Member Function Documentation

◆ Apply()

icFloatNumber CIccToneMapFunc::Apply ( icFloatNumber  lumValue,
icFloatNumber  pixelValue 
) const
4096{
4097 if (!m_nFunctionType && m_params) {
4098 return m_params[0] * lumValue * (pixelValue + m_params[1]) + m_params[2];
4099 }
4100
4101 return 0;
4102}

References m_nFunctionType, and m_params.

Referenced by CIccMpeToneMap::Apply().

+ Here is the caller graph for this function:

◆ Begin()

bool CIccToneMapFunc::Begin ( )
4085{
4086 if (m_nFunctionType != 0x0000)
4087 return false;
4088
4089 if (m_nParameters < NumArgs() || !m_params)
4090 return false;
4091
4092 return true;
4093}
int NumArgs() const
Definition IccMpeBasic.cpp:3947

References m_nFunctionType, m_nParameters, m_params, and NumArgs().

Referenced by CIccMpeToneMap::Begin().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Describe()

void CIccToneMapFunc::Describe ( std::string &  sDescription,
int  nVerboseness = 0 
)
3973{
3974 icChar buf[128];
3975
3976 sprintf(buf, "ToneFunctionType: %04Xh\n", m_nFunctionType);
3977 sDescription += buf;
3978
3979 switch (m_nFunctionType) {
3980 case 0x0000:
3981 sprintf(buf, "Y = %.8f * M * ( X + %.8f) + %.8f\n\n", m_params[0], m_params[1], m_params[2]);
3982 sDescription += buf;
3983 return;
3984
3985 default:
3986 int i;
3987 sprintf(buf, "Unknown Function with %d parameters:\n\n", m_nParameters);
3988 sDescription += buf;
3989
3990 for (i = 0; i < m_nParameters; i++) {
3991 sprintf(buf, "Param[%d] = %.8lf\n\n", i, m_params[i]);
3992 sDescription += buf;
3993 }
3994
3995 }
3996}
char icChar
Definition IccDefs.h:110

References m_nFunctionType, m_nParameters, and m_params.

Referenced by CIccMpeToneMap::Describe().

+ Here is the caller graph for this function:

◆ GetClassName()

virtual const char * CIccToneMapFunc::GetClassName ( ) const
inlinevirtual

Reimplemented in CIccXmlToneMapFunc.

514{ return "CIccToneMapFunc"; }

Referenced by CIccMpeXmlToneMap::ToXml().

+ Here is the caller graph for this function:

◆ GetType()

virtual icToneFunctionSignature CIccToneMapFunc::GetType ( ) const
inlinevirtual
513{ return icSigToneMapFunction; }
@ icSigToneMapFunction
Definition icProfileHeader.h:1077

References icSigToneMapFunction.

Referenced by Write().

+ Here is the caller graph for this function:

◆ NewCopy()

CIccToneMapFunc * CIccToneMapFunc::NewCopy ( ) const
virtual
3938{
3939 CIccToneMapFunc* rv = new CIccToneMapFunc();
3940
3941 if (rv)
3942 *rv = *this;
3943
3944 return rv;
3945}
Definition IccMpeBasic.h:506
CIccToneMapFunc()
Definition IccMpeBasic.cpp:3897

References CIccToneMapFunc(), and operator=().

Referenced by CIccMpeToneMap::CopyToneFuncs().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ NumArgs()

int CIccToneMapFunc::NumArgs ( ) const
protected
3948{
3949 if (m_nFunctionType == 0)
3950 return 3;
3951 return 0;
3952}

References m_nFunctionType.

Referenced by Begin(), SetFunction(), and Write().

+ Here is the caller graph for this function:

◆ operator=()

CIccToneMapFunc & CIccToneMapFunc::operator= ( const CIccToneMapFunc toneMap)
3914{
3915 if (&toneMapFunc == this)
3916 return *this;
3917
3918 m_nFunctionType = toneMapFunc.m_nFunctionType;
3919 m_nParameters = toneMapFunc.m_nParameters;
3920
3921 if (m_params)
3922 free(m_params);
3923 if (toneMapFunc.m_nParameters && toneMapFunc.m_params) {
3924 m_params = (icFloatNumber*)malloc(m_nParameters * sizeof(icFloatNumber));
3925 if (m_params)
3926 memcpy(m_params, toneMapFunc.m_params, m_nParameters * sizeof(icFloatNumber));
3927 }
3928 else
3929 m_params = NULL;
3930
3931 m_nReserved = toneMapFunc.m_nReserved;
3932 m_nReserved2 = toneMapFunc.m_nReserved2;
3933
3934 return *this;
3935}
float icFloatNumber
Definition IccDefs.h:101

References m_nFunctionType, m_nParameters, m_nReserved, m_nReserved2, and m_params.

Referenced by CIccXmlToneMapFunc::NewCopy(), and NewCopy().

+ Here is the caller graph for this function:

◆ Read()

bool CIccToneMapFunc::Read ( icUInt32Number  size,
CIccIO pIO 
)
3999{
4001
4002 icUInt32Number headerSize = sizeof(icTagTypeSignature) +
4003 sizeof(icUInt32Number) +
4004 sizeof(icUInt16Number) +
4005 sizeof(icUInt16Number);
4006
4007 if (headerSize > size)
4008 return false;
4009
4010 if (!pIO) {
4011 return false;
4012 }
4013
4014 if (!pIO->Read32(&sig))
4015 return false;
4016
4017 if (sig != icSigToneMapFunction)
4018 return false;
4019
4020 if (!pIO->Read32(&m_nReserved))
4021 return false;
4022
4023 if (!pIO->Read16(&m_nFunctionType))
4024 return false;
4025
4026 if (!pIO->Read16(&m_nReserved2))
4027 return false;
4028
4029 if (m_params) {
4030 free(m_params);
4031 }
4032
4033 m_nParameters = (icUInt8Number)((size - headerSize)/sizeof(icFloatNumber));
4034
4035 if (m_nParameters) {
4036
4037 m_params = (icFloatNumber*)malloc(m_nParameters * sizeof(icFloatNumber));
4038 if (!m_params)
4039 return false;
4040
4042 return false;
4043 }
4044 }
4045 else
4046 m_params = NULL;
4047
4048 return true;
4049
4050}
unsigned char icUInt8Number
Definition icProfileHeader.h:250
unsigned short icUInt16Number
Definition icProfileHeader.h:256
icCurveSegSignature
Definition icProfileHeader.h:1045
unsigned long icUInt32Number
Definition icProfileHeader.h:262
icTagTypeSignature
Definition icProfileHeader.h:526
icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:302
icInt32Number Read16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:114
icInt32Number Read32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:143

References icSigToneMapFunction, m_nFunctionType, m_nParameters, m_nReserved, m_nReserved2, m_params, CIccIO::Read16(), CIccIO::Read32(), and CIccIO::ReadFloat32Float().

Referenced by CIccMpeToneMap::Read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetFunction()

bool CIccToneMapFunc::SetFunction ( icUInt16Number  nFunc,
icUInt8Number  nParams,
icFloatNumber pParams 
)
3955{
3956 m_nFunctionType = nFunc;
3957
3958 if (m_params)
3959 free(m_params);
3960
3961 int nArgs = NumArgs();
3963 if (nArgs && pParams) {
3964 m_params = (icFloatNumber*)calloc(nArgs, sizeof(icFloatNumber));
3965 if (m_params)
3966 memcpy(m_params, pParams, icIntMin(nArgs, nParams) * sizeof(icFloatNumber));
3967 }
3968
3969 return nParams == NumArgs();
3970}
ICCPROFLIB_API icUInt32Number icIntMin(icUInt32Number v1, icUInt32Number v2)
Definition IccUtil.cpp:908

References icIntMin(), m_nFunctionType, m_nParameters, m_params, and NumArgs().

+ Here is the call graph for this function:

◆ Validate()

icValidateStatus CIccToneMapFunc::Validate ( std::string &  sFuncReport,
int  nVerboseness = 0 
) const
4105{
4106 CIccInfo Info;
4107
4109
4110 if (m_nReserved || m_nReserved2) {
4111 sReport += icMsgValidateWarning;
4112 sReport += " formula curve has non zero reserved data.\n";
4114 }
4115
4116 switch (m_nFunctionType) {
4117 case 0x0000:
4118 if (!m_params || m_nParameters < 3) {
4119 sReport += icMsgValidateCriticalError;
4120 sReport += " Tone mapping function has invalid parameters.\n";
4122 }
4123 else if (m_nParameters > 3) {
4124 sReport += icMsgValidateWarning;
4125 sReport += " tone mapping function has too many formulaCurveSegment parameters.\n";
4127 }
4128 break;
4129
4130 default:
4131 {
4132 icChar buf[128];
4133 sReport += icMsgValidateCriticalError;
4134 sprintf(buf, " tone mapping function uses unknown function type %d\n", m_nFunctionType);
4135 sReport += buf;
4137 }
4138 }
4139
4140 return rv;
4141}
icValidateStatus
Definition IccDefs.h:119
@ icValidateOK
Definition IccDefs.h:120
@ icValidateWarning
Definition IccDefs.h:121
@ icValidateCriticalError
Definition IccDefs.h:123
ICCPROFLIB_API const char * icMsgValidateWarning
Definition IccUtil.cpp:90
ICCPROFLIB_API const char * icMsgValidateCriticalError
Definition IccUtil.cpp:92
ICCPROFLIB_API icValidateStatus icMaxStatus(icValidateStatus s1, icValidateStatus s2)
Definition IccUtil.cpp:244
Definition IccUtil.h:303

References icMaxStatus(), icMsgValidateCriticalError, icMsgValidateWarning, icValidateCriticalError, icValidateOK, icValidateWarning, m_nFunctionType, m_nParameters, m_nReserved, m_nReserved2, and m_params.

Referenced by CIccMpeToneMap::Validate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Write()

bool CIccToneMapFunc::Write ( CIccIO pIO)
4053{
4055
4056 if (!pIO)
4057 return false;
4058
4059 if (!pIO->Write32(&sig))
4060 return false;
4061
4062 if (!pIO->Write32(&m_nReserved))
4063 return false;
4064
4065 if (!pIO->Write16(&m_nFunctionType))
4066 return false;
4067
4068 if (!pIO->Write16(&m_nReserved2))
4069 return false;
4070
4071
4072 if (m_nParameters != NumArgs())
4073 return false;
4074
4075 if (m_nParameters) {
4077 return false;
4078 }
4079
4080 return true;
4081
4082}
icToneFunctionSignature
Definition icProfileHeader.h:1076
virtual icToneFunctionSignature GetType() const
Definition IccMpeBasic.h:513
icInt32Number Write16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:122
icInt32Number Write32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:152
icInt32Number WriteFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:321

References GetType(), m_nFunctionType, m_nParameters, m_nReserved, m_nReserved2, m_params, NumArgs(), CIccIO::Write16(), CIccIO::Write32(), and CIccIO::WriteFloat32Float().

Referenced by CIccMpeToneMap::Write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ m_nFunctionType

◆ m_nParameters

◆ m_nReserved

icUInt32Number CIccToneMapFunc::m_nReserved
protected

◆ m_nReserved2

◆ m_params


The documentation for this class was generated from the following files: