Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
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)
 
bool ParseXml (xmlNode *pNode, std::string &parseStr)
 
bool ToXml (std::string &xml, std::string blanks)
 
- Public Member Functions inherited from CIccSingleSampledCurve
virtual icFloatNumber Apply (icFloatNumber v) const
 Name: CIccSingleSampledCurve::Apply.
 
virtual bool Begin (icElemInterp nInterp, CIccTagMultiProcessElement *pMPE)
 Name: CIccSingleSampledCurve::Begin.
 
 CIccSingleSampledCurve (const CIccSingleSampledCurve &ITPC)
 Name: CIccSingleSampledCurve::CIccSingleSampledCurve.
 
 CIccSingleSampledCurve (icFloatNumber first=0.0, icFloatNumber last=1.0)
 Name: CIccSingleSampledCurve::CIccSingleSampledCurve.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccSingleSampledCurve::Describe.
 
virtual const icCharGetClassName () const
 
icUInt16Number GetExtensionType ()
 
virtual icFloatNumberGetSamples ()
 
virtual icUInt32Number GetSize ()
 
icUInt16Number GetStorageType ()
 
virtual icCurveElemSignature GetType () const
 
virtual CIccCurveSetCurveNewCopy () const
 
CIccSingleSampledCurveoperator= (const CIccSingleSampledCurve &SampledCurve)
 Name: &CIccSingleSampledCurve::operator=.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccSingleSampledCurve::Read.
 
bool SetExtensionType (icUInt16Number nExtensionType)
 Name: CIccSingleSampledCurve::SetExtensionType.
 
void SetRange (icFloatNumber first=0.0f, icFloatNumber last=1.0f)
 Name: CIccSingleSampledCurve::SetRange.
 
virtual bool SetSize (icUInt32Number nSize, bool bZeroAlloc=true)
 Name: CIccSingleSampledCurve::SetSize.
 
bool SetStorageType (icUInt16Number nStorateType)
 Name: CIccSingleSampledCurve::SetStorageType.
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccTagMultiProcessElement *pMPE=NULL, const CIccProfile *pProfile=NULL) const
 Name: CIccSingleSampledCurve::Validate.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccSingleSampledCurve::Write.
 
virtual ~CIccSingleSampledCurve ()
 Name: CIccSingleSampledCurve::~CIccSingleSampledCurve.
 
- Public Member Functions inherited from CIccCurveSetCurve
virtual ~CIccCurveSetCurve ()
 

Additional Inherited Members

- Static Public Member Functions inherited from CIccCurveSetCurve
static CIccCurveSetCurveCreate (icCurveElemSignature sig)
 Name: CIccCurveSetCurve::Create.
 
- Protected Attributes inherited from CIccSingleSampledCurve
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

Definition at line 603 of file IccMpeXml.cpp.

Constructor & Destructor Documentation

◆ CIccSinglSampledeCurveXml()

CIccSinglSampledeCurveXml::CIccSinglSampledeCurveXml ( icFloatNumber first = 0,
icFloatNumber last = 0 )
inline

Definition at line 606 of file IccMpeXml.cpp.

606: CIccSingleSampledCurve(first, last) {}
CIccSingleSampledCurve(icFloatNumber first=0.0, icFloatNumber last=1.0)
Name: CIccSingleSampledCurve::CIccSingleSampledCurve.

Member Function Documentation

◆ ParseXml()

bool CIccSinglSampledeCurveXml::ParseXml ( xmlNode * pNode,
std::string & parseStr )

Definition at line 637 of file IccMpeXml.cpp.

638{
639 xmlAttr *attr = icXmlFindAttr(pNode, "FirstEntry");
640
641 if (!attr) {
642 parseStr += "Bad FirstEntry in Simple Sampled Segment\n";
643 return false;
644 }
645
647
648 attr = icXmlFindAttr(pNode, "LastEntry");
649
650 if (!attr) {
651 parseStr += "Bad LastEntry in Simple Sampled Segment\n";
652 return false;
653 }
654
656
658 attr = icXmlFindAttr(pNode, "StorageType");
659 if (attr) {
661 }
662
664 attr = icXmlFindAttr(pNode, "ExtensionType");
665 if (attr) {
667 }
668
669 const char *filename = icXmlAttrValue(pNode, "Filename");
670
671 // file exists
672 if (filename[0]) {
673 CIccIO *file = IccOpenFileIO(filename, "rb");
674 if (!file) {
675 parseStr += "Error! - File '";
676 parseStr += filename;
677 parseStr += "' not found.\n";
678 delete file;
679 return false;
680 }
681
682 const char *format = icXmlAttrValue(pNode, "Format");
683
684 // format is text
685 if (!strcmp(format, "text")) {
686 icUInt32Number num = file->GetLength();
687 char *buf = (char *) new char[num];
688
689 if (!buf) {
690 perror("Memory Error");
691 parseStr += "'";
692 parseStr += filename;
693 parseStr += "' may not be a valid text file.\n";
694 free(buf);
695 delete file;
696 return false;
697 }
698
699 if (file->Read8(buf, num) != num) {
700 perror("Read-File Error");
701 parseStr += "'";
702 parseStr += filename;
703 parseStr += "' may not be a valid text file.\n";
704 free(buf);
705 delete file;
706 return false;
707 }
708
709 // lut8type
711 CIccUInt8Array data;
712
713 //if (!data.ParseTextArray(buf)) {
714 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
715 parseStr += "File '";
716 parseStr += filename;
717 parseStr += "' is not a valid text file.\n";
718 SetSize(0);
719 free(buf);
720 delete file;
721 return false;
722 }
723
724 else {
725 SetSize(data.GetSize());
726 icUInt8Number *src = data.GetBuf();
728
730 for (i = 0; i < data.GetSize(); i++) {
731 *dst = (icFloatNumber)(*src) / 255.0f;
732 dst++;
733 src++;
734 }
735
736 //if (i!=256) {
737 //printf("Error! - Input/Output table does not have 256 entries.\n");
738 //SetSize(0);
739 //return false;
740 //}
741 delete file;
742 return true;
743 }
744 }
745
746 //lut16type
747 else if (m_storageType == icValueTypeUInt16) {
748 CIccUInt16Array data;
749
750 //if (!data.ParseTextArray(buf)) {
751 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
752 parseStr += "File '";
753 parseStr += filename;
754 parseStr += "' is not a valid text file.\n";
755 SetSize(0);
756 free(buf);
757 delete file;
758 return false;
759 }
760
761 else {
762 SetSize(data.GetSize());
763
764 icUInt16Number *src = data.GetBuf();
766
768 for (i = 0; i < data.GetSize(); i++) {
769 *dst = (icFloatNumber)(*src) / 65535.0f;
770 dst++;
771 src++;
772 }
773 }
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 free(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 file;
806 return true;
807 }
808 else {
809 delete file;
810 return false;
811 }
812 }
813 // format is binary
814 else if (!strcmp(format, "binary")) {
815 const char *order = icXmlAttrValue(pNode, "Endian");
816 bool little_endian = !strcmp(order, "little");
817
819 icUInt32Number num = file->GetLength();
820 icUInt8Number value;
821
822 SetSize(num);
825 for (i = 0; i < num; i++) {
826 if (!file->Read8(&value)) {
827 perror("Read-File Error");
828 parseStr += "'";
829 parseStr += filename;
830 parseStr += "' may not be a valid binary file.\n";
831 delete file;
832 return false;
833 }
834 *dst++ = (icFloatNumber)value / 255.0f;
835 }
836 delete file;
837 return true;
838 }
839 else if (m_storageType == icValueTypeUInt16) {
840 icUInt32Number num = file->GetLength() / sizeof(icUInt16Number);
841 icUInt16Number value;
842 icUInt8Number *m_ptr = (icUInt8Number*)&value;
843
844 SetSize(num);
847 for (i = 0; i < num; i++) {
848 if (!file->Read16(&value)) { //assumes data is big endian
849 perror("Read-File Error");
850 parseStr += "'";
851 parseStr += filename;
852 parseStr += "' may not be a valid binary file.\n";
853 delete file;
854 return false;
855 }
856#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
857 if (little_endian) {
858#else
859 if (!little_endian) {
860#endif
861 icUInt8Number t = m_ptr[0];
862 m_ptr[0] = m_ptr[1];
863 m_ptr[1] = t;
864 }
865 *dst++ = (icFloatNumber)value / 65535.0f;
866 }
867 delete file;
868 return true;
869 }
870 else if (m_storageType == icValueTypeFloat16) {
871 icUInt32Number num = file->GetLength() / sizeof(icFloat16Number);
872 icFloat16Number value;
873 icUInt8Number *m_ptr = (icUInt8Number*)&value;
874
875 SetSize(num);
878 for (i = 0; i < num; i++) {
879 if (!file->Read16(&value)) { //assumes data is big endian
880 perror("Read-File Error");
881 parseStr += "'";
882 parseStr += filename;
883 parseStr += "' may not be a valid binary file.\n";
884 delete file;
885 return false;
886 }
887#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
888 if (little_endian) {
889#else
890 if (!little_endian) {
891#endif
892 icUInt8Number t = m_ptr[0];
893 m_ptr[0] = m_ptr[1];
894 m_ptr[1] = t;
895 }
896 *dst++ = icF16toF(value);
897 }
898 delete file;
899 return true;
900 }
901 else if (m_storageType == icValueTypeFloat32) {
902 icUInt32Number num = file->GetLength() / sizeof(icFloat32Number);
903 icFloat32Number value;
904 icUInt8Number *m_ptr = (icUInt8Number*)&value;
905
906 SetSize(num);
908
910 for (i = 0; i < num; i++) {
911 if (!file->ReadFloat32Float(&value)) {
912 perror("Read-File Error");
913 parseStr += "'";
914 parseStr += filename;
915 parseStr += "' may not be a valid binary file.\n";
916 delete file;
917 return false;
918 }
919#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
920 if (little_endian) {
921#else
922 if (!little_endian) {
923#endif
924 icUInt8Number tmp;
925 tmp = m_ptr[0]; m_ptr[0] = m_ptr[3]; m_ptr[3] = tmp;
926 tmp = m_ptr[1]; m_ptr[1] = m_ptr[2]; m_ptr[2] = tmp;
927 }
928 *dst++ = value;
929 }
930 delete file;
931 return true;
932 }
933 else { //not 8bit/16bit/float
934 delete file;
935 return false;
936 }
937 }
938 else {//not text/binary
939 delete file;
940 return false;
941 }
942 }
943 // no file
944 else {
945 CIccFloatArray samples;
946
947 if (!samples.ParseArray(pNode->children)) {
948 return false;
949 }
950
951 if (!SetSize(samples.GetSize())) {
952 return false;
953 }
954
955 memcpy(m_pSamples, samples.GetBuf(), samples.GetSize() * sizeof(icFloatNumber));
956 }
957
958 return true;
959 }
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
CIccIO * IccOpenFileIO(const icChar *szFilename, const char *szAttr)
Definition IccIoXml.cpp:100
icFloatNumber icF16toF(icFloat16Number num)
Definition IccUtil.cpp:629
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
unsigned int icUInt32Number
Type: Class.
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
icFloatNumber m_firstEntry
icUInt16Number m_extensionType
icFloatNumber m_lastEntry
icFloatNumber * m_pSamples
icUInt16Number m_storageType
virtual bool SetSize(icUInt32Number nSize, bool bZeroAlloc=true)
Name: CIccSingleSampledCurve::SetSize.
static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode)
bool ParseTextArrayNum(const char *szText, icUInt32Number num, std::string &parseStr)
icUInt32Number GetSize()
Definition IccUtilXml.h:166
unsigned char icUInt8Number
Number definitions.
float icFloat32Number
unsigned short icUInt16Number
icUInt16Number icFloat16Number
IEEE float storage numbers.
@ icClipSingleSampledCurve
@ icValueTypeFloat16
@ icValueTypeUInt8
@ icValueTypeUInt16
@ icValueTypeFloat32

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

Referenced by ParseXmlCurve().

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

◆ ToXml()

bool CIccSinglSampledeCurveXml::ToXml ( std::string & xml,
std::string blanks )

Definition at line 612 of file IccMpeXml.cpp.

613{
614 char line[256];
615
616 xml += blanks;
617 sprintf(line, "<SingleSampledCurve FirstEntry=\"" icXmlFloatFmt "\"", m_firstEntry);
618 xml += line;
619
620 sprintf(line, " LastEntry=\"" icXmlFloatFmt "\"", m_lastEntry);
621 xml += line;
622
623 sprintf(line, " StorageType=\"%u\"", m_storageType);
624 xml += line;
625
626 sprintf(line, " ExtensionType=\"%u\">\n", m_extensionType);
627 xml += line;
628
630
631 xml += blanks + "</SingleSampledCurve>\n";
632
633 return true;
634}
@ icConvertFloat
#define icXmlFloatFmt
icUInt32Number m_nCount
static bool DumpArray(std::string &xml, std::string blanks, T *buf, icUInt32Number nBufSize, icConvertType nType, icUInt8Number nColumns)

References CIccXmlArrayType< T, Tsig >::DumpArray(), icConvertFloat, and icXmlFloatFmt.

Referenced by ToXmlCurve().

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

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