IccMAX 2.1.27
Color Profile Tools
Loading...
Searching...
No Matches
CIccSinglSampledeCurveXml Class Reference
+ Inheritance diagram for CIccSinglSampledeCurveXml:
+ Collaboration diagram for CIccSinglSampledeCurveXml:

Public Member Functions

 CIccSinglSampledeCurveXml (icFloatNumber first=0, icFloatNumber last=0)
 
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
 
icUInt16Number GetExtensionType ()
 
virtual icFloatNumberGetSamples ()
 
virtual icUInt32Number GetSize ()
 
icUInt16Number GetStorageType ()
 
virtual icCurveElemSignature GetType () const
 
virtual CIccCurveSetCurveNewCopy () const
 
bool ParseXml (xmlNode *pNode, std::string &parseStr)
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 
bool SetExtensionType (icUInt16Number nExtensionType)
 
void SetRange (icFloatNumber first=0.0f, icFloatNumber last=1.0f)
 
virtual bool SetSize (icUInt32Number nSize, bool bZeroAlloc=true)
 
bool SetStorageType (icUInt16Number nStorateType)
 
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

icUInt16Number m_extensionType
 
icFloatNumber m_firstEntry
 
icFloatNumber m_hiIntercept
 
icFloatNumber m_hiSlope
 
icFloatNumber m_last
 
icFloatNumber m_lastEntry
 
icFloatNumber m_loIntercept
 
icFloatNumber m_loSlope
 
icUInt32Number m_nCount
 
icUInt32Number m_nReserved
 
icFloatNumberm_pSamples
 
icFloatNumber m_range
 
icUInt16Number m_storageType
 

Detailed Description

Constructor & Destructor Documentation

◆ CIccSinglSampledeCurveXml()

CIccSinglSampledeCurveXml::CIccSinglSampledeCurveXml ( icFloatNumber  first = 0,
icFloatNumber  last = 0 
)
inline
605: CIccSingleSampledCurve(first, last) {}
Definition IccMpeBasic.h:287

References CIccSingleSampledCurve::CIccSingleSampledCurve().

Referenced by ParseXmlCurve().

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

Member Function Documentation

◆ Apply()

icFloatNumber CIccSingleSampledCurve::Apply ( icFloatNumber  v) const
virtualinherited

Name: CIccSingleSampledCurve::Apply

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

1812{
1813 if (v<m_firstEntry) {
1814 return m_loSlope * v + m_loIntercept;;
1815 }
1816 else if (v>m_lastEntry) {
1817 return m_hiSlope * v + m_hiIntercept;
1818 }
1819
1821 icUInt32Number index = (icUInt32Number) pos;
1822 icFloatNumber remainder = pos - (icFloatNumber)index;
1823
1824 if (remainder==0.0)
1825 return m_pSamples[index];
1826
1827 return (icFloatNumber)((1.0-remainder)*m_pSamples[index] + remainder*m_pSamples[index+1]);
1828}
unsigned long icUInt32Number
Definition icProfileHeader.h:262
float icFloatNumber
Definition IccDefs.h:101
icFloatNumber m_hiSlope
Definition IccMpeBasic.h:337
icFloatNumber m_firstEntry
Definition IccMpeBasic.h:329
icFloatNumber m_lastEntry
Definition IccMpeBasic.h:330
icFloatNumber m_loIntercept
Definition IccMpeBasic.h:336
icFloatNumber m_last
Definition IccMpeBasic.h:333
icFloatNumber * m_pSamples
Definition IccMpeBasic.h:324
icFloatNumber m_range
Definition IccMpeBasic.h:332
icFloatNumber m_loSlope
Definition IccMpeBasic.h:335
icFloatNumber m_hiIntercept
Definition IccMpeBasic.h:338

References CIccSingleSampledCurve::m_firstEntry, CIccSingleSampledCurve::m_hiIntercept, CIccSingleSampledCurve::m_hiSlope, CIccSingleSampledCurve::m_last, CIccSingleSampledCurve::m_lastEntry, CIccSingleSampledCurve::m_loIntercept, CIccSingleSampledCurve::m_loSlope, CIccSingleSampledCurve::m_pSamples, and CIccSingleSampledCurve::m_range.

◆ Begin()

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

Name: CIccSingleSampledCurve::Begin

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

1766{
1767 if (m_nCount<2)
1768 return false;
1769
1771 m_last = (icFloatNumber)(m_nCount - 1);
1772 icFloatNumber stepSize = m_range / m_last;
1773
1774 if (m_range == 0.0)
1775 return false;
1776
1777 switch(m_extensionType) {
1779 m_loSlope=0.0;
1781
1782 m_hiSlope=0.0;
1784 break;
1785
1787 m_loSlope = (m_pSamples[1]-m_pSamples[0])/stepSize;
1789
1790 m_hiSlope = (m_pSamples[m_nCount-1] - m_pSamples[m_nCount-2])/stepSize;
1792 break;
1793
1794 default:
1795 return false;
1796 }
1797
1798 return true;
1799}
@ icExtendSingleSampledCurve
Definition icProfileHeader.h:1068
@ icClipSingleSampledCurve
Definition icProfileHeader.h:1067
icUInt16Number m_extensionType
Definition IccMpeBasic.h:327
icUInt32Number m_nCount
Definition IccMpeBasic.h:323

References icClipSingleSampledCurve, icExtendSingleSampledCurve, CIccSingleSampledCurve::m_extensionType, CIccSingleSampledCurve::m_firstEntry, CIccSingleSampledCurve::m_hiIntercept, CIccSingleSampledCurve::m_hiSlope, CIccSingleSampledCurve::m_last, CIccSingleSampledCurve::m_lastEntry, CIccSingleSampledCurve::m_loIntercept, CIccSingleSampledCurve::m_loSlope, CIccSingleSampledCurve::m_nCount, CIccSingleSampledCurve::m_pSamples, and CIccSingleSampledCurve::m_range.

◆ 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: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 CIccSingleSampledCurve::Describe ( std::string &  sDescription,
int  nVerboseness 
)
virtualinherited

Name: CIccSingleSampledCurve::Describe

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

1526{
1527 icChar buf[128];
1528
1529 if (m_nCount<2) {
1530 sDescription += "Empty Single Sampled Curve [";
1531 sprintf(buf, "%.8f, ", m_firstEntry);
1532 sDescription += buf;
1533
1534 sprintf(buf, "%.8f", m_lastEntry);
1535 sDescription += buf;
1536
1537 sprintf(buf, "]\n");
1538 sDescription += buf;
1539 }
1540 else {
1541 sDescription += "Single Sampled Curve [";
1542
1543 sprintf(buf, "%.8f, ", m_firstEntry);
1544 sDescription += buf;
1545
1546 sprintf(buf, "%.8f", m_lastEntry);
1547 sDescription += buf;
1548
1549 sprintf(buf, "]\n");
1550 sDescription += buf;
1551
1552 switch(m_storageType) {
1553 case icValueTypeUInt8:
1554 sDescription +="UInt8Number Array\n";
1555 break;
1556 case icValueTypeUInt16:
1557 sDescription +="UInt16Number Array\n";
1558 break;
1559 case icValueTypeFloat16:
1560 sDescription +="Float16Number Array\n";
1561 break;
1562 case icValueTypeFloat32:
1563 sDescription +="Float32Number Array\n";
1564 break;
1565 default:
1566 sDescription +="Unknown Data Type\n";
1567 break;
1568 }
1569
1570 switch(m_extensionType) {
1572 sDescription += "Clip End Points\n";
1573 break;
1575 sDescription += "Extend End Points\n";
1576 break;
1577 default:
1578 sDescription += "Unknown extension handling\n";
1579 break;
1580 }
1581 sDescription += "IN OUT\n";
1582
1584
1587
1588 for (i=0; i<m_nCount; i++) {
1589 sprintf(buf, "%.8f %.8f\n", m_firstEntry + (icFloatNumber)i*range/last, m_pSamples[i]);
1590 sDescription += buf;
1591 }
1592 }
1593 sDescription += "\n";
1594}
@ icValueTypeFloat16
Definition icProfileHeader.h:1087
@ icValueTypeUInt8
Definition icProfileHeader.h:1089
@ icValueTypeUInt16
Definition icProfileHeader.h:1088
@ icValueTypeFloat32
Definition icProfileHeader.h:1086
char icChar
Definition IccDefs.h:110
icUInt16Number m_storageType
Definition IccMpeBasic.h:326

References icClipSingleSampledCurve, icExtendSingleSampledCurve, icValueTypeFloat16, icValueTypeFloat32, icValueTypeUInt16, icValueTypeUInt8, CIccSingleSampledCurve::m_extensionType, CIccSingleSampledCurve::m_firstEntry, CIccSingleSampledCurve::m_lastEntry, CIccSingleSampledCurve::m_nCount, CIccSingleSampledCurve::m_pSamples, and CIccSingleSampledCurve::m_storageType.

◆ GetClassName()

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

Implements CIccCurveSetCurve.

296{ return "CIccSingleSampledCurve"; }

◆ GetExtensionType()

icUInt16Number CIccSingleSampledCurve::GetExtensionType ( )
inlineinherited

◆ GetSamples()

virtual icFloatNumber * CIccSingleSampledCurve::GetSamples ( )
inlinevirtualinherited
309{ return m_pSamples; }

References CIccSingleSampledCurve::m_pSamples.

Referenced by CDevLinkWriter::begin(), and main().

+ Here is the caller graph for this function:

◆ GetSize()

virtual icUInt32Number CIccSingleSampledCurve::GetSize ( )
inlinevirtualinherited
301{ return m_nCount; }

References CIccSingleSampledCurve::m_nCount.

◆ GetStorageType()

icUInt16Number CIccSingleSampledCurve::GetStorageType ( )
inlineinherited

◆ GetType()

virtual icCurveElemSignature CIccSingleSampledCurve::GetType ( ) const
inlinevirtualinherited

Implements CIccCurveSetCurve.

295{ return icSigSingleSampledCurve; }

References icSigSingleSampledCurve.

Referenced by CIccSingleSampledCurve::Read(), and CIccSingleSampledCurve::Write().

+ Here is the caller graph for this function:

◆ NewCopy()

virtual CIccCurveSetCurve * CIccSingleSampledCurve::NewCopy ( ) const
inlinevirtualinherited

Implements CIccCurveSetCurve.

292{ return new CIccSingleSampledCurve(*this); }

References CIccSingleSampledCurve::CIccSingleSampledCurve().

+ Here is the call graph for this function:

◆ ParseXml()

bool CIccSinglSampledeCurveXml::ParseXml ( xmlNode *  pNode,
std::string &  parseStr 
)
637{
638 xmlAttr *attr = icXmlFindAttr(pNode, "FirstEntry");
639
640 if (!attr) {
641 parseStr += "Bad FirstEntry in Simple Sampled Segment\n";
642 return false;
643 }
644
646
647 attr = icXmlFindAttr(pNode, "LastEntry");
648
649 if (!attr) {
650 parseStr += "Bad LastEntry in Simple Sampled Segment\n";
651 return false;
652 }
653
655
657 attr = icXmlFindAttr(pNode, "StorageType");
658 if (attr) {
660 }
661
663 attr = icXmlFindAttr(pNode, "ExtensionType");
664 if (attr) {
666 }
667
668 const char *filename = icXmlAttrValue(pNode, "Filename");
669
670 // file exists
671 if (filename[0]) {
672 CIccIO *file = IccOpenFileIO(filename, "rb");
673 if (!file) {
674 parseStr += "Error! - File '";
675 parseStr += filename;
676 parseStr += "' not found.\n";
677 delete file;
678 return false;
679 }
680
681 const char *format = icXmlAttrValue(pNode, "Format");
682
683 // format is text
684 if (!strcmp(format, "text")) {
685 icUInt32Number num = file->GetLength();
686 char *buf = new char[num];
687
688 if (!buf) {
689 perror("Memory Error");
690 parseStr += "'";
691 parseStr += filename;
692 parseStr += "' may not be a valid text file.\n";
693 delete file;
694 return false;
695 }
696
697 if (file->Read8(buf, num) != num) {
698 perror("Read-File Error");
699 parseStr += "'";
700 parseStr += filename;
701 parseStr += "' may not be a valid text file.\n";
702 delete [] buf;
703 delete file;
704 return false;
705 }
706
707 // lut8type
709 CIccUInt8Array data;
710
711 //if (!data.ParseTextArray(buf)) {
712 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
713 parseStr += "File '";
714 parseStr += filename;
715 parseStr += "' is not a valid text file.\n";
716 SetSize(0);
717 delete [] buf;
718 delete file;
719 return false;
720 }
721
722 else {
723 SetSize(data.GetSize());
724 icUInt8Number *src = data.GetBuf();
726
728 for (i = 0; i < data.GetSize(); i++) {
729 *dst = (icFloatNumber)(*src) / 255.0f;
730 dst++;
731 src++;
732 }
733
734 //if (i!=256) {
735 //printf("Error! - Input/Output table does not have 256 entries.\n");
736 //SetSize(0);
737 //return false;
738 //}
739 delete[] buf;
740 delete file;
741 return true;
742 }
743 }
744
745 //lut16type
746 else if (m_storageType == icValueTypeUInt16) {
747 CIccUInt16Array data;
748
749 //if (!data.ParseTextArray(buf)) {
750 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
751 parseStr += "File '";
752 parseStr += filename;
753 parseStr += "' is not a valid text file.\n";
754 SetSize(0);
755 delete[] buf;
756 delete file;
757 return false;
758 }
759
760 else {
761 SetSize(data.GetSize());
762
763 icUInt16Number *src = data.GetBuf();
765
767 for (i = 0; i < data.GetSize(); i++) {
768 *dst = (icFloatNumber)(*src) / 65535.0f;
769 dst++;
770 src++;
771 }
772 }
773 delete[] buf;
774 delete file;
775 return true;
776 }
777
778 //float type
779 else if (m_storageType == icValueTypeFloat32) {
780 CIccFloatArray data;
781
782 //if (!data.ParseTextArray(buf)) {
783 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
784 parseStr += "File '";
785 parseStr += filename;
786 parseStr += "' is not a valid text file.\n";
787 SetSize(0);
788 delete[] buf;
789 delete file;
790 return false;
791 }
792
793 else {
794 SetSize(data.GetSize());
795 icFloatNumber *src = data.GetBuf();
797
799 for (i = 0; i < data.GetSize(); i++) {
800 *dst = *src;
801 dst++;
802 src++;
803 }
804 }
805 delete[] buf;
806 delete file;
807 return true;
808 }
809 else {
810 delete[]buf;
811 delete file;
812 return false;
813 }
814 }
815 // format is binary
816 else if (!strcmp(format, "binary")) {
817 const char *order = icXmlAttrValue(pNode, "Endian");
818 bool little_endian = !strcmp(order, "little");
819
821 icUInt32Number num = file->GetLength();
822 icUInt8Number value;
823
824 SetSize(num);
827 for (i = 0; i < num; i++) {
828 if (!file->Read8(&value)) {
829 perror("Read-File Error");
830 parseStr += "'";
831 parseStr += filename;
832 parseStr += "' may not be a valid binary file.\n";
833 delete file;
834 return false;
835 }
836 *dst++ = (icFloatNumber)value / 255.0f;
837 }
838 delete file;
839 return true;
840 }
841 else if (m_storageType == icValueTypeUInt16) {
842 icUInt32Number num = file->GetLength() / sizeof(icUInt16Number);
843 icUInt16Number value;
844 icUInt8Number *m_ptr = (icUInt8Number*)&value;
845
846 SetSize(num);
849 for (i = 0; i < num; i++) {
850 if (!file->Read16(&value)) { //assumes data is big endian
851 perror("Read-File Error");
852 parseStr += "'";
853 parseStr += filename;
854 parseStr += "' may not be a valid binary file.\n";
855 delete file;
856 return false;
857 }
858#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
859 if (little_endian) {
860#else
861 if (!little_endian) {
862#endif
863 icUInt8Number t = m_ptr[0];
864 m_ptr[0] = m_ptr[1];
865 m_ptr[1] = t;
866 }
867 *dst++ = (icFloatNumber)value / 65535.0f;
868 }
869 delete file;
870 return true;
871 }
872 else if (m_storageType == icValueTypeFloat16) {
873 icUInt32Number num = file->GetLength() / sizeof(icFloat16Number);
874 icFloat16Number value;
875 icUInt8Number *m_ptr = (icUInt8Number*)&value;
876
877 SetSize(num);
880 for (i = 0; i < num; i++) {
881 if (!file->Read16(&value)) { //assumes data is big endian
882 perror("Read-File Error");
883 parseStr += "'";
884 parseStr += filename;
885 parseStr += "' may not be a valid binary file.\n";
886 delete file;
887 return false;
888 }
889#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
890 if (little_endian) {
891#else
892 if (!little_endian) {
893#endif
894 icUInt8Number t = m_ptr[0];
895 m_ptr[0] = m_ptr[1];
896 m_ptr[1] = t;
897 }
898 *dst++ = icF16toF(value);
899 }
900 delete file;
901 return true;
902 }
903 else if (m_storageType == icValueTypeFloat32) {
904 icUInt32Number num = file->GetLength() / sizeof(icFloat32Number);
905 icFloat32Number value;
906 icUInt8Number *m_ptr = (icUInt8Number*)&value;
907
908 SetSize(num);
910
912 for (i = 0; i < num; i++) {
913 if (!file->ReadFloat32Float(&value)) {
914 perror("Read-File Error");
915 parseStr += "'";
916 parseStr += filename;
917 parseStr += "' may not be a valid binary file.\n";
918 delete file;
919 return false;
920 }
921#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
922 if (little_endian) {
923#else
924 if (!little_endian) {
925#endif
926 icUInt8Number tmp;
927 tmp = m_ptr[0]; m_ptr[0] = m_ptr[3]; m_ptr[3] = tmp;
928 tmp = m_ptr[1]; m_ptr[1] = m_ptr[2]; m_ptr[2] = tmp;
929 }
930 *dst++ = value;
931 }
932 delete file;
933 return true;
934 }
935 else { //not 8bit/16bit/float
936 delete file;
937 return false;
938 }
939 }
940 else {//not text/binary
941 delete file;
942 return false;
943 }
944 }
945 // no file
946 else {
947 CIccFloatArray samples;
948
949 if (!samples.ParseArray(pNode->children)) {
950 return false;
951 }
952
953 if (!SetSize(samples.GetSize())) {
954 return false;
955 }
956
957 memcpy(m_pSamples, samples.GetBuf(), samples.GetSize() * sizeof(icFloatNumber));
958 }
959
960 return true;
961 }
unsigned char icUInt8Number
Definition icProfileHeader.h:250
float icFloat32Number
Definition icProfileHeader.h:313
unsigned short icUInt16Number
Definition icProfileHeader.h:256
icUInt16Number icFloat16Number
Definition icProfileHeader.h:310
ICCPROFLIB_API icFloat32Number icF16toF(icFloat16Number num)
Definition IccUtil.cpp:629
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
Definition IccUtilXml.cpp:669
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault="")
Definition IccUtilXml.cpp:572
CIccIO * IccOpenFileIO(const icChar *szFilename, const char *szAttr)
Definition IccIoXml.cpp:100
virtual bool SetSize(icUInt32Number nSize, bool bZeroAlloc=true)
Definition IccMpeBasic.cpp:1488
Definition IccIO.h:97
icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:302
virtual icInt32Number GetLength()
Definition IccIO.h:130
virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:104
icInt32Number Read16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:114
Definition IccUtilXml.h:145
static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode)
Definition IccUtilXml.cpp:1034
bool ParseTextArrayNum(const char *szText, icUInt32Number num, std::string &parseStr)
Definition IccUtilXml.cpp:807
T * GetBuf()
Definition IccUtilXml.h:165
icUInt32Number GetSize()
Definition IccUtilXml.h:166

References CIccXmlArrayType< T, Tsig >::GetBuf(), CIccIO::GetLength(), CIccXmlArrayType< T, Tsig >::GetSize(), icClipSingleSampledCurve, IccOpenFileIO(), icF16toF(), icValueTypeFloat16, icValueTypeFloat32, icValueTypeUInt16, icValueTypeUInt8, icXmlAttrValue(), icXmlAttrValue(), icXmlFindAttr(), CIccSingleSampledCurve::m_extensionType, CIccSingleSampledCurve::m_firstEntry, CIccSingleSampledCurve::m_lastEntry, CIccSingleSampledCurve::m_pSamples, CIccSingleSampledCurve::m_storageType, CIccXmlArrayType< T, Tsig >::ParseArray(), CIccXmlArrayType< T, Tsig >::ParseTextArrayNum(), CIccIO::Read16(), CIccIO::Read8(), CIccIO::ReadFloat32Float(), and CIccSingleSampledCurve::SetSize().

Referenced by ParseXmlCurve().

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

◆ Read()

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

Name: CIccSingleSampledCurve::Read

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

1607{
1609
1610 icUInt32Number headerSize = sizeof(icTagTypeSignature) +
1611 sizeof(icUInt32Number) +
1612 sizeof(icUInt32Number) +
1613 sizeof(icFloat32Number) +
1614 sizeof(icFloat32Number) +
1615 sizeof(icUInt16Number) +
1616 sizeof(icUInt16Number);
1617
1618 if (headerSize > size)
1619 return false;
1620
1621 if (!pIO) {
1622 return false;
1623 }
1624
1625 if (!pIO->Read32(&sig) || sig!=GetType())
1626 return false;
1627
1628 if (!pIO->Read32(&m_nReserved))
1629 return false;
1630
1631 if (!pIO->Read32(&m_nCount))
1632 return false;
1633
1634 if (!pIO->ReadFloat32Float(&m_firstEntry))
1635 return false;
1636
1637 if (!pIO->ReadFloat32Float(&m_lastEntry))
1638 return false;
1639
1640 if (!pIO->Read16(&m_extensionType))
1641 return false;
1642
1643 if (!pIO->Read16(&m_storageType))
1644 return false;
1645
1646 if (!SetSize(m_nCount, false))
1647 return false;
1648
1649 if (m_nCount > size - headerSize)
1650 return false;
1651
1652 if (m_nCount) {
1653 switch(m_storageType) {
1654 case icValueTypeUInt8:
1655 if (m_nCount * sizeof(icUInt8Number) > size - headerSize)
1656 return false;
1657
1659 return false;
1660 break;
1661 case icValueTypeUInt16:
1662 if (m_nCount * 2 > size - headerSize)
1663 return false;
1664
1666 return false;
1667 break;
1668 case icValueTypeFloat16:
1669 if (m_nCount * 2 > size - headerSize)
1670 return false;
1671
1673 return false;
1674 break;
1675 case icValueTypeFloat32:
1676 if (m_nCount * sizeof(icFloat32Number) > size - headerSize)
1677 return false;
1678
1680 return false;
1681 break;
1682 default:
1683 return false;
1684 }
1685 }
1686
1687 return true;
1688}
long icInt32Number
Definition icProfileHeader.h:291
icCurveSegSignature
Definition icProfileHeader.h:1045
icTagTypeSignature
Definition icProfileHeader.h:526
icUInt32Number m_nReserved
Definition IccMpeBasic.h:321
virtual icCurveElemSignature GetType() const
Definition IccMpeBasic.h:295
icInt32Number ReadFloat16Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:269
icInt32Number ReadUInt8Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:203
icInt32Number ReadUInt16Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:236
icInt32Number Read32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:143

References CIccSingleSampledCurve::GetType(), icValueTypeFloat16, icValueTypeFloat32, icValueTypeUInt16, icValueTypeUInt8, CIccSingleSampledCurve::m_extensionType, CIccSingleSampledCurve::m_firstEntry, CIccSingleSampledCurve::m_lastEntry, CIccSingleSampledCurve::m_nCount, CIccSingleSampledCurve::m_nReserved, CIccSingleSampledCurve::m_pSamples, CIccSingleSampledCurve::m_storageType, CIccIO::Read16(), CIccIO::Read32(), CIccIO::ReadFloat16Float(), CIccIO::ReadFloat32Float(), CIccIO::ReadUInt16Float(), CIccIO::ReadUInt8Float(), and CIccSingleSampledCurve::SetSize().

+ Here is the call graph for this function:

◆ SetExtensionType()

bool CIccSingleSampledCurve::SetExtensionType ( icUInt16Number  nExtensionType)
inherited

Name: CIccSingleSampledCurve::SetExtensionType

Purpose: Sets extension type of the single sampled curve

Args: nExtensionType is type of extension to use

Return: true if valid extension type, false otherwise

1435{
1436 m_extensionType = nExtensionType;
1437
1438 switch (nExtensionType) {
1441 return true;
1442 }
1443 return false;
1444}

References icClipSingleSampledCurve, icExtendSingleSampledCurve, and CIccSingleSampledCurve::m_extensionType.

◆ SetRange()

void CIccSingleSampledCurve::SetRange ( icFloatNumber  first = 0.0f,
icFloatNumber  last = 1.0f 
)
inherited

Name: CIccSingleSampledCurve::SetRange

Purpose: Sets range of sampled lookup table.

Args: first = first entry input position last = last entry input position

1409{
1410 if (first < last) {
1411 m_firstEntry = first;
1412 m_lastEntry = last;
1413 }
1414 else {
1415 m_firstEntry = last;
1416 m_lastEntry = first;
1417 }
1418}

References CIccSingleSampledCurve::m_firstEntry, and CIccSingleSampledCurve::m_lastEntry.

◆ SetSize()

bool CIccSingleSampledCurve::SetSize ( icUInt32Number  nCount,
bool  bZeroAlloc = true 
)
virtualinherited

Name: CIccSingleSampledCurve::SetSize

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

Args: nCount = number of elements in lut (must be >= 2).
bZeroAlloc = flag to decide if memory should be set to zero.

Return: true if allocation successful.

1489{
1490 if (!nCount) {
1491 if (m_pSamples)
1492 free(m_pSamples);
1493 m_pSamples = NULL;
1494 m_nCount = nCount;
1495 return true;
1496 }
1497
1498 if (m_pSamples) {
1499 free(m_pSamples);
1500 }
1501
1502 if (bZeroAlloc)
1503 m_pSamples = (icFloatNumber*)calloc(nCount, sizeof(icFloatNumber));
1504 else
1505 m_pSamples = (icFloatNumber*)malloc(nCount * sizeof(icFloatNumber));
1506
1507 if (m_pSamples)
1508 m_nCount = nCount;
1509 else
1510 m_nCount = 0;
1511
1512 return (m_pSamples != NULL);
1513}

References CIccSingleSampledCurve::m_nCount, and CIccSingleSampledCurve::m_pSamples.

Referenced by CDevLinkWriter::begin(), main(), ParseXml(), and CIccSingleSampledCurve::Read().

+ Here is the caller graph for this function:

◆ SetStorageType()

bool CIccSingleSampledCurve::SetStorageType ( icUInt16Number  nStorateType)
inherited

Name: CIccSingleSampledCurve::SetStorageType

Purpose: Sets storate type of the data stored in the single sampled curve

Args: nStorageType is type of data to use

Return: true if valid storage type, false otherwise

1460{
1461 m_storageType = nStorateType;
1462
1463 switch (nStorateType) {
1464 case icValueTypeUInt8:
1465 case icValueTypeUInt16:
1466 case icValueTypeFloat16:
1467 case icValueTypeFloat32:
1468 return true;
1469 }
1470 return false;
1471}

References icValueTypeFloat16, icValueTypeFloat32, icValueTypeUInt16, icValueTypeUInt8, and CIccSingleSampledCurve::m_storageType.

◆ ToXml()

bool CIccSinglSampledeCurveXml::ToXml ( std::string &  xml,
std::string  blanks 
)
612{
613 char line[256];
614
615 xml += blanks;
616 sprintf(line, "<SingleSampledCurve FirstEntry=\"" icXmlFloatFmt "\"", m_firstEntry);
617 xml += line;
618
619 sprintf(line, " LastEntry=\"" icXmlFloatFmt "\"", m_lastEntry);
620 xml += line;
621
622 sprintf(line, " StorageType=\"%u\"", m_storageType);
623 xml += line;
624
625 sprintf(line, " ExtensionType=\"%u\">\n", m_extensionType);
626 xml += line;
627
629
630 xml += blanks + "</SingleSampledCurve>\n";
631
632 return true;
633}
@ icConvertFloat
Definition IccXmlConfig.h:70
#define icXmlFloatFmt
Definition IccXmlConfig.h:75
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, CIccSingleSampledCurve::m_extensionType, CIccSingleSampledCurve::m_firstEntry, CIccSingleSampledCurve::m_lastEntry, CIccSingleSampledCurve::m_nCount, CIccSingleSampledCurve::m_pSamples, and CIccSingleSampledCurve::m_storageType.

Referenced by ToXmlCurve().

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

◆ Validate()

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

Name: CIccSingleSampledCurve::Validate

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

1841{
1842 CIccInfo Info;
1843 std::string sSigPathName = Info.GetSigPathName(sigPath);
1844
1846 if (m_nReserved) {
1847 sReport += icMsgValidateWarning;
1848 sReport += sSigPathName;
1849 sReport += " single sampled curve has non zero reserved data.\n";
1850 rv = icValidateWarning;
1851 }
1852
1854 sReport += icMsgValidateCriticalError;
1855 sReport += sSigPathName;
1856 sReport += " single sampled curve has unknown extension type\n";
1858 }
1859
1861 sReport += icMsgValidateCriticalError;
1862 sReport += sSigPathName;
1863 sReport += " single sampled curve uses unknown value type\n";
1865 }
1866
1867 if (m_nCount<2) {
1868 sReport += icMsgValidateCriticalError;
1869 sReport += sSigPathName;
1870 sReport += " single sampled curve has too few sample points.\n";
1872 }
1873
1874 if (m_lastEntry-m_firstEntry <= 0.0) {
1875 sReport += icMsgValidateWarning;
1876 sReport += sSigPathName;
1877 sReport += " single sampled curve has an invalid sample range.\r\n";
1879 }
1880
1881 return rv;
1882}
#define icMaxSingleSampledCurveType
Definition icProfileHeader.h:1071
#define icMaxValueType
Definition icProfileHeader.h:1092
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
std::string GetSigPathName(std::string sigPath)
Definition IccUtil.cpp:1614

References CIccInfo::GetSigPathName(), icMaxStatus(), icMsgValidateCriticalError, icMsgValidateWarning, icValidateCriticalError, icValidateOK, icValidateWarning, CIccSingleSampledCurve::m_extensionType, CIccSingleSampledCurve::m_firstEntry, CIccSingleSampledCurve::m_lastEntry, CIccSingleSampledCurve::m_nCount, CIccSingleSampledCurve::m_nReserved, and CIccSingleSampledCurve::m_storageType.

+ Here is the call graph for this function:

◆ Write()

bool CIccSingleSampledCurve::Write ( CIccIO pIO)
virtualinherited

Name: CIccSingleSampledCurve::Write

Purpose:

Args:

Return:

Implements CIccCurveSetCurve.

1701{
1703
1704 if (!pIO)
1705 return false;
1706
1707 if (!pIO->Write32(&sig))
1708 return false;
1709
1710 if (!pIO->Write32(&m_nReserved))
1711 return false;
1712
1713 if (!pIO->Write32(&m_nCount))
1714 return false;
1715
1716 if (!pIO->WriteFloat32Float(&m_firstEntry))
1717 return false;
1718
1719 if (!pIO->WriteFloat32Float(&m_lastEntry))
1720 return false;
1721
1722 if (!pIO->Write16(&m_extensionType))
1723 return false;
1724
1725 if (!pIO->Write16(&m_storageType))
1726 return false;
1727
1728 if (m_nCount) {
1729
1730 switch(m_storageType) {
1731 case icValueTypeUInt8:
1733 return false;
1734 break;
1735 case icValueTypeUInt16:
1737 return false;
1738 break;
1739 case icValueTypeFloat16:
1741 return false;
1742 break;
1743 case icValueTypeFloat32:
1745 return false;
1746 break;
1747 default:
1748 return false;
1749 }
1750 }
1751
1752 return true;
1753}
icCurveElemSignature
Definition icProfileHeader.h:1056
icInt32Number Write16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:122
icInt32Number WriteFloat16Float(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:285
icInt32Number Write32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:152
icInt32Number WriteFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:321
icInt32Number WriteUInt8Float(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:219
icInt32Number WriteUInt16Float(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:252

References CIccSingleSampledCurve::GetType(), icValueTypeFloat16, icValueTypeFloat32, icValueTypeUInt16, icValueTypeUInt8, CIccSingleSampledCurve::m_extensionType, CIccSingleSampledCurve::m_firstEntry, CIccSingleSampledCurve::m_lastEntry, CIccSingleSampledCurve::m_nCount, CIccSingleSampledCurve::m_nReserved, CIccSingleSampledCurve::m_pSamples, CIccSingleSampledCurve::m_storageType, CIccIO::Write16(), CIccIO::Write32(), CIccIO::WriteFloat16Float(), CIccIO::WriteFloat32Float(), CIccIO::WriteUInt16Float(), and CIccIO::WriteUInt8Float().

+ Here is the call graph for this function:

Field Documentation

◆ m_extensionType

◆ m_firstEntry

◆ m_hiIntercept

◆ m_hiSlope

◆ m_last

◆ m_lastEntry

◆ m_loIntercept

◆ m_loSlope

◆ m_nCount

◆ m_nReserved

◆ m_pSamples

◆ m_range

◆ m_storageType


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