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

#include <IccMpeXml.h>

+ Inheritance diagram for CIccSegmentedCurveXml:
+ Collaboration diagram for CIccSegmentedCurveXml:

Public Member Functions

virtual icFloatNumber Apply (icFloatNumber v) const
 
virtual bool Begin (icElemInterp nInterp, CIccTagMultiProcessElement *pMPE)
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 
virtual const icCharGetClassName () const
 
virtual icCurveElemSignature GetType () const
 
bool Insert (CIccCurveSegment *pCurveSegment)
 
virtual CIccCurveSetCurveNewCopy () const
 
bool ParseXml (xmlNode *pNode, std::string &parseStr)
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 
void Reset ()
 
bool ToXml (std::string &xml, std::string blanks)
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccTagMultiProcessElement *pMPE=NULL, const CIccProfile *pProfile=NULL) const
 
virtual bool Write (CIccIO *pIO)
 

Static Public Member Functions

static CIccCurveSetCurveCreate (icCurveElemSignature sig)
 

Protected Attributes

CIccCurveSegmentListm_list
 
icUInt32Number m_nReserved1
 
icUInt32Number m_nReserved2
 

Detailed Description

Member Function Documentation

◆ Apply()

icFloatNumber CIccSegmentedCurve::Apply ( icFloatNumber  v) const
virtualinherited

Name: CIccSegmentedCurve::Apply

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

2900{
2901 CIccCurveSegmentList::iterator i;
2902
2903 for (i=m_list->begin(); i!=m_list->end(); i++) {
2904 if (v <= (*i)->EndPoint())
2905 return (*i)->Apply(v);
2906 }
2907 return v;
2908}
CIccCurveSegmentList * m_list
Definition IccMpeBasic.h:273

References CIccCurveSegment::Apply(), CIccCurveSegment::EndPoint(), and CIccSegmentedCurve::m_list.

Referenced by CIccTagSegmentedCurve::Apply().

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

◆ Begin()

bool CIccSegmentedCurve::Begin ( icElemInterp  nInterp,
CIccTagMultiProcessElement pMPE 
)
virtualinherited

Name: CIccSegmentedCurve::Begin

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

2872{
2873 if (m_list->size()==0)
2874 return false;
2875
2876 CIccCurveSegmentList::iterator i;
2877 CIccCurveSegment *pLast = NULL;
2878
2879 for (i=m_list->begin(); i!=m_list->end(); i++) {
2880 if (!(*i)->Begin(pLast))
2881 return false;
2882 pLast = *i;
2883 }
2884
2885 return true;
2886}
Definition IccMpeBasic.h:95

References CIccCurveSegment::Begin(), and CIccSegmentedCurve::m_list.

Referenced by CIccTagSegmentedCurve::Begin().

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

◆ Create()

CIccCurveSetCurve * CIccCurveSetCurve::Create ( icCurveElemSignature  sig)
staticinherited

Name: CIccCurveSetCurve::Create

Purpose:

Args:

Return:

2961{
2962 switch (sig) {
2964 return new CIccSegmentedCurve();
2966 return new CIccSingleSampledCurve();
2968 return new CIccSampledCalculatorCurve();
2969 default:
2970 return NULL;
2971 }
2972}
@ icSigSegmentedCurve
Definition icProfileHeader.h:1057
@ icSigSampledCalculatorCurve
Definition icProfileHeader.h:1059
@ icSigSingleSampledCurve
Definition icProfileHeader.h:1058
Definition IccMpeBasic.h:249
Definition IccMpeBasic.h:287
Definition IccMpeBasic.h:354

References CIccSampledCalculatorCurve::CIccSampledCalculatorCurve(), CIccSegmentedCurve::CIccSegmentedCurve(), CIccSingleSampledCurve::CIccSingleSampledCurve(), icSigSampledCalculatorCurve, icSigSegmentedCurve, and icSigSingleSampledCurve.

Referenced by CIccMpeCurveSet::Read(), and CIccMpeToneMap::Read().

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

◆ Describe()

void CIccSegmentedCurve::Describe ( std::string &  sDescription,
int  nVerboseness 
)
virtualinherited

Name: CIccSegmentedCurve::Describe

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

2627{
2628 CIccCurveSegmentList::iterator i;
2629
2630 sDescription += "BEGIN_CURVE\n";
2631 for (i=m_list->begin(); i!=m_list->end(); i++) {
2632 (*i)->Describe(sDescription, nVerboseness);
2633 }
2634}

References CIccCurveSegment::Describe(), and CIccSegmentedCurve::m_list.

Referenced by CIccTagSegmentedCurve::Describe().

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

◆ GetClassName()

virtual const icChar * CIccSegmentedCurve::GetClassName ( ) const
inlinevirtualinherited

Implements CIccCurveSetCurve.

258{ return "CIccSegmentedCurve"; }

◆ GetType()

virtual icCurveElemSignature CIccSegmentedCurve::GetType ( ) const
inlinevirtualinherited

Implements CIccCurveSetCurve.

257{ return icSigSegmentedCurve; }

References icSigSegmentedCurve.

Referenced by CIccSegmentedCurve::Read(), CIccSegmentedCurve::Validate(), and CIccSegmentedCurve::Write().

+ Here is the caller graph for this function:

◆ Insert()

bool CIccSegmentedCurve::Insert ( CIccCurveSegment pCurveSegment)
inherited

Name: CIccSegmentedCurve::Insert

Purpose:

Args:

Return:

2843{
2844 CIccCurveSegmentList::reverse_iterator last = m_list->rbegin();
2845
2846 if (last!=m_list->rend()) {
2847 if (pCurveSegment->StartPoint() == (*last)->EndPoint()) {
2848 m_list->push_back(pCurveSegment);
2849 return true;
2850 }
2851 }
2852 else {
2853 m_list->push_back(pCurveSegment);
2854 return true;
2855 }
2856
2857 return false;
2858}
icFloatNumber StartPoint()
Definition IccMpeBasic.h:115

References CIccCurveSegment::EndPoint(), CIccSegmentedCurve::m_list, and CIccCurveSegment::StartPoint().

+ Here is the call graph for this function:

◆ NewCopy()

virtual CIccCurveSetCurve * CIccSegmentedCurve::NewCopy ( ) const
inlinevirtualinherited

Implements CIccCurveSetCurve.

254{ return new CIccSegmentedCurve(*this);}
CIccSegmentedCurve()
Definition IccMpeBasic.cpp:2540

References CIccSegmentedCurve::CIccSegmentedCurve().

Referenced by CIccTagSegmentedCurve::CIccTagSegmentedCurve(), CIccDefaultEncProfileConverter::ConvertFromParams(), and CIccTagSegmentedCurve::operator=().

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

◆ ParseXml()

bool CIccSegmentedCurveXml::ParseXml ( xmlNode *  pNode,
std::string &  parseStr 
)
987{
988 m_list->clear();
989 for (pNode=pNode->children; pNode; pNode=pNode->next) {
990 if (pNode->type == XML_ELEMENT_NODE) {
991 icFloatNumber start = icGetSegPos(icXmlAttrValue(pNode, "Start"));
992 icFloatNumber end = icGetSegPos(icXmlAttrValue(pNode, "End"));
993
994 if (!icXmlStrCmp(pNode->name, "FormulaSegment")) {
996
997 if (!pSegXml->ParseXml(pNode, parseStr)) {
998 parseStr += "Unable to parse FormulaSegment\n";
999 delete pSegXml;
1000 return false;
1001 }
1002 m_list->push_back(pSegXml);
1003 }
1004 else if (!icXmlStrCmp(pNode->name, "SampledSegment")) {
1005 CIccSampledCurveSegmentXml *pSegXml = new CIccSampledCurveSegmentXml(start, end);
1006
1007 if (!pSegXml->ParseXml(pNode, parseStr)) {
1008 parseStr += "Unable to parse SampledSegment\n";
1009 delete pSegXml;
1010 return false;
1011 }
1012 m_list->push_back(pSegXml);
1013 }
1014 else {
1015 parseStr += "Bad Segment Type\n";
1016 return false;
1017 }
1018 }
1019 }
1020 return true;
1021}
float icFloatNumber
Definition IccDefs.h:101
#define icXmlStrCmp(x, y)
Definition IccUtilXml.h:134
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault="")
Definition IccUtilXml.cpp:572
icFloatNumber icGetSegPos(const char *str)
Definition IccMpeXml.cpp:148
Definition IccMpeXml.cpp:128
bool ParseXml(xmlNode *pNode, std::string &parseStr)
Definition IccMpeXml.cpp:193
Definition IccMpeXml.cpp:259
bool ParseXml(xmlNode *pNode, std::string &parseStr)
Definition IccMpeXml.cpp:286

References CIccFormulaCurveSegmentXml::CIccFormulaCurveSegmentXml(), CIccSampledCurveSegmentXml::CIccSampledCurveSegmentXml(), icGetSegPos(), icXmlAttrValue(), CIccSegmentedCurve::m_list, CIccFormulaCurveSegmentXml::ParseXml(), and CIccSampledCurveSegmentXml::ParseXml().

Referenced by CIccTagXmlSegmentedCurve::ParseXml(), and ParseXmlCurve().

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

◆ Read()

bool CIccSegmentedCurve::Read ( icUInt32Number  size,
CIccIO pIO 
)
virtualinherited

Name: CIccSegmentedCurve::Read

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

2649{
2651
2652 icUInt32Number startPos = pIO->Tell();
2653
2654 icUInt32Number headerSize = sizeof(icCurveElemSignature) +
2655 sizeof(icUInt32Number) +
2656 sizeof(icUInt16Number) +
2657 sizeof(icUInt16Number);
2658
2659 if (headerSize > size)
2660 return false;
2661
2662 if (!pIO) {
2663 return false;
2664 }
2665
2666 if (!pIO->Read32(&sig))
2667 return false;
2668
2669 if (sig!=GetType())
2670 return false;
2671
2672 if (!pIO->Read32(&m_nReserved1))
2673 return false;
2674
2675 icUInt16Number nSegments;
2676
2677 if (!pIO->Read16(&nSegments))
2678 return false;
2679
2680 if (!pIO->Read16(&m_nReserved2))
2681 return false;
2682
2683 Reset();
2684
2685 icUInt32Number pos = pIO->Tell();
2686 icCurveSegSignature segSig;
2687 CIccCurveSegment *pSeg;
2688
2689 if (nSegments==1) {
2690 if (sizeof(segSig) > size - headerSize)
2691 return false;
2692
2693 if (!pIO->Read32(&segSig))
2694 return false;
2696 if (!pSeg)
2697 return false;
2698
2699 pIO->Seek(pos, icSeekSet);
2700
2701 if (!pSeg->Read(size-(pos-startPos), pIO)) {
2702 delete pSeg;
2703 return false;
2704 }
2705
2706 m_list->push_back(pSeg);
2707 }
2708 else if (nSegments) {
2709 if (nSegments > size - headerSize)
2710 return false;
2711
2712 icFloatNumber *breakpoints=(icFloatNumber*)calloc(nSegments-1, sizeof(icFloatNumber));
2713
2714 if (!breakpoints)
2715 return false;
2716
2717 if (pIO->ReadFloat32Float(breakpoints, nSegments-1)!=nSegments-1) {
2718 free(breakpoints);
2719 return false;
2720 }
2721
2722 int i;
2723 for (i=0; i<nSegments; i++) {
2724 pos = pIO->Tell();
2725 if (!pIO->Read32(&segSig)) {
2726 free(breakpoints);
2727 return false;
2728 }
2729 if (pIO->Seek(pos, icSeekSet)!=(icInt32Number)pos)
2730 return false;;
2731
2732 if (!i)
2733 pSeg = CIccCurveSegment::Create(segSig, icMinFloat32Number, breakpoints[i]);
2734 else if (i==nSegments-1)
2735 pSeg = CIccCurveSegment::Create(segSig, breakpoints[i-1], icMaxFloat32Number);
2736 else
2737 pSeg = CIccCurveSegment::Create(segSig, breakpoints[i-1], breakpoints[i]);
2738
2739 if (!pSeg) {
2740 free(breakpoints);
2741 return false;
2742 }
2743
2744 if (!pSeg->Read(size-(pos-startPos), pIO)) {
2745 delete pSeg;
2746 free(breakpoints);
2747 return false;
2748 }
2749
2750 m_list->push_back(pSeg);
2751 }
2752
2753 free(breakpoints);
2754 }
2755
2756 return true;
2757}
icCurveElemSignature
Definition icProfileHeader.h:1056
unsigned short icUInt16Number
Definition icProfileHeader.h:256
long icInt32Number
Definition icProfileHeader.h:291
icCurveSegSignature
Definition icProfileHeader.h:1045
unsigned long icUInt32Number
Definition icProfileHeader.h:262
#define icMinFloat32Number
Definition icProfileHeader.h:318
#define icMaxFloat32Number
Definition icProfileHeader.h:317
@ icSeekSet
Definition IccIO.h:83
virtual bool Read(icUInt32Number size, CIccIO *pIO)=0
static CIccCurveSegment * Create(icCurveSegSignature sig, icFloatNumber start, icFloatNumber end)
Definition IccMpeBasic.cpp:2517
virtual icCurveElemSignature GetType() const
Definition IccMpeBasic.h:257
icUInt32Number m_nReserved2
Definition IccMpeBasic.h:275
void Reset()
Definition IccMpeBasic.cpp:2821
icUInt32Number m_nReserved1
Definition IccMpeBasic.h:274
icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:302
icInt32Number Read16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:114
virtual icInt32Number Tell()
Definition IccIO.h:133
virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos)
Definition IccIO.h:132
icInt32Number Read32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:143

References CIccCurveSegment::Create(), CIccSegmentedCurve::GetType(), icSeekSet, CIccSegmentedCurve::m_list, CIccSegmentedCurve::m_nReserved1, CIccSegmentedCurve::m_nReserved2, CIccCurveSegment::Read(), CIccIO::Read16(), CIccIO::Read32(), CIccIO::ReadFloat32Float(), CIccSegmentedCurve::Reset(), CIccIO::Seek(), and CIccIO::Tell().

Referenced by CIccTagSegmentedCurve::Read().

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

◆ Reset()

void CIccSegmentedCurve::Reset ( )
inherited

Name: CIccSegmentedCurve::Reset

Purpose:

Args:

Return:

2822{
2823 CIccCurveSegmentList::iterator i;
2824
2825 for (i=m_list->begin(); i!=m_list->end(); i++) {
2826 delete (*i);
2827 }
2828 m_list->clear();
2829}

References CIccSegmentedCurve::m_list.

Referenced by CIccSegmentedCurve::~CIccSegmentedCurve(), CIccSegmentedCurve::operator=(), and CIccSegmentedCurve::Read().

+ Here is the caller graph for this function:

◆ ToXml()

bool CIccSegmentedCurveXml::ToXml ( std::string &  xml,
std::string  blanks 
)
965{
966 CIccCurveSegmentList::iterator seg;
967 xml += blanks + "<SegmentedCurve>\n";
968 for (seg = m_list->begin(); seg!=m_list->end(); seg++) {
969 CIccCurveSegment* pSeg = *seg;
970 if (pSeg && pSeg->GetType() == icSigFormulaCurveSeg) {
971 if (!((CIccFormulaCurveSegmentXml*)pSeg)->ToXml(xml, blanks+" "))
972 return false;
973 }
974 else if (pSeg && pSeg->GetType() == icSigSampledCurveSeg) {
975 if (!((CIccSampledCurveSegmentXml*)pSeg)->ToXml(xml, blanks+" "))
976 return false;
977 }
978 else
979 return false;
980 }
981 xml += blanks + "</SegmentedCurve>\n";
982 return true;
983}
@ icSigSampledCurveSeg
Definition icProfileHeader.h:1047
@ icSigFormulaCurveSeg
Definition icProfileHeader.h:1046
virtual icCurveSegSignature GetType() const =0
virtual icCurveSegSignature GetType() const
Definition IccMpeBasic.h:141

References CIccCurveSegment::GetType(), icSigFormulaCurveSeg, icSigSampledCurveSeg, CIccSegmentedCurve::m_list, CIccFormulaCurveSegmentXml::ToXml(), and CIccSampledCurveSegmentXml::ToXml().

Referenced by CIccTagXmlSegmentedCurve::ToXml(), and ToXmlCurve().

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

◆ Validate()

icValidateStatus CIccSegmentedCurve::Validate ( std::string  sigPath,
std::string &  sReport,
const CIccTagMultiProcessElement pMPE = NULL,
const CIccProfile pProfile = NULL 
) const
virtualinherited

Name: CIccSegmentedCurve::Validate

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

2921{
2922 CIccInfo Info;
2923 std::string sSigPathName = Info.GetSigPathName(sigPath);
2924
2926 if (m_nReserved1 || m_nReserved2) {
2927 sReport += icMsgValidateWarning;
2928 sReport += sSigPathName;
2929 sReport += " Segmented curve has non zero reserved data.\n";
2930 rv = icValidateWarning;
2931 }
2932
2933 if (m_list->size()==0) {
2934 sReport += icMsgValidateCriticalError;
2935 sReport += sSigPathName;
2936 sReport += " Has Empty CurveSegment!\n";
2938 }
2939
2940 CIccCurveSegmentList::iterator i;
2941
2942 for (i=m_list->begin(); i!=m_list->end(); i++) {
2943 rv = icMaxStatus(rv, (*i)->Validate(sigPath+icGetSigPath(GetType()), sReport, pMPE, pProfile));
2944 }
2945
2946 return rv;
2947}
icValidateStatus
Definition IccDefs.h:119
@ icValidateOK
Definition IccDefs.h:120
@ icValidateWarning
Definition IccDefs.h:121
@ icValidateCriticalError
Definition IccDefs.h:123
ICCPROFLIB_API std::string icGetSigPath(icUInt32Number sig)
Definition IccUtil.cpp:1191
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
std::string GetSigPathName(std::string sigPath)
Definition IccUtil.cpp:1614

References CIccInfo::GetSigPathName(), CIccSegmentedCurve::GetType(), icGetSigPath(), icMaxStatus(), icMsgValidateCriticalError, icMsgValidateWarning, icValidateCriticalError, icValidateOK, icValidateWarning, CIccSegmentedCurve::m_list, CIccSegmentedCurve::m_nReserved1, CIccSegmentedCurve::m_nReserved2, and CIccCurveSegment::Validate().

Referenced by CIccTagSegmentedCurve::Validate().

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

◆ Write()

bool CIccSegmentedCurve::Write ( CIccIO pIO)
virtualinherited

Name: CIccSegmentedCurve::Write

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

2771{
2773
2774 if (!pIO)
2775 return false;
2776
2777 if (!pIO->Write32(&sig))
2778 return false;
2779
2780 if (!pIO->Write32(&m_nReserved1))
2781 return false;
2782
2783 icUInt16Number nSegments = (icUInt16Number)m_list->size();
2784
2785 if (!pIO->Write16(&nSegments))
2786 return false;
2787
2788 if (!pIO->Write16(&m_nReserved2))
2789 return false;
2790
2791 CIccCurveSegmentList::iterator i;
2792 if (nSegments>1) {
2793 icFloatNumber breakpoint;
2794
2795 i=m_list->begin();
2796 for (i++; i!=m_list->end(); i++) {
2797 breakpoint = (*i)->StartPoint();
2798 if (!pIO->WriteFloat32Float(&breakpoint))
2799 return false;
2800 }
2801 }
2802 for (i=m_list->begin(); i!=m_list->end(); i++) {
2803 if (!(*i)->Write(pIO))
2804 return false;
2805 }
2806
2807 return true;
2808}
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 CIccSegmentedCurve::GetType(), CIccSegmentedCurve::m_list, CIccSegmentedCurve::m_nReserved1, CIccSegmentedCurve::m_nReserved2, CIccCurveSegment::StartPoint(), CIccCurveSegment::Write(), CIccIO::Write16(), CIccIO::Write32(), and CIccIO::WriteFloat32Float().

Referenced by CIccTagSegmentedCurve::Write().

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

Field Documentation

◆ m_list

◆ m_nReserved1

◆ m_nReserved2


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