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

Class: CIccSampledCurveSegment. More...

#include <IccMpeBasic.h>

+ Inheritance diagram for CIccSampledCurveSegment:
+ Collaboration diagram for CIccSampledCurveSegment:

Public Member Functions

virtual icFloatNumber Apply (icFloatNumber v) const
 Name: CIccSampledCurveSegment::Apply.
 
virtual bool Begin (CIccCurveSegment *pPrevSeg)
 Name: CIccSampledCurveSegment::Begin.
 
 CIccSampledCurveSegment (const CIccSampledCurveSegment &ITPC)
 Name: CIccSampledCurveSegment::CIccSampledCurveSegment.
 
 CIccSampledCurveSegment (icFloatNumber start, icFloatNumber end)
 Name: CIccSampledCurveSegment::CIccSampledCurveSegment.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccSampledCurveSegment::Describe.
 
virtual const icCharGetClassName () const
 
virtual icFloatNumberGetSamples ()
 
virtual icUInt32Number GetSize ()
 
virtual icCurveSegSignature GetType () const
 
virtual CIccCurveSegmentNewCopy () const
 
CIccSampledCurveSegmentoperator= (const CIccSampledCurveSegment &ParamCurveTag)
 Name: &CIccSampledCurveSegment::operator=.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccSampledCurveSegment::Read.
 
virtual bool SetSize (icUInt32Number nSize, bool bZeroAlloc=true)
 Name: CIccSampledCurveSegment::SetSize.
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccTagMultiProcessElement *pMPE=NULL, const CIccProfile *pProfile=NULL) const
 Name: CIccSampledCurveSegment::Validate.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccSampledCurveSegment::Write.
 
virtual ~CIccSampledCurveSegment ()
 Name: CIccSampledCurveSegment::~CIccSampledCurveSegment.
 
- Public Member Functions inherited from CIccCurveSegment
icFloatNumber EndPoint ()
 
icFloatNumber StartPoint ()
 
virtual ~CIccCurveSegment ()
 

Protected Attributes

icFloatNumber m_last
 
icUInt32Number m_nCount
 
icFloatNumberm_pSamples
 
icFloatNumber m_range
 
- Protected Attributes inherited from CIccCurveSegment
icFloatNumber m_endPoint
 
icUInt32Number m_nReserved
 
icFloatNumber m_startPoint
 

Additional Inherited Members

- Static Public Member Functions inherited from CIccCurveSegment
static CIccCurveSegmentCreate (icCurveSegSignature sig, icFloatNumber start, icFloatNumber end)
 Name: CIccCurveSegment::Create.
 

Detailed Description

Class: CIccSampledCurveSegment.

Purpose: The sampled curve segment

Definition at line 171 of file IccMpeBasic.h.

Constructor & Destructor Documentation

◆ CIccSampledCurveSegment() [1/2]

CIccSampledCurveSegment::CIccSampledCurveSegment ( icFloatNumber start,
icFloatNumber end )

Name: CIccSampledCurveSegment::CIccSampledCurveSegment.

Purpose:

Args:

Return:

Definition at line 858 of file IccMpeBasic.cpp.

859{
860 m_nReserved = 0;
861 m_startPoint = start;
862 m_endPoint = end;
863 m_range = end - start;
864 m_nCount = 0;
865 m_pSamples = 0;
866 m_last = 0;
867}
icFloatNumber m_startPoint
icFloatNumber m_endPoint
icUInt32Number m_nReserved
icFloatNumber * m_pSamples
icUInt32Number m_nCount

◆ CIccSampledCurveSegment() [2/2]

CIccSampledCurveSegment::CIccSampledCurveSegment ( const CIccSampledCurveSegment & curve)

Name: CIccSampledCurveSegment::CIccSampledCurveSegment.

Purpose:

Args:

Return:

Definition at line 879 of file IccMpeBasic.cpp.

880{
881 m_nReserved = curve.m_nReserved;
883 m_endPoint = curve.m_endPoint;
885 m_nCount = curve.m_nCount;
886 m_last = curve.m_last;
887
888 if (m_nCount) {
889 m_pSamples = (icFloatNumber*)malloc(m_nCount * sizeof(icFloatNumber));
890 if (m_pSamples)
891 memcpy(m_pSamples, curve.m_pSamples, m_nCount * sizeof(icFloatNumber));
892 else
893 m_nCount = 0;
894 }
895 else{
896 m_pSamples = NULL;
897 }
898}
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100

References CIccCurveSegment::m_endPoint, m_last, m_nCount, CIccCurveSegment::m_nReserved, m_pSamples, and CIccCurveSegment::m_startPoint.

◆ ~CIccSampledCurveSegment()

CIccSampledCurveSegment::~CIccSampledCurveSegment ( )
virtual

Name: CIccSampledCurveSegment::~CIccSampledCurveSegment.

Purpose:

Args:

Return:

Definition at line 943 of file IccMpeBasic.cpp.

944{
945 if (m_pSamples)
946 free(m_pSamples);
947}

Member Function Documentation

◆ Apply()

icFloatNumber CIccSampledCurveSegment::Apply ( icFloatNumber v) const
virtual

Name: CIccSampledCurveSegment::Apply.

Purpose:

Args:

Return:

Implements CIccCurveSegment.

Definition at line 1193 of file IccMpeBasic.cpp.

1194{
1195 if (v<m_startPoint)
1196 v=m_startPoint;
1197 else if (v>m_endPoint)
1198 v=m_endPoint;
1199
1201 icUInt32Number index = (icUInt32Number) pos;
1202 icFloatNumber remainder = pos - (icFloatNumber)index;
1203
1204 if (remainder==0.0)
1205 return m_pSamples[index];
1206
1207 return (icFloatNumber)((1.0-remainder)*m_pSamples[index] + remainder*m_pSamples[index+1]);
1208}
unsigned int icUInt32Number

◆ Begin()

bool CIccSampledCurveSegment::Begin ( CIccCurveSegment * pPrevSeg = NULL)
virtual

Name: CIccSampledCurveSegment::Begin.

Purpose:

Args:

Return:

Implements CIccCurveSegment.

Definition at line 1163 of file IccMpeBasic.cpp.

1164{
1165 if (m_nCount<2)
1166 return false;
1167
1169 m_last = (icFloatNumber)(m_nCount - 1);
1170
1171 if (m_endPoint-m_startPoint == 0.0)
1172 return false;
1173
1174 if (!pPrevSeg)
1175 return false;
1176
1177 //Set up interpolation from Application of last segment
1178 m_pSamples[0] = pPrevSeg->Apply(m_startPoint);
1179
1180 return true;
1181}
virtual icFloatNumber Apply(icFloatNumber v) const =0

◆ Describe()

void CIccSampledCurveSegment::Describe ( std::string & sDescription,
int nVerboseness )
virtual

Name: CIccSampledCurveSegment::Describe.

Purpose:

Args:

Return:

Implements CIccCurveSegment.

Definition at line 1004 of file IccMpeBasic.cpp.

1005{
1006 icChar buf[128];
1007
1008 if (m_nCount<2) {
1009 sDescription += "Empty Segment [";
1011 sDescription += "-Infinity, ";
1012 else {
1013 sprintf(buf, "%.8f, ", m_startPoint);
1014 sDescription += buf;
1015 }
1017 sDescription += "+Infinity";
1018 else {
1019 sprintf(buf, "%.8f", m_endPoint);
1020 sDescription += buf;
1021 }
1022
1023 sprintf(buf, "]\n");
1024 sDescription += buf;
1025 }
1026 else {
1027 sDescription += "Sampled Segment [";
1029 sDescription += "-Infinity, ";
1030 else {
1031 sprintf(buf, "%.8f, ", m_startPoint);
1032 sDescription += buf;
1033 }
1035 sDescription += "+Infinity";
1036 else {
1037 sprintf(buf, "%.8f", m_endPoint);
1038 sDescription += buf;
1039 }
1040 sprintf(buf, "]\n");
1041 sDescription += buf;
1042 sDescription += "IN OUT\n";
1043
1045
1048
1049 for (i=1; i<m_nCount; i++) {
1050 sprintf(buf, "%.8f %.8f\n", m_startPoint + (icFloatNumber)i*range/last, m_pSamples[i]);
1051 sDescription += buf;
1052 }
1053 }
1054 sDescription += "\n";
1055}
char icChar
Definition IccDefs.h:109
#define icMinFloat32Number
#define icMaxFloat32Number
Useful macros for defining Curve Segment breakpoints.

References icMaxFloat32Number, and icMinFloat32Number.

◆ GetClassName()

virtual const icChar * CIccSampledCurveSegment::GetClassName ( ) const
inlinevirtual

Implements CIccCurveSegment.

Definition at line 181 of file IccMpeBasic.h.

181{ return "CIccSampledCurveSegment"; }

◆ GetSamples()

virtual icFloatNumber * CIccSampledCurveSegment::GetSamples ( )
inlinevirtual

Definition at line 186 of file IccMpeBasic.h.

186{ return m_pSamples; }

◆ GetSize()

virtual icUInt32Number CIccSampledCurveSegment::GetSize ( )
inlinevirtual

Definition at line 184 of file IccMpeBasic.h.

184{ return m_nCount; }

◆ GetType()

virtual icCurveSegSignature CIccSampledCurveSegment::GetType ( ) const
inlinevirtual

Implements CIccCurveSegment.

Definition at line 180 of file IccMpeBasic.h.

180{ return icSigSampledCurveSeg; }
@ icSigSampledCurveSeg

References icSigSampledCurveSeg.

◆ NewCopy()

virtual CIccCurveSegment * CIccSampledCurveSegment::NewCopy ( ) const
inlinevirtual

Implements CIccCurveSegment.

Definition at line 177 of file IccMpeBasic.h.

177{ return new CIccSampledCurveSegment(*this);}
CIccSampledCurveSegment(icFloatNumber start, icFloatNumber end)
Name: CIccSampledCurveSegment::CIccSampledCurveSegment.

◆ operator=()

CIccSampledCurveSegment & CIccSampledCurveSegment::operator= ( const CIccSampledCurveSegment & curve)

Name: &CIccSampledCurveSegment::operator=.

Purpose:

Args:

Return:

Definition at line 910 of file IccMpeBasic.cpp.

911{
912 if (m_pSamples)
913 free(m_pSamples);
914
915 m_nReserved = curve.m_nReserved;
917 m_endPoint = curve.m_endPoint;
918 m_nCount = curve.m_nCount;
919
920 if (m_nCount) {
921 m_pSamples = (icFloatNumber*)malloc(m_nCount * sizeof(icFloatNumber));
922 if (m_pSamples)
923 memcpy(m_pSamples, curve.m_pSamples, m_nCount * sizeof(icFloatNumber));
924 else
925 m_nCount = 0;
926 }
927 else {
928 m_pSamples = NULL;
929 }
930 return (*this);
931}

References CIccCurveSegment::m_endPoint, m_nCount, CIccCurveSegment::m_nReserved, m_pSamples, and CIccCurveSegment::m_startPoint.

◆ Read()

bool CIccSampledCurveSegment::Read ( icUInt32Number size,
CIccIO * pIO )
virtual

Name: CIccSampledCurveSegment::Read.

Purpose:

Args:

Return:

Implements CIccCurveSegment.

Definition at line 1067 of file IccMpeBasic.cpp.

1068{
1070
1071 icUInt32Number headerSize = sizeof(icTagTypeSignature) +
1072 sizeof(icUInt32Number) +
1073 sizeof(icUInt32Number);
1074
1075 if (headerSize > size)
1076 return false;
1077
1078 if (!pIO) {
1079 return false;
1080 }
1081
1082 if (!pIO->Read32(&sig))
1083 return false;
1084
1085 if (!pIO->Read32(&m_nReserved))
1086 return false;
1087
1088 if (!pIO->Read32(&m_nCount))
1089 return false;
1090
1091 if (m_nCount > size - headerSize || m_nCount * sizeof(icFloat32Number) > size - headerSize)
1092 return false;
1093
1094 //Reserve room for first point who's value comes from previous segment
1095 m_nCount++;
1096
1097 if (!SetSize(m_nCount, false))
1098 return false;
1099
1100 if (m_nCount) {
1102 return false;
1103 }
1104
1105 //Initialize first point with zero. Properly initialized during Begin()
1106 m_pSamples[0] = 0;
1107
1108 return true;
1109}
icArraySignature sig
icTagTypeSignature
icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:302
icInt32Number Read32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:143
virtual bool SetSize(icUInt32Number nSize, bool bZeroAlloc=true)
Name: CIccSampledCurveSegment::SetSize.
float icFloat32Number
long icInt32Number
icCurveSegSignature
MPE Curve segment Signatures.

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

+ Here is the call graph for this function:

◆ SetSize()

bool CIccSampledCurveSegment::SetSize ( icUInt32Number nCount,
bool bZeroAlloc = true )
virtual

Name: CIccSampledCurveSegment::SetSize.

Purpose: Sets size of sampled lookup table. Previous data (if exists) is lost.

Args: nCount = number of elements in lut (must be >= 2). Note: the m_pSample[0] is initialized from the the previous segment. It is not saved as part of Write(), or loaded as part of Read(). It will be initialized during the call to Begin(), The actual count of elements written to the file will be nCount-1 bZeroAlloc = flag to decide if memory should be set to zero.

Return: true if allocation successful.

Definition at line 967 of file IccMpeBasic.cpp.

968{
969 if (!nCount) {
970 if (m_pSamples)
971 free(m_pSamples);
972 m_pSamples = NULL;
973 m_nCount = nCount;
974 return true;
975 }
976
977 if (m_pSamples) {
978 free(m_pSamples);
979 }
980
981 if (bZeroAlloc)
982 m_pSamples = (icFloatNumber*)calloc(nCount, sizeof(icFloatNumber));
983 else
984 m_pSamples = (icFloatNumber*)malloc(nCount * sizeof(icFloatNumber));
985
986 if (m_pSamples)
987 m_nCount = nCount;
988 else
989 m_nCount = 0;
990
991 return (m_pSamples != NULL);
992}

◆ Validate()

icValidateStatus CIccSampledCurveSegment::Validate ( std::string sigPath,
std::string & sReport,
const CIccTagMultiProcessElement * pMPE = NULL,
const CIccProfile * pProfile = NULL ) const
virtual

Name: CIccSampledCurveSegment::Validate.

Purpose:

Args:

Return:

Implements CIccCurveSegment.

Definition at line 1220 of file IccMpeBasic.cpp.

1221{
1222 CIccInfo Info;
1223 std::string sSigPathName = Info.GetSigPathName(sigPath);
1224
1226 if (m_nReserved) {
1227 sReport += icMsgValidateWarning;
1228 sReport += sSigPathName;
1229 sReport += " sampled curve has non zero reserved data.\n";
1230 rv = icValidateWarning;
1231 }
1232
1233 if (m_nCount<1) {
1234 sReport += icMsgValidateCriticalError;
1235 sReport += sSigPathName;
1236 sReport += " sampled curve has too few sample points.\n";
1238 }
1239 else if (m_endPoint-m_startPoint == 0.0) {
1240 sReport += icMsgValidateWarning;
1241 sReport += sSigPathName;
1242 sReport += " sampled curve has a range of zero.\n";
1244 }
1245
1246 return rv;
1247}
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
std::string GetSigPathName(std::string sigPath)
Definition IccUtil.cpp:1614

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

+ Here is the call graph for this function:

◆ Write()

bool CIccSampledCurveSegment::Write ( CIccIO * pIO)
virtual

Name: CIccSampledCurveSegment::Write.

Purpose:

Args:

Return:

Implements CIccCurveSegment.

Definition at line 1121 of file IccMpeBasic.cpp.

1122{
1124
1125 if (!pIO)
1126 return false;
1127
1128 if (!pIO->Write32(&sig))
1129 return false;
1130
1131 if (!pIO->Write32(&m_nReserved))
1132 return false;
1133
1134 icUInt32Number nCount;
1135
1136 if (m_nCount)
1137 nCount = m_nCount -1;
1138 else
1139 nCount = 0;
1140
1141 if (!pIO->Write32(&nCount))
1142 return false;
1143
1144 //First point in samples is ONLY for interpolation (not saved)
1145 if (nCount) {
1146 if (pIO->WriteFloat32Float(m_pSamples+1, nCount)!=(icInt32Number)nCount)
1147 return false;
1148 }
1149
1150 return true;
1151}
icInt32Number Write32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:152
icInt32Number WriteFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:321
virtual icCurveSegSignature GetType() const

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

+ Here is the call graph for this function:

Member Data Documentation

◆ m_last

icFloatNumber CIccSampledCurveSegment::m_last
protected

Definition at line 202 of file IccMpeBasic.h.

Referenced by CIccSampledCurveSegment().

◆ m_nCount

icUInt32Number CIccSampledCurveSegment::m_nCount
protected

Definition at line 198 of file IccMpeBasic.h.

Referenced by CIccSampledCurveSegment(), and operator=().

◆ m_pSamples

icFloatNumber* CIccSampledCurveSegment::m_pSamples
protected

Definition at line 199 of file IccMpeBasic.h.

Referenced by CIccSampledCurveSegment(), and operator=().

◆ m_range

icFloatNumber CIccSampledCurveSegment::m_range
protected

Definition at line 201 of file IccMpeBasic.h.


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