Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CIccToneMapFunc Class Reference

Class: CIccToneMapFunc. More...

#include <IccMpeBasic.h>

+ Inheritance diagram for CIccToneMapFunc:
+ Collaboration diagram for CIccToneMapFunc:

Public Member Functions

icFloatNumber Apply (icFloatNumber lumValue, icFloatNumber pixelValue) const
 
bool Begin ()
 
 CIccToneMapFunc ()
 
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)
 
virtual ~CIccToneMapFunc ()
 

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

Definition at line 505 of file IccMpeBasic.h.

Constructor & Destructor Documentation

◆ CIccToneMapFunc()

CIccToneMapFunc::CIccToneMapFunc ( )

Definition at line 3868 of file IccMpeBasic.cpp.

3869{
3870 m_nFunctionType = 0;
3871 m_nParameters = 0;
3872 m_params = NULL;
3873 m_nReserved = 0;
3874 m_nReserved2 = 0;
3875}
icUInt16Number m_nReserved2
icUInt32Number m_nReserved
icUInt16Number m_nFunctionType
icUInt8Number m_nParameters
icFloatNumber * m_params

◆ ~CIccToneMapFunc()

CIccToneMapFunc::~CIccToneMapFunc ( )
virtual

Definition at line 3878 of file IccMpeBasic.cpp.

3879{
3880 if (m_params)
3881 free(m_params);
3882}

Member Function Documentation

◆ Apply()

icFloatNumber CIccToneMapFunc::Apply ( icFloatNumber lumValue,
icFloatNumber pixelValue ) const

Definition at line 4066 of file IccMpeBasic.cpp.

4067{
4068 if (!m_nFunctionType && m_params) {
4069 return m_params[0] * lumValue * (pixelValue + m_params[1]) + m_params[2];
4070 }
4071
4072 return 0;
4073}

◆ Begin()

bool CIccToneMapFunc::Begin ( )

Definition at line 4055 of file IccMpeBasic.cpp.

4056{
4057 if (m_nFunctionType != 0x0000)
4058 return false;
4059
4060 if (m_nParameters < NumArgs() || !m_params)
4061 return false;
4062
4063 return true;
4064}
int NumArgs() const

◆ Describe()

void CIccToneMapFunc::Describe ( std::string & sDescription,
int nVerboseness = 0 )

Definition at line 3943 of file IccMpeBasic.cpp.

3944{
3945 icChar buf[128];
3946
3947 sprintf(buf, "ToneFunctionType: %04Xh\n", m_nFunctionType);
3948 sDescription += buf;
3949
3950 switch (m_nFunctionType) {
3951 case 0x0000:
3952 sprintf(buf, "Y = %.8f * M * ( X + %.8f) + %.8f\n\n", m_params[0], m_params[1], m_params[2]);
3953 sDescription += buf;
3954 return;
3955
3956 default:
3957 int i;
3958 sprintf(buf, "Unknown Function with %d parameters:\n\n", m_nParameters);
3959 sDescription += buf;
3960
3961 for (i = 0; i < m_nParameters; i++) {
3962 sprintf(buf, "Param[%d] = %.8lf\n\n", i, m_params[i]);
3963 sDescription += buf;
3964 }
3965
3966 }
3967}
char icChar
Definition IccDefs.h:109

◆ GetClassName()

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

Reimplemented in CIccXmlToneMapFunc.

Definition at line 514 of file IccMpeBasic.h.

514{ return "CIccToneMapFunc"; }

◆ GetType()

virtual icToneFunctionSignature CIccToneMapFunc::GetType ( ) const
inlinevirtual

Definition at line 513 of file IccMpeBasic.h.

513{ return icSigToneMapFunction; }
@ icSigToneMapFunction

References icSigToneMapFunction.

◆ NewCopy()

CIccToneMapFunc * CIccToneMapFunc::NewCopy ( ) const
virtual

Definition at line 3908 of file IccMpeBasic.cpp.

3909{
3910 CIccToneMapFunc* rv = new CIccToneMapFunc();
3911
3912 if (rv)
3913 *rv = *this;
3914
3915 return rv;
3916}
Class: CIccToneMapFunc.

Referenced by CIccMpeToneMap::CopyToneFuncs().

+ Here is the caller graph for this function:

◆ NumArgs()

int CIccToneMapFunc::NumArgs ( ) const
protected

Definition at line 3918 of file IccMpeBasic.cpp.

3919{
3920 if (m_nFunctionType == 0)
3921 return 3;
3922 return 0;
3923}

◆ operator=()

CIccToneMapFunc & CIccToneMapFunc::operator= ( const CIccToneMapFunc & toneMap)

Definition at line 3884 of file IccMpeBasic.cpp.

3885{
3886 if (&toneMapFunc == this)
3887 return *this;
3888
3889 m_nFunctionType = toneMapFunc.m_nFunctionType;
3890 m_nParameters = toneMapFunc.m_nParameters;
3891
3892 if (m_params)
3893 free(m_params);
3894 if (toneMapFunc.m_nParameters && toneMapFunc.m_params) {
3895 m_params = (icFloatNumber*)malloc(m_nParameters * sizeof(icFloatNumber));
3896 if (m_params)
3897 memcpy(m_params, toneMapFunc.m_params, m_nParameters * sizeof(icFloatNumber));
3898 }
3899 else
3900 m_params = NULL;
3901
3902 m_nReserved = toneMapFunc.m_nReserved;
3903 m_nReserved2 = toneMapFunc.m_nReserved2;
3904
3905 return *this;
3906}
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100

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

◆ Read()

bool CIccToneMapFunc::Read ( icUInt32Number size,
CIccIO * pIO )

Definition at line 3969 of file IccMpeBasic.cpp.

3970{
3972
3973 icUInt32Number headerSize = sizeof(icTagTypeSignature) +
3974 sizeof(icUInt32Number) +
3975 sizeof(icUInt16Number) +
3976 sizeof(icUInt16Number);
3977
3978 if (headerSize > size)
3979 return false;
3980
3981 if (!pIO) {
3982 return false;
3983 }
3984
3985 if (!pIO->Read32(&sig))
3986 return false;
3987
3989 return false;
3990
3991 if (!pIO->Read32(&m_nReserved))
3992 return false;
3993
3994 if (!pIO->Read16(&m_nFunctionType))
3995 return false;
3996
3997 if (!pIO->Read16(&m_nReserved2))
3998 return false;
3999
4000 if (m_params) {
4001 free(m_params);
4002 }
4003
4004 m_nParameters = (icUInt8Number)((size - headerSize)/sizeof(icFloatNumber));
4005
4006 if (m_nParameters) {
4007
4008 m_params = (icFloatNumber*)malloc(m_nParameters * sizeof(icFloatNumber));
4009 if (!m_params)
4010 return false;
4011
4013 return false;
4014 }
4015 }
4016 else
4017 m_params = NULL;
4018
4019 return true;
4020
4021}
icArraySignature sig
icTagTypeSignature
unsigned int icUInt32Number
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
unsigned char icUInt8Number
Number definitions.
unsigned short icUInt16Number
icCurveSegSignature
MPE Curve segment Signatures.

References icSigToneMapFunction, CIccIO::Read16(), CIccIO::Read32(), CIccIO::ReadFloat32Float(), and sig.

+ Here is the call graph for this function:

◆ SetFunction()

bool CIccToneMapFunc::SetFunction ( icUInt16Number nFunc,
icUInt8Number nParams,
icFloatNumber * pParams )

Definition at line 3925 of file IccMpeBasic.cpp.

3926{
3927 m_nFunctionType = nFunc;
3928
3929 if (m_params)
3930 free(m_params);
3931
3932 int nArgs = NumArgs();
3934 if (nArgs && pParams) {
3935 m_params = (icFloatNumber*)calloc(nArgs, sizeof(icFloatNumber));
3936 if (m_params)
3937 memcpy(m_params, pParams, icIntMin(nArgs, nParams) * sizeof(icFloatNumber));
3938 }
3939
3940 return nParams == NumArgs();
3941}
icUInt32Number icIntMin(icUInt32Number v1, icUInt32Number v2)
Definition IccUtil.cpp:908

References icIntMin().

+ Here is the call graph for this function:

◆ Validate()

icValidateStatus CIccToneMapFunc::Validate ( std::string & sFuncReport,
int nVerboseness = 0 ) const

Definition at line 4075 of file IccMpeBasic.cpp.

4076{
4077 CIccInfo Info;
4078
4080
4081 if (m_nReserved || m_nReserved2) {
4082 sReport += icMsgValidateWarning;
4083 sReport += " formula curve has non zero reserved data.\n";
4085 }
4086
4087 switch (m_nFunctionType) {
4088 case 0x0000:
4089 if (!m_params || m_nParameters < 3) {
4090 sReport += icMsgValidateCriticalError;
4091 sReport += " Tone mapping function has invalid parameters.\n";
4093 }
4094 else if (m_nParameters > 3) {
4095 sReport += icMsgValidateWarning;
4096 sReport += " tone mapping function has too many formulaCurveSegment parameters.\n";
4098 }
4099 break;
4100
4101 default:
4102 {
4103 icChar buf[128];
4104 sReport += icMsgValidateCriticalError;
4105 sprintf(buf, " tone mapping function uses unknown function type %d\n", m_nFunctionType);
4106 sReport += buf;
4108 }
4109 }
4110
4111 return rv;
4112}
icValidateStatus
Definition IccDefs.h:118
@ icValidateOK
Definition IccDefs.h:119
@ icValidateWarning
Definition IccDefs.h:120
@ icValidateCriticalError
Definition IccDefs.h:122
icValidateStatus icMaxStatus(icValidateStatus s1, icValidateStatus s2)
Name: icMaxStatus.
Definition IccUtil.cpp:244
const char * icMsgValidateWarning
Definition IccUtil.cpp:90
const char * icMsgValidateCriticalError
Definition IccUtil.cpp:92
Type: Class.
Definition IccUtil.h:303

References icMaxStatus(), icMsgValidateCriticalError, icMsgValidateWarning, icValidateCriticalError, icValidateOK, and icValidateWarning.

+ Here is the call graph for this function:

◆ Write()

bool CIccToneMapFunc::Write ( CIccIO * pIO)

Definition at line 4023 of file IccMpeBasic.cpp.

4024{
4026
4027 if (!pIO)
4028 return false;
4029
4030 if (!pIO->Write32(&sig))
4031 return false;
4032
4033 if (!pIO->Write32(&m_nReserved))
4034 return false;
4035
4036 if (!pIO->Write16(&m_nFunctionType))
4037 return false;
4038
4039 if (!pIO->Write16(&m_nReserved2))
4040 return false;
4041
4042
4043 if (m_nParameters != NumArgs())
4044 return false;
4045
4046 if (m_nParameters) {
4048 return false;
4049 }
4050
4051 return true;
4052
4053}
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
virtual icToneFunctionSignature GetType() const
icToneFunctionSignature
MPE Tone Map Function signature.

References sig, CIccIO::Write16(), CIccIO::Write32(), and CIccIO::WriteFloat32Float().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_nFunctionType

icUInt16Number CIccToneMapFunc::m_nFunctionType
protected

Definition at line 531 of file IccMpeBasic.h.

Referenced by operator=().

◆ m_nParameters

icUInt8Number CIccToneMapFunc::m_nParameters
protected

Definition at line 532 of file IccMpeBasic.h.

Referenced by operator=().

◆ m_nReserved

icUInt32Number CIccToneMapFunc::m_nReserved
protected

Definition at line 534 of file IccMpeBasic.h.

Referenced by operator=().

◆ m_nReserved2

icUInt16Number CIccToneMapFunc::m_nReserved2
protected

Definition at line 535 of file IccMpeBasic.h.

Referenced by operator=().

◆ m_params

icFloatNumber* CIccToneMapFunc::m_params
protected

Definition at line 533 of file IccMpeBasic.h.

Referenced by operator=().


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