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

#include <IccTagXml.h>

+ Inheritance diagram for CIccTagXmlNamedColor2:
+ Collaboration diagram for CIccTagXmlNamedColor2:

Public Member Functions

virtual const char * GetClassName () const
 
virtual IIccExtensionTagGetExtension ()
 
virtual bool ParseXml (xmlNode *pNode, std::string &parseStr)
 
virtual bool ToXml (std::string &xml, std::string blanks="")
 
virtual ~CIccTagXmlNamedColor2 ()
 
- Public Member Functions inherited from CIccTagNamedColor2
 CIccTagNamedColor2 (const CIccTagNamedColor2 &ITNC)
 Name: CIccTagNamedColor2::CIccTagNamedColor2.
 
 CIccTagNamedColor2 (int nSize=1, int nDeviceCoords=0)
 Name: CIccTagNamedColor2::CIccTagNamedColor2.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccTagNamedColor2::Describe.
 
icInt32Number FindCachedPCSColor (icFloatNumber *pPCS, icFloatNumber dMinDE=1000.0) const
 Name: CIccTagNamedColor2::FindPCSColor.
 
icInt32Number FindColor (const icChar *szColor) const
 Name: CIccTagNamedColor2::FindColor.
 
icInt32Number FindDeviceColor (icFloatNumber *pDevColor) const
 Name: CIccTagNamedColor2::FindDeviceColor.
 
icInt32Number FindPCSColor (icFloatNumber *pPCS, icFloatNumber dMinDE=1000.0)
 Name: CIccTagNamedColor2::FindPCSColor.
 
icInt32Number FindRootColor (const icChar *szRootColor) const
 Name: CIccTagNamedColor2::FindRootColor.
 
bool GetColorName (std::string &sColorName, icInt32Number index) const
 Name: CIccTagNamedColor2::GetColorName.
 
icUInt32Number GetDeviceCoords () const
 
icColorSpaceSignature GetDeviceSpace () const
 
SIccNamedColorEntryGetEntry (icUInt32Number index) const
 
icColorSpaceSignature GetPCS () const
 
const icCharGetPrefix () const
 
icUInt32Number GetSize () const
 
const icCharGetSufix () const
 
virtual icTagTypeSignature GetType () const
 Function: GetType()
 
icUInt32Number GetVendorFlags () const
 
bool InitFindCachedPCSColor ()
 Name: CIccTagNamedColor2::InitFindPCSColor.
 
void Lab2ToLab4 (icFloatNumber *Dst, const icFloatNumber *Src) const
 Name: CIccTagNamedColor2::Lab2ToLab4.
 
void Lab4ToLab2 (icFloatNumber *Dst, const icFloatNumber *Src) const
 Name: CIccTagNamedColor2::Lab4ToLab2.
 
icFloatNumber NegClip (icFloatNumber v) const
 Name: CIccTagNamedColor2::NegClip.
 
virtual CIccTagNewCopy () const
 Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
 
CIccTagNamedColor2operator= (const CIccTagNamedColor2 &NamedColor2Tag)
 Name: CIccTagNamedColor2::operator=.
 
SIccNamedColorEntryoperator[] (icUInt32Number index) const
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccTagNamedColor2::Read.
 
void ResetPCSCache ()
 Call ResetPCSCache() if entry values change between calls to FindPCSColor()
 
virtual void SetColorSpaces (icColorSpaceSignature csPCS, icColorSpaceSignature csDevice)
 Name: CIccTagNamedColor2::SetColorSpaces.
 
void SetPrefix (const icChar *szPrefix)
 Name: CIccTagNamedColor2::SetPrefix.
 
bool SetSize (icUInt32Number nSize, icInt32Number nDeviceCoords=-1)
 Name: CIccTagNamedColor2::SetSize.
 
void SetSufix (const icChar *szSufix)
 Name: CIccTagNamedColor2::SetSufix.
 
void SetVendorFlags (icUInt32Number nVendorFlags)
 
icFloatNumber UnitClip (icFloatNumber v) const
 Name: CIccTagNamedColor2::UnitClip.
 
virtual bool UseLegacyPCS () const
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccProfile *pProfile=NULL) const
 Name: CIccTagNamedColor2::Validate.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccTagNamedColor2::Write.
 
virtual ~CIccTagNamedColor2 ()
 Name: CIccTagNamedColor2::~CIccTagNamedColor2.
 
- Public Member Functions inherited from CIccTag
 CIccTag ()
 Name: CIccTag::CIccTag.
 
virtual void DetachIO ()
 Function: ReadAll() - Read All sub data for tag from file.
 
virtual icArraySignature GetTagArrayType () const
 
virtual icStructSignature GetTagStructType () const
 
virtual bool IsArrayType ()
 
virtual bool IsMBBType ()
 
virtual bool IsNumArrayType () const
 
virtual bool IsSupported ()
 Function: IsSupported(size, pIO) - Check if tag fully supported for apply purposes.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO, CIccProfile *pProfile)
 Function: Read(size, pIO) - Read tag from file.
 
virtual bool ReadAll ()
 Function: ReadAll() - Read All sub data for tag from file.
 
virtual ~CIccTag ()
 Name: CIccTag::CIccTag.
 
- Public Member Functions inherited from CIccTagXml
virtual const char * GetExtClassName () const
 
virtual const char * GetExtDerivedClassName () const
 
virtual ~CIccTagXml (void)
 

Additional Inherited Members

- Static Public Member Functions inherited from CIccTag
static CIccTagCreate (icTagTypeSignature sig)
 Name: CIccTag::Create.
 
- Public Attributes inherited from CIccTag
icUInt32Number m_nReserved
 
- Protected Attributes inherited from CIccTagNamedColor2
icColorSpaceSignature m_csDevice
 
icColorSpaceSignature m_csPCS
 
SIccNamedColorEntrym_NamedColor
 
SIccNamedLabEntrym_NamedLab
 
icUInt32Number m_nColorEntrySize
 For quick response of repeated FindPCSColor.
 
icUInt32Number m_nDeviceCoords
 
icUInt32Number m_nSize
 
icUInt32Number m_nVendorFlags
 
icChar m_szPrefix [32]
 
icChar m_szSufix [32]
 

Detailed Description

Definition at line 216 of file IccTagXml.h.

Constructor & Destructor Documentation

◆ ~CIccTagXmlNamedColor2()

virtual CIccTagXmlNamedColor2::~CIccTagXmlNamedColor2 ( )
inlinevirtual

Definition at line 219 of file IccTagXml.h.

219{}

Member Function Documentation

◆ GetClassName()

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

Reimplemented from CIccTagNamedColor2.

Definition at line 221 of file IccTagXml.h.

221{return "CIccTagXmlNamedColor2"; }

◆ GetExtension()

virtual IIccExtensionTag * CIccTagXmlNamedColor2::GetExtension ( )
inlinevirtual

Reimplemented from CIccTag.

Definition at line 223 of file IccTagXml.h.

223{return this; }

◆ ParseXml()

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

Implements CIccTagXml.

Definition at line 721 of file IccTagXml.cpp.

722{
723 pNode = icXmlFindNode(pNode, "NamedColors");
724
725 if (pNode) {
726 const icChar *szVendorFlags = icXmlAttrValue(pNode, "VendorFlag");
727 const icChar *szDeviceCoords = icXmlAttrValue(pNode, "CountOfDeviceCoords");
728 const icChar *szDeviceEncoding = icXmlAttrValue(pNode, "DeviceEncoding");
729 const icChar *szPrefix = icXmlAttrValue(pNode, "Prefix");
730 const icChar *szSufix = icXmlAttrValue(pNode, "Suffix");
731
732 if (szVendorFlags && *szVendorFlags &&
733 szDeviceCoords && *szDeviceCoords &&
734 szDeviceEncoding && *szDeviceEncoding &&
735 szPrefix && szSufix) {
736 std::string str;
737
738 sscanf(szVendorFlags, "%x", &m_nVendorFlags);
739
740 strncpy(m_szPrefix, icUtf8ToAnsi(str, szPrefix), sizeof(m_szPrefix));
741 m_szPrefix[sizeof(m_szPrefix)-1] = '\0';
742
743 strncpy(m_szSufix, icUtf8ToAnsi(str, szSufix), sizeof(m_szSufix));
744 m_szSufix[sizeof(m_szSufix)-1] = '\0';
745
746 m_nDeviceCoords = atoi(szDeviceCoords);
747 icUInt32Number n = icXmlNodeCount3(pNode->children, "NamedColor", "LabNamedColor", "XYZNamedColor");
749
751
752 SIccNamedColorEntry *pNamedColor = m_NamedColor;
753
754 for (i=0, pNode=pNode->children; pNode; pNode=pNode->next) {
755 const icChar *szName = NULL;
756 if (pNode->type == XML_ELEMENT_NODE &&
757 !icXmlStrCmp(pNode->name, "NamedColor") &&
758 i<n) {
759 szName = icXmlAttrValue(pNode, "Name");
760 xmlAttr *L = icXmlFindAttr(pNode, "L");
761 xmlAttr *a = icXmlFindAttr(pNode, "a");
762 xmlAttr *b = icXmlFindAttr(pNode, "b");
763
764 if (L && a && b) {
765 pNamedColor->pcsCoords[0] = (icFloatNumber)atof(icXmlAttrValue(L));
766 pNamedColor->pcsCoords[1] = (icFloatNumber)atof(icXmlAttrValue(a));
767 pNamedColor->pcsCoords[2] = (icFloatNumber)atof(icXmlAttrValue(b));
768
769 icLabToPcs(pNamedColor->pcsCoords);
770 Lab4ToLab2(pNamedColor->pcsCoords, pNamedColor->pcsCoords);
771 }
772 else {
773 xmlAttr *x = icXmlFindAttr(pNode, "X");
774 xmlAttr *y = icXmlFindAttr(pNode, "Y");
775 xmlAttr *z = icXmlFindAttr(pNode, "Z");
776
777 if (x && y && z) {
778 pNamedColor->pcsCoords[0] = (icFloatNumber)atof(icXmlAttrValue(x));
779 pNamedColor->pcsCoords[1] = (icFloatNumber)atof(icXmlAttrValue(y));
780 pNamedColor->pcsCoords[2] = (icFloatNumber)atof(icXmlAttrValue(z));
781
782 icXyzToPcs(pNamedColor->pcsCoords);
783 }
784 else
785 return false;
786 }
787 }
788 else if (pNode->type == XML_ELEMENT_NODE &&
789 !icXmlStrCmp(pNode->name, "LabNamedColor") &&
790 i < n) {
791 szName = icXmlAttrValue(pNode, "Name");
792 xmlAttr *L = icXmlFindAttr(pNode, "L");
793 xmlAttr *a = icXmlFindAttr(pNode, "a");
794 xmlAttr *b = icXmlFindAttr(pNode, "b");
795
796 if (L && a && b) {
797 pNamedColor->pcsCoords[0] = (icFloatNumber)atof(icXmlAttrValue(L));
798 pNamedColor->pcsCoords[1] = (icFloatNumber)atof(icXmlAttrValue(a));
799 pNamedColor->pcsCoords[2] = (icFloatNumber)atof(icXmlAttrValue(b));
800
801 icLabToPcs(pNamedColor->pcsCoords);
802 Lab4ToLab2(pNamedColor->pcsCoords, pNamedColor->pcsCoords);
803 }
804 else {
805 return false;
806 }
807 }
808 else if (pNode->type == XML_ELEMENT_NODE &&
809 !icXmlStrCmp(pNode->name, "XYZNamedColor") &&
810 i < n) {
811 szName = icXmlAttrValue(pNode, "Name");
812 xmlAttr *x = icXmlFindAttr(pNode, "X");
813 xmlAttr *y = icXmlFindAttr(pNode, "Y");
814 xmlAttr *z = icXmlFindAttr(pNode, "Z");
815
816 if (x && y && z) {
817 pNamedColor->pcsCoords[0] = (icFloatNumber)atof(icXmlAttrValue(x));
818 pNamedColor->pcsCoords[1] = (icFloatNumber)atof(icXmlAttrValue(y));
819 pNamedColor->pcsCoords[2] = (icFloatNumber)atof(icXmlAttrValue(z));
820
821 icXyzToPcs(pNamedColor->pcsCoords);
822 }
823 else
824 return false;
825 }
826
827 if (szName) {
828 strncpy(pNamedColor->rootName, icUtf8ToAnsi(str, szName), sizeof(pNamedColor->rootName));
829 pNamedColor->rootName[sizeof(pNamedColor->rootName) - 1] = 0;
830
831 if (m_nDeviceCoords && pNode->children) {
832 if (!strcmp(szDeviceEncoding, "int8")) {
833 CIccUInt8Array coords;
834
835 coords.ParseArray(pNode->children);
836 icUInt8Number *pBuf = coords.GetBuf();
837
839 for (j = 0; j < m_nDeviceCoords && j < coords.GetSize(); j++) {
840 pNamedColor->deviceCoords[j] = (icFloatNumber)pBuf[i] / 255.0f;
841 }
842 }
843 else if (!strcmp(szDeviceEncoding, "int16")) {
844 CIccUInt16Array coords;
845
846 coords.ParseArray(pNode->children);
847 icUInt16Number *pBuf = coords.GetBuf();
848
850 for (j = 0; j < m_nDeviceCoords && j < coords.GetSize(); j++) {
851 pNamedColor->deviceCoords[j] = (icFloatNumber)pBuf[i] / 65535.0f;
852 }
853 }
854 else if (!strcmp(szDeviceEncoding, "float")) {
855 CIccFloatArray coords;
856
857 coords.ParseArray(pNode->children);
858 icFloatNumber *pBuf = coords.GetBuf();
859
861 for (j = 0; j < m_nDeviceCoords && j < coords.GetSize(); j++) {
862 pNamedColor->deviceCoords[j] = (icFloatNumber)pBuf[i];
863 }
864 }
865 else
866 return false;
867 }
868
869 i++;
870 pNamedColor = (SIccNamedColorEntry*)((icChar*)pNamedColor + m_nColorEntrySize);
871 }
872 }
873 return i==n;
874 }
875 }
876 return false;
877}
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
char icChar
Definition IccDefs.h:109
const icChar * szName
void icXyzToPcs(icFloatNumber *XYZ)
Definition IccUtil.cpp:941
void icLabToPcs(icFloatNumber *Lab)
Definition IccUtil.cpp:927
const char * icUtf8ToAnsi(std::string &buf, const char *szSrc)
icUInt32Number icXmlNodeCount3(xmlNode *pNode, const char *szNodeName1, const char *szNodeName2, const char *szNodeName3)
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
xmlNode * icXmlFindNode(xmlNode *pNode, const char *szNodeName)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
#define icXmlStrCmp(x, y)
Definition IccUtilXml.h:134
unsigned int icUInt32Number
SIccNamedColorEntry * m_NamedColor
icUInt32Number m_nVendorFlags
void Lab4ToLab2(icFloatNumber *Dst, const icFloatNumber *Src) const
Name: CIccTagNamedColor2::Lab4ToLab2.
icChar m_szSufix[32]
icUInt32Number m_nColorEntrySize
For quick response of repeated FindPCSColor.
bool SetSize(icUInt32Number nSize, icInt32Number nDeviceCoords=-1)
Name: CIccTagNamedColor2::SetSize.
icUInt32Number m_nDeviceCoords
icChar m_szPrefix[32]
static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode)
icUInt32Number GetSize()
Definition IccUtilXml.h:166
unsigned char icUInt8Number
Number definitions.
unsigned short icUInt16Number
icChar rootName[32]
icFloatNumber deviceCoords[1]
icFloatNumber pcsCoords[3]

References SIccNamedColorEntry::deviceCoords, CIccXmlArrayType< T, Tsig >::GetBuf(), CIccXmlArrayType< T, Tsig >::GetSize(), icLabToPcs(), icUtf8ToAnsi(), icXmlAttrValue(), icXmlFindAttr(), icXmlFindNode(), icXmlNodeCount3(), icXmlStrCmp, icXyzToPcs(), CIccXmlArrayType< T, Tsig >::ParseArray(), SIccNamedColorEntry::pcsCoords, SIccNamedColorEntry::rootName, and szName.

+ Here is the call graph for this function:

◆ ToXml()

bool CIccTagXmlNamedColor2::ToXml ( std::string & xml,
std::string blanks = "" )
virtual

Implements CIccTagXml.

Definition at line 655 of file IccTagXml.cpp.

656{
657 char fix[256];
658 char line[256];
659 char buf[256];
660 int i, j;
661 std::string str;
662
663 sprintf(line, "<NamedColors VendorFlag=\"%08x\" CountOfDeviceCoords=\"%d\" DeviceEncoding=\"int16\"", m_nVendorFlags, m_nDeviceCoords);
664 xml += blanks + line;
665
666 sprintf(line, " Prefix=\"%s\"", icFixXml(fix, icAnsiToUtf8(str, m_szPrefix)));
667 xml += line;
668
669 sprintf(line, " Suffix=\"%s\">\n", icFixXml(fix, icAnsiToUtf8(str, m_szSufix)));
670 xml += line;
671
672 for (i=0; i<(int)m_nSize; i++) {
673 SIccNamedColorEntry *pEntry= GetEntry(i);
674
675 const char *szNodeName = "";
676
677 if (pEntry) {
678 if (m_csPCS==icSigLabData) {
679 icFloatNumber lab[3];
680
681 Lab2ToLab4(lab, pEntry->pcsCoords);
682 icLabFromPcs(lab);
683 szNodeName = "LabNamedColor";
684 sprintf(line, " <%s Name=\"%s\" L=\"" icXmlFloatFmt "\" a=\"" icXmlFloatFmt "\" b=\"" icXmlFloatFmt "\"", szNodeName,
685 icFixXml(fix, icAnsiToUtf8(str, pEntry->rootName)), lab[0], lab[1], lab[2]);
686 xml += blanks + line;
687 }
688 else {
689 icFloatNumber xyz[3];
690
691 memcpy(xyz, pEntry->pcsCoords, 3*sizeof(icFloatNumber));
692 icXyzFromPcs(xyz);
693 szNodeName = "XYZNamedColor";
694 sprintf(line, " <%s Name=\"%s\" X=\"" icXmlFloatFmt "\" Y=\"" icXmlFloatFmt "\" Z=\"" icXmlFloatFmt "\"", szNodeName,
695 icFixXml(fix, icAnsiToUtf8(str, pEntry->rootName)), xyz[0], xyz[1], xyz[2]);
696 xml += blanks + line;
697 }
698
699 if (!m_nDeviceCoords) {
700 xml += "/>\n";
701 }
702 else {
703 xml += ">";
704 for (j=0; j<(int)m_nDeviceCoords; j++) {
705 if (j)
706 xml+=" ";
707 sprintf(buf, "%d", (int)(pEntry->deviceCoords[j] * 65535.0 + 0.5));
708 xml += buf;
709 }
710 xml += "\n";
711
712 xml += blanks + " </" + szNodeName + ">\n";
713 }
714 }
715 }
716 xml += blanks + " </NamedColors>\n";
717 return true;
718}
void icXyzFromPcs(icFloatNumber *XYZ)
Floating point encoding of XYZ in PCS is in range 0.0 to 1.0 (Note: X=1.0 is encoded as about 0....
Definition IccUtil.cpp:934
void icLabFromPcs(icFloatNumber *Lab)
Floating point encoding of Lab in PCS is in range 0.0 to 1.0.
Definition IccUtil.cpp:919
const char * icFixXml(std::string &buf, const char *szStr)
const char * icAnsiToUtf8(std::string &buf, const char *szSrc)
#define icXmlFloatFmt
icColorSpaceSignature m_csPCS
icUInt32Number m_nSize
void Lab2ToLab4(icFloatNumber *Dst, const icFloatNumber *Src) const
Name: CIccTagNamedColor2::Lab2ToLab4.
SIccNamedColorEntry * GetEntry(icUInt32Number index) const
@ icSigLabData

References SIccNamedColorEntry::deviceCoords, icAnsiToUtf8(), icFixXml(), icLabFromPcs(), icSigLabData, icXmlFloatFmt, icXyzFromPcs(), SIccNamedColorEntry::pcsCoords, and SIccNamedColorEntry::rootName.

+ Here is the call graph for this function:

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