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

#include <IccMpeXml.h>

+ Inheritance diagram for CIccXmlToneMapFunc:
+ Collaboration diagram for CIccXmlToneMapFunc:

Public Member Functions

virtual ~CIccXmlToneMapFunc ()
 
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 ()
 
virtual CIccToneMapFuncNewCopy () const
 
virtual bool ParseXml (xmlNode *pNode, std::string &parseStr)
 
bool Read (icUInt32Number size, CIccIO *pIO)
 
bool SetFunction (icUInt16Number nFunc, icUInt8Number, icFloatNumber *pParams)
 
virtual bool ToXml (std::string &xml, std::string blanks="")
 
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

Constructor & Destructor Documentation

◆ ~CIccXmlToneMapFunc()

virtual CIccXmlToneMapFunc::~CIccXmlToneMapFunc ( )
inlinevirtual
141{}

Member Function Documentation

◆ Apply()

icFloatNumber CIccToneMapFunc::Apply ( icFloatNumber  lumValue,
icFloatNumber  pixelValue 
) const
inherited
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}
icUInt16Number m_nFunctionType
Definition IccMpeBasic.h:531
icFloatNumber * m_params
Definition IccMpeBasic.h:533

References CIccToneMapFunc::m_nFunctionType, and CIccToneMapFunc::m_params.

Referenced by CIccMpeToneMap::Apply().

+ Here is the caller graph for this function:

◆ Begin()

bool CIccToneMapFunc::Begin ( )
inherited
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
icUInt8Number m_nParameters
Definition IccMpeBasic.h:532

References CIccToneMapFunc::m_nFunctionType, CIccToneMapFunc::m_nParameters, CIccToneMapFunc::m_params, and CIccToneMapFunc::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 
)
inherited
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 CIccToneMapFunc::m_nFunctionType, CIccToneMapFunc::m_nParameters, and CIccToneMapFunc::m_params.

Referenced by CIccMpeToneMap::Describe().

+ Here is the caller graph for this function:

◆ GetClassName()

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

Reimplemented from CIccToneMapFunc.

145{ return "CIccXmlToneMapFunc"; }

◆ GetType()

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

References icSigToneMapFunction.

Referenced by CIccToneMapFunc::Write().

+ Here is the caller graph for this function:

◆ NewCopy() [1/2]

CIccToneMapFunc * CIccXmlToneMapFunc::NewCopy ( )
virtual
1647{
1649
1650 if (rv)
1651 *rv = *this;
1652
1653 return rv;
1654}
Definition IccMpeBasic.h:506
Definition IccMpeXml.h:139

References CIccToneMapFunc::operator=().

+ Here is the call graph for this function:

◆ NewCopy() [2/2]

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

References CIccToneMapFunc::CIccToneMapFunc(), and CIccToneMapFunc::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
protectedinherited
3948{
3949 if (m_nFunctionType == 0)
3950 return 3;
3951 return 0;
3952}

References CIccToneMapFunc::m_nFunctionType.

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

+ Here is the caller graph for this function:

◆ ParseXml()

bool CIccXmlToneMapFunc::ParseXml ( xmlNode *  pNode,
std::string &  parseStr 
)
virtual
1682{
1683 xmlAttr* funcType = icXmlFindAttr(pNode, "FunctionType");
1684
1685 if (!funcType) {
1686 parseStr += "Bad FunctionType in Tone Map Function\n";
1687 return false;
1688 }
1689
1690 m_nReserved2 = atoi(icXmlAttrValue(pNode, "Reserved2"));
1691 m_nFunctionType = atoi(icXmlAttrValue(funcType));
1692
1693 switch (m_nFunctionType) {
1694 case 0x0000:
1695 m_nParameters = 3;
1696 break;
1697
1698 default:
1699 parseStr += "Unsupported FunctionType value in Tone Map Function\n";
1700 return false;
1701 }
1702
1703 CIccFloatArray args;
1704
1705 if (!args.ParseArray(pNode->children))
1706 return false;
1707
1708 if (args.GetSize() < m_nParameters)
1709 return false;
1710
1711 if (m_params) {
1712 free(m_params);
1713 }
1714
1715 if (m_nParameters) {
1716 m_params = (icFloatNumber*)malloc(m_nParameters * sizeof(icFloatNumber));
1717 if (!m_params)
1718 return false;
1719
1720 memcpy(m_params, args.GetBuf(), m_nParameters * sizeof(icFloatNumber));
1721 }
1722 else
1723 m_params = NULL;
1724
1725 return true;
1726}
float icFloatNumber
Definition IccDefs.h:101
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
Definition IccUtilXml.cpp:669
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault="")
Definition IccUtilXml.cpp:572
icUInt16Number m_nReserved2
Definition IccMpeBasic.h:535
Definition IccUtilXml.h:145
static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode)
Definition IccUtilXml.cpp:1034
T * GetBuf()
Definition IccUtilXml.h:165
icUInt32Number GetSize()
Definition IccUtilXml.h:166

References CIccXmlArrayType< T, Tsig >::GetBuf(), CIccXmlArrayType< T, Tsig >::GetSize(), icXmlAttrValue(), icXmlAttrValue(), icXmlFindAttr(), CIccToneMapFunc::m_nFunctionType, CIccToneMapFunc::m_nParameters, CIccToneMapFunc::m_nReserved2, CIccToneMapFunc::m_params, and CIccXmlArrayType< T, Tsig >::ParseArray().

Referenced by CIccMpeXmlToneMap::ParseXml().

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

◆ Read()

bool CIccToneMapFunc::Read ( icUInt32Number  size,
CIccIO pIO 
)
inherited
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
icUInt32Number m_nReserved
Definition IccMpeBasic.h:534
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, CIccToneMapFunc::m_nFunctionType, CIccToneMapFunc::m_nParameters, CIccToneMapFunc::m_nReserved, CIccToneMapFunc::m_nReserved2, CIccToneMapFunc::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 
)
inherited
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(), CIccToneMapFunc::m_nFunctionType, CIccToneMapFunc::m_nParameters, CIccToneMapFunc::m_params, and CIccToneMapFunc::NumArgs().

+ Here is the call graph for this function:

◆ ToXml()

bool CIccXmlToneMapFunc::ToXml ( std::string &  xml,
std::string  blanks = "" 
)
virtual
1657{
1658 char line[256];
1659
1660 sprintf(line, "<ToneMapFunction FunctionType=\"%d\"", m_nFunctionType);
1661 xml += blanks + line;
1662
1663 if (m_nReserved) {
1664 sprintf(line, " Reserved=\"%d\"", m_nReserved);
1665 xml += line;
1666 }
1667 if (m_nReserved2) {
1668 sprintf(line, " Reserved2=\"%d\"", m_nReserved2);
1669 xml += line;
1670 }
1671 xml += ">\n";
1672
1674
1675 xml += blanks + "</ToneMapFunction>\n";
1676
1677 return true;
1678
1679}
@ icConvertFloat
Definition IccXmlConfig.h:70
static bool DumpArray(std::string &xml, std::string blanks, T *buf, icUInt32Number nBufSize, icConvertType nType, icUInt8Number nColumns)
Definition IccUtilXml.cpp:820

References CIccXmlArrayType< T, Tsig >::DumpArray(), icConvertFloat, CIccToneMapFunc::m_nFunctionType, CIccToneMapFunc::m_nParameters, CIccToneMapFunc::m_nReserved, CIccToneMapFunc::m_nReserved2, and CIccToneMapFunc::m_params.

Referenced by CIccMpeXmlToneMap::ToXml().

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

◆ Validate()

icValidateStatus CIccToneMapFunc::Validate ( std::string &  sFuncReport,
int  nVerboseness = 0 
) const
inherited
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, CIccToneMapFunc::m_nFunctionType, CIccToneMapFunc::m_nParameters, CIccToneMapFunc::m_nReserved, CIccToneMapFunc::m_nReserved2, and CIccToneMapFunc::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)
inherited
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 CIccToneMapFunc::GetType(), CIccToneMapFunc::m_nFunctionType, CIccToneMapFunc::m_nParameters, CIccToneMapFunc::m_nReserved, CIccToneMapFunc::m_nReserved2, CIccToneMapFunc::m_params, CIccToneMapFunc::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

◆ m_nReserved2

◆ m_params


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