79#ifdef USEREFICCMAXNAMESPACE
90 sprintf(line,
"<UnknownElement Type=\"%s\" InputChannels=\"%d\" OutputChannels=\"%d\"",
95 sprintf(line,
" Reserved=\"%u\"", m_nReserved);
102 xml += blanks +
"</UnknownElement>\n";
112 if (pNode->children && pNode->children->type == XML_TEXT_NODE && pNode->children->content) {
115 if (!SetDataSize(nSize,
false))
118 icXmlGetHexData(m_pData, (
const char *)pNode->children->content, nSize);
132 bool ToXml(std::string &xml, std::string blanks);
133 bool ParseXml(xmlNode *pNode, std::string &parseStr);
139 strcpy(buf,
"-infinity");
141 strcpy(buf,
"+infinity");
150 if (!strncmp(str,
"-inf", 4)) {
153 if (!strncmp(str,
"+inf", 4)) {
166 sprintf(line,
"<FormulaSegment Start=\"%s\"",
icSegPos(buf, m_startPoint));
167 xml += blanks + line;
169 sprintf(line,
" End=\"%s\"",
icSegPos(buf, m_endPoint));
172 sprintf(line,
" FunctionType=\"%d\"", m_nFunctionType);
176 sprintf(line,
" Reserved=\"%d\"", m_nReserved);
180 sprintf(line,
" Reserved2=\"%d\"", m_nReserved2);
187 xml += blanks +
"</FormulaSegment>\n";
198 parseStr +=
"Bad FunctionType in Formula Segment\n";
206 switch(m_nFunctionType) {
228 parseStr +=
"Unsupported FunctionType value in Formula Segment\n";
237 if (args.
GetSize()<m_nParameters)
263 bool ToXml(std::string &xml, std::string blanks);
264 bool ParseXml(xmlNode *pNode, std::string &parseStr);
272 sprintf(line,
"<SampledSegment Start=\"%s\"",
icSegPos(buf, m_startPoint));
273 xml += blanks + line;
275 sprintf(line,
" End=\"%s\">\n",
icSegPos(buf, m_endPoint));
280 xml += blanks +
"</SampledSegment>\n";
294 parseStr +=
"Error! - File '";
295 parseStr += filename;
296 parseStr +=
"' not found.\n";
304 if (!strcmp(format,
"text")) {
306 char *buf = (
char *)
new char[num];
309 perror(
"Memory Error");
311 parseStr += filename;
312 parseStr +=
"' may not be a valid text file.\n";
318 if (file->
Read8(buf, num) !=num) {
319 perror(
"Read-File Error");
321 parseStr += filename;
322 parseStr +=
"' may not be a valid text file.\n";
332 parseStr +=
"File '";
333 parseStr += filename;
334 parseStr +=
"' is not a valid text file.\n";
347 for (i=0; i<data.
GetSize(); i++) {
360 else if (!strcmp(format,
"binary")) {
362 bool little_endian = !strcmp(order,
"little");
377 for (i=0; i<num; i++) {
378 if (!file->
Read8(&value)) {
379 perror(
"Read-File Error");
381 parseStr += filename;
382 parseStr +=
"' may not be a valid binary file.\n";
399 for (i=0; i<num; i++) {
400 if (!file->
Read16(&value)) {
401 perror(
"Read-File Error");
403 parseStr += filename;
404 parseStr +=
"' may not be a valid binary file.\n";
408#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
411 if (!little_endian) {
430 for (i=0; i<num; i++) {
431 if (!file->
Read16(&value)) {
432 perror(
"Read-File Error");
434 parseStr += filename;
435 parseStr +=
"' may not be a valid binary file.\n";
439#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
442 if (!little_endian) {
462 for (i=0; i<num; i++) {
464 perror(
"Read-File Error");
466 parseStr += filename;
467 parseStr +=
"' may not be a valid binary file.\n";
471#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
474 if (!little_endian) {
477 tmp = m_ptr[0]; m_ptr[0] = m_ptr[3]; m_ptr[3] = tmp;
478 tmp = m_ptr[1]; m_ptr[1] = m_ptr[2]; m_ptr[2] = tmp;
498 if (!SetSize(samples.
GetSize())) {
514 bool ToXml(std::string &xml, std::string blanks);
515 bool ParseXml(xmlNode *pNode, std::string &parseStr);
523 sprintf(line,
"<SampledCalculatorCurve FirstEntry=\"" icXmlFloatFmt "\"", m_firstEntry);
526 sprintf(line,
" LastEntry=\"" icXmlFloatFmt "\"", m_lastEntry);
529 sprintf(line,
" ExtensionType=\"%u\"", m_extensionType);
532 sprintf(line,
" DesiredSize=\"%u\">\n", m_nDesiredSize);
536 sprintf(line,
" Reservered2=\"%u\">\n", m_nReserved2);
540 if (m_pCalc && !strcmp(m_pCalc->GetClassName(),
"CIccMpeXmlCalculator")) {
542 if (!pXmlCalc->
ToXml(xml, blanks +
" "))
549 xml += blanks +
"</SampledCalculatorCurve>\n";
560 parseStr +=
"Bad FirstEntry in Sampled Calculator Curve\n";
569 parseStr +=
"Bad LastEntry in Sampled Calculator Curve\n";
578 parseStr +=
"Bad DesiredSize in Sampled Calculator Curve\n";
584 xmlNode *pCalcNode =
icXmlFindNode(pNode->children,
"CalculatorElement");
588 if (!pCalc->
ParseXml(pCalcNode, parseStr)) {
589 parseStr +=
"Unable to parse calculator element in Sampled Calculator Curve\n";
595 parseStr +=
"Missing Calculator Element in Sampled Calculator Curve\n";
608 bool ToXml(std::string &xml, std::string blanks);
609 bool ParseXml(xmlNode *pNode, std::string &parseStr);
617 sprintf(line,
"<SingleSampledCurve FirstEntry=\"" icXmlFloatFmt "\"", m_firstEntry);
620 sprintf(line,
" LastEntry=\"" icXmlFloatFmt "\"", m_lastEntry);
623 sprintf(line,
" StorageType=\"%u\"", m_storageType);
626 sprintf(line,
" ExtensionType=\"%u\">\n", m_extensionType);
631 xml += blanks +
"</SingleSampledCurve>\n";
642 parseStr +=
"Bad FirstEntry in Simple Sampled Segment\n";
651 parseStr +=
"Bad LastEntry in Simple Sampled Segment\n";
675 parseStr +=
"Error! - File '";
676 parseStr += filename;
677 parseStr +=
"' not found.\n";
685 if (!strcmp(format,
"text")) {
687 char *buf = (
char *)
new char[num];
690 perror(
"Memory Error");
692 parseStr += filename;
693 parseStr +=
"' may not be a valid text file.\n";
699 if (file->
Read8(buf, num) != num) {
700 perror(
"Read-File Error");
702 parseStr += filename;
703 parseStr +=
"' may not be a valid text file.\n";
715 parseStr +=
"File '";
716 parseStr += filename;
717 parseStr +=
"' is not a valid text file.\n";
730 for (i = 0; i < data.
GetSize(); i++) {
752 parseStr +=
"File '";
753 parseStr += filename;
754 parseStr +=
"' is not a valid text file.\n";
768 for (i = 0; i < data.
GetSize(); i++) {
784 parseStr +=
"File '";
785 parseStr += filename;
786 parseStr +=
"' is not a valid text file.\n";
799 for (i = 0; i < data.
GetSize(); i++) {
814 else if (!strcmp(format,
"binary")) {
816 bool little_endian = !strcmp(order,
"little");
825 for (i = 0; i < num; i++) {
826 if (!file->
Read8(&value)) {
827 perror(
"Read-File Error");
829 parseStr += filename;
830 parseStr +=
"' may not be a valid binary file.\n";
847 for (i = 0; i < num; i++) {
848 if (!file->
Read16(&value)) {
849 perror(
"Read-File Error");
851 parseStr += filename;
852 parseStr +=
"' may not be a valid binary file.\n";
856#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
859 if (!little_endian) {
878 for (i = 0; i < num; i++) {
879 if (!file->
Read16(&value)) {
880 perror(
"Read-File Error");
882 parseStr += filename;
883 parseStr +=
"' may not be a valid binary file.\n";
887#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
890 if (!little_endian) {
910 for (i = 0; i < num; i++) {
912 perror(
"Read-File Error");
914 parseStr += filename;
915 parseStr +=
"' may not be a valid binary file.\n";
919#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
922 if (!little_endian) {
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;
951 if (!SetSize(samples.
GetSize())) {
964 CIccCurveSegmentList::iterator seg;
965 xml += blanks +
"<SegmentedCurve>\n";
966 for (seg = m_list->begin(); seg!=m_list->end(); seg++) {
979 xml += blanks +
"</SegmentedCurve>\n";
987 for (pNode=pNode->children; pNode; pNode=pNode->next) {
988 if (pNode->type == XML_ELEMENT_NODE) {
995 if (!pSegXml->
ParseXml(pNode, parseStr)) {
996 parseStr +=
"Unable to parse FormulaSegment\n";
1000 m_list->push_back(pSegXml);
1002 else if (!
icXmlStrCmp(pNode->name,
"SampledSegment")) {
1005 if (!pSegXml->
ParseXml(pNode, parseStr)) {
1006 parseStr +=
"Unable to parse SampledSegment\n";
1010 m_list->push_back(pSegXml);
1013 parseStr +=
"Bad Segment Type\n";
1027 if (!(m_ptr->
ToXml(xml, blanks +
" ")))
1033 if (!(m_ptr->
ToXml(xml, blanks +
" ")))
1039 if (!(m_ptr->
ToXml(xml, blanks +
" ")))
1051 sprintf(line,
"<CurveSetElement InputChannels=\"%d\" OutputChannels=\"%d\"", NumInputChannels(), NumOutputChannels());
1052 xml += blanks + line;
1055 sprintf(line,
" Reserved=\"%u\"", m_nReserved);
1062 for (i=0; i<NumInputChannels(); i++) {
1066 for (j = 0; j < i; j++) {
1067 if (m_curve[i] == m_curve[j])
1073 sprintf(line,
"<DuplicateCurve Index=\"%d\"/>\n", j);
1074 xml += blanks +
" ";
1077 else if (!
ToXmlCurve(xml, blanks, m_curve[i]))
1081 xml += blanks +
"</CurveSetElement>\n";
1089 if (!strcmp((
const char*)pNode->name,
"SegmentedCurve")) {
1092 if (pCurve->
ParseXml(pNode, parseStr)) {
1098 else if (!strcmp((
const char*)pNode->name,
"SingleSampledCurve")) {
1101 if (pCurve->
ParseXml(pNode, parseStr)) {
1107 else if (!strcmp((
const char*)pNode->name,
"SampledCalculatorCurve")) {
1110 if (pCurve->
ParseXml(pNode, parseStr)) {
1125 if (!nChannels || atoi(
icXmlAttrValue(pNode,
"OutputChannels")) != nChannels) {
1126 parseStr +=
"Invalid InputChannels or OutputChannels In CurveSetElement\n";
1132 for (pNode = pNode->children, nIndex = 0;
1134 pNode=pNode->next) {
1135 if (pNode->type == XML_ELEMENT_NODE) {
1136 if (nIndex >= nChannels) {
1139 else if (!strcmp((
const char*)pNode->name,
"DuplicateCurve")) {
1143 int nCopyIndex = atoi(attr);
1144 if (nCopyIndex >= 0 && nCopyIndex < nIndex) {
1145 m_curve[nIndex] = m_curve[nCopyIndex];
1149 parseStr +=
"Invalid index for duplicate CurveSet Curve\n";
1154 parseStr +=
"Missing index for duplicate CurveSet Curve\n";
1164 if (!SetCurve(nIndex, pCurve))
1171 if (!pNode && nIndex == nChannels)
1181 sprintf(buf,
"<MatrixElement InputChannels=\"%d\" OutputChannels=\"%d\"", NumInputChannels(), NumOutputChannels());
1182 xml += blanks + buf;
1185 sprintf(buf,
" Reserved=\"%u\"", m_nReserved);
1193 xml += blanks +
" <MatrixData>\n";
1195 for (n=0, j=0; j<NumOutputChannels(); j++) {
1196 xml += blanks +
" ";
1197 for (i=0; i<NumInputChannels(); i++, n++) {
1203 xml += blanks +
" </MatrixData>\n";
1207 for (i = 0; i < NumOutputChannels(); i++) {
1211 if (i < NumOutputChannels()) {
1212 xml += blanks +
" <ConstantData>\n";
1214 xml += blanks +
" ";
1215 for (i = 0; i < NumOutputChannels(); i++) {
1221 xml += blanks +
" </ConstantData>\n";
1225 xml += blanks +
"</MatrixElement>\n";
1235 if (!nInputChannels || !nOutputChannels) {
1236 parseStr +=
"Invalid InputChannels or OutputChannels In MatrixElement\n";
1244 SetSize(nInputChannels, nOutputChannels);
1249 const char *invert =
icXmlAttrValue(pData,
"InvertMatrix",
"false");
1250 if (!
stricmp(invert,
"true")) {
1251 if (m_nInputChannels != m_nOutputChannels) {
1252 parseStr +=
"Inversion of MatrixData requires square matrix\n";
1256 if (!pInverter || !pInverter->
Invert(m_pMatrix, m_nOutputChannels, m_nInputChannels)) {
1257 parseStr +=
"Unable to invert matrix!\n";
1263 SetSize(0, nOutputChannels);
1264 m_nInputChannels = nInputChannels;
1278 sprintf(buf,
"<EmissionMatrixElement InputChannels=\"%d\" OutputChannels=\"%d\"", NumInputChannels(), NumOutputChannels());
1279 xml += blanks + buf;
1282 sprintf(buf,
" Reserved=\"%u\"", m_nReserved);
1288 xml += blanks + buf;
1293 xml += blanks +
" <WhiteData>\n";
1295 xml += blanks +
" ";
1296 for (i=0; i<(int)m_Range.steps; i++) {
1302 xml += blanks +
" </WhiteData>\n";
1306 xml += blanks +
" <MatrixData>\n";
1308 for (n=0, j=0; j<numVectors(); j++) {
1309 xml += blanks +
" ";
1310 for (i=0; i<(int)m_Range.steps; i++, n++) {
1316 xml += blanks +
" </MatrixData>\n";
1320 xml += blanks +
" <OffsetData>\n";
1322 xml += blanks +
" ";
1323 for (i=0; i<(int)m_Range.steps; i++) {
1329 xml += blanks +
" </OffsetData>\n";
1332 xml += blanks +
"</EmissionMatrixElement>\n";
1343 if (!nInputChannels || !nOutputChannels) {
1344 parseStr +=
"Invalid InputChannels or OutputChannels In MatrixElement\n";
1357 parseStr +=
"Invalid Spectral Range\n";
1362 m_Range.steps = nSteps;
1365 SetSize(nInputChannels, nOutputChannels, m_Range);
1366 if (!m_pWhite || !m_pMatrix || !m_pOffset) {
1367 parseStr +=
"Unable to SetSize\n";
1378 parseStr +=
"Missing MatrixData";
1388 parseStr +=
"Missing MatrixData";
1397 memset(m_pOffset, 0, (
int)m_Range.steps*
sizeof(
icFloatNumber));
1405 sprintf(buf,
"<InvEmissionMatrixElement InputChannels=\"%d\" OutputChannels=\"%d\"", NumInputChannels(), NumOutputChannels());
1406 xml += blanks + buf;
1409 sprintf(buf,
" Reserved=\"%u\"", m_nReserved);
1415 xml += blanks + buf;
1420 xml += blanks +
" <WhiteData>\n";
1422 xml += blanks +
" ";
1423 for (i=0; i<(int)m_Range.steps; i++) {
1429 xml += blanks +
" </WhiteData>\n";
1433 xml += blanks +
" <MatrixData>\n";
1435 for (n=0, j=0; j<numVectors(); j++) {
1436 xml += blanks +
" ";
1437 for (i=0; i<(int)m_Range.steps; i++, n++) {
1443 xml += blanks +
" </MatrixData>\n";
1447 xml += blanks +
" <OffsetData>\n";
1449 xml += blanks +
" ";
1450 for (i=0; i<(int)m_Range.steps; i++) {
1456 xml += blanks +
" </OffsetData>\n";
1459 xml += blanks +
"</InvEmissionMatrixElement>\n";
1470 if (!nInputChannels || !nOutputChannels) {
1471 parseStr +=
"Invalid InputChannels or OutputChannels In MatrixElement\n";
1484 parseStr +=
"Invalid Spectral Range\n";
1489 m_Range.steps = nSteps;
1492 SetSize(nInputChannels, nOutputChannels, m_Range);
1493 if (!m_pWhite || !m_pMatrix || !m_pOffset) {
1494 parseStr +=
"Unable to SetSize\n";
1505 parseStr +=
"Missing White Data";
1515 parseStr +=
"Missing Matrix Data";
1524 memset(m_pOffset, 0, (
int)m_Range.steps*
sizeof(
icFloatNumber));
1531 char buf[128], line[128];
1532 sprintf(buf,
"<TintArrayElement InputChannels=\"%d\" OutputChannels=\"%d\"", NumInputChannels(), NumOutputChannels());
1533 xml += blanks + buf;
1536 sprintf(buf,
" Reserved=\"%u\"", m_nReserved);
1542 if (m_Array && (pTagEx=m_Array->GetExtension()) && !strcmp(pTagEx->
GetExtClassName(),
"CIccTagXml")) {
1546 sprintf(line,
" <%s>\n", tagSig);
1550 if (!pTagXml->
ToXml(xml,
" ")) {
1551 printf(
"Unable to output tag with type %s\n",
icGetSigStr(buf, m_Array->GetType()));
1554 sprintf(line,
" </%s>\n", tagSig);
1558 xml += blanks +
"</TintArrayElement>\n";
1568 if (!nInputChannels || !nOutputChannels) {
1569 parseStr +=
"Invalid InputChannels or OutputChannels In TintArrayElement\n";
1572 m_nInputChannels = nInputChannels;
1573 m_nOutputChannels = nOutputChannels;
1575 for (pNode = pNode->children; pNode && pNode->type != XML_ELEMENT_NODE; pNode = pNode->next);
1581 std::string nodeName = (
icChar*) pNode->name;
1595 parseStr+=
"Invalid data type for Tint Array!\n";
1606 if (pXmlTag->
ParseXml(pNode->children, parseStr)) {
1613 parseStr +=
"Unable to Parse \"";
1616 parseStr += nodeName;
1617 parseStr +=
") Tint Tag\n";
1623 parseStr +=
"Invalid tag extension for \"";
1626 parseStr += nodeName;
1627 parseStr +=
") Tint Tag\n";
1634 parseStr +=
"Tint Array missing tint values\n";
1655 sprintf(line,
"<ToneMapFunction FunctionType=\"%d\"", m_nFunctionType);
1656 xml += blanks + line;
1659 sprintf(line,
" Reserved=\"%d\"", m_nReserved);
1663 sprintf(line,
" Reserved2=\"%d\"", m_nReserved2);
1670 xml += blanks +
"</ToneMapFunction>\n";
1681 parseStr +=
"Bad FunctionType in Tone Map Function\n";
1688 switch (m_nFunctionType) {
1694 parseStr +=
"Unsupported FunctionType value in Tone Map Function\n";
1703 if (args.
GetSize() < m_nParameters)
1710 if (m_nParameters) {
1726 char buf[128], line[128];
1727 sprintf(buf,
"<ToneMapElement InputChannels=\"%d\" OutputChannels=\"%d\"", NumInputChannels(), NumOutputChannels());
1728 xml += blanks + buf;
1731 sprintf(buf,
" Reserved=\"%u\"", m_nReserved);
1737 xml += blanks +
" <LuminanceCurve>\n";
1738 if (!
ToXmlCurve(xml, blanks +
" ", m_pLumCurve))
1740 xml += blanks +
" </LuminanceCurve>\n";
1744 xml += blanks +
" <ToneMapFunctions>\n";
1746 for (i = 0; i < NumOutputChannels(); i++) {
1747 if (m_pToneFuncs[i] && !strcmp(m_pToneFuncs[i]->GetClassName(),
"CIccXmlToneMapFunc")) {
1751 for (j = 0; j < i; j++) {
1752 if (m_pToneFuncs[i] == m_pToneFuncs[j])
1758 sprintf(line,
"<DuplicateFunction Index=\"%d\"/>\n", j);
1759 xml += blanks +
" ";
1762 else if (!pFunc->
ToXml(xml, blanks +
" "))
1768 xml += blanks +
" </ToneMapFunctions>\n";
1771 xml += blanks +
"</ToneMapElement>\n";
1781 if (!nInputChannels || !nOutputChannels || nInputChannels!=nOutputChannels+1) {
1782 parseStr +=
"Invalid InputChannels or OutputChannels In ToneMapElement\n";
1785 m_nInputChannels = nInputChannels;
1787 SetNumOutputChannels(nOutputChannels);
1789 if (!m_pToneFuncs) {
1790 parseStr +=
"Unable to allocate ToneMapFunctions\n";
1794 xmlNode* pSubNode =
icXmlFindNode(pNode->children,
"LuminanceCurve");
1798 for (pNode = pSubNode->children; pNode && pNode->type != XML_ELEMENT_NODE; pNode = pNode->next);
1801 parseStr +=
"Unable to parse Luminance Curve\n";
1806 parseStr +=
"Missing Luminance Curve";
1809 pSubNode =
icXmlFindNode(pNode->children,
"ToneMapFunctions");
1814 for (pNode = pSubNode->children, nIndex = 0;
1816 pNode = pNode->next) {
1817 if (pNode->type == XML_ELEMENT_NODE) {
1818 if (nIndex >= nOutputChannels) {
1819 parseStr +=
"Too many ToneFunctions";
1822 else if (!strcmp((
const char*)pNode->name,
"DuplicateFunction")) {
1826 int nCopyIndex = atoi(attr);
1827 if (nCopyIndex >= 0 && nCopyIndex < nIndex) {
1828 m_pToneFuncs[nIndex] = m_pToneFuncs[nCopyIndex];
1832 parseStr +=
"Invalid index for duplicate ToneMapFunction\n";
1837 parseStr +=
"Missing index for duplicate ToneMapFunction\n";
1841 else if (!strcmp((
const char*)pNode->name,
"ToneMapFunction")) {
1844 if (!pFunc->
ParseXml(pNode, parseStr)) {
1853 parseStr += std::string(
"Unknown Tone Map Function '") + (
const char*)pNode->name +
"'\n";
1858 if (nIndex < m_nOutputChannels) {
1859 parseStr +=
"Missing ToneMap Functions\n";
1873 sprintf(attrs,
" InputChannels=\"%d\" OutputChannels=\"%d\" Reserved=\"%u\"", NumInputChannels(), NumOutputChannels(), m_nReserved);
1876 sprintf(attrs,
" InputChannels=\"%d\" OutputChannels=\"%d\"", NumInputChannels(), NumOutputChannels());
1885 m_nOutputChannels = atoi(
icXmlAttrValue(pNode,
"OutputChannels"));
1887 if (!m_nInputChannels || !m_nOutputChannels) {
1888 parseStr +=
"Invalid InputChannels or OutputChannels In CLutElement\n";
1905 std::string reserved;
1908 sprintf(attrs,
" Reserved=\"%u\"", m_nReserved);
1913 sprintf(attrs,
" Reserved2=\"%u\"", m_nReserved2);
1917 sprintf(attrs,
" InputChannels=\"%d\" OutputChannels=\"%d\"%s StorageType=\"%d\"", NumInputChannels(), NumOutputChannels(), reserved.c_str(), m_storageType);
1928 m_nOutputChannels = atoi(
icXmlAttrValue(pNode,
"OutputChannels"));
1930 if (!m_nInputChannels || !m_nOutputChannels) {
1931 parseStr +=
"Invalid InputChannels or OutputChannels In ExtCLutElement\n";
1948 char buf[256], fix[256];
1950 sprintf(line,
"<BAcsElement InputChannels=\"%d\" OutputChannels=\"%d\" Signature=\"%s\"", NumInputChannels(), NumOutputChannels(),
1952 xml += blanks + line;
1955 sprintf(line,
" Reserved=\"%u\"", m_nReserved);
1959 if (m_pData && m_nDataSize) {
1966 xml += blanks +
"</BAcsElement>\n";
1979 m_nOutputChannels = atoi(
icXmlAttrValue(pNode,
"OutputChannels"));
1981 if (!m_nInputChannels || !m_nOutputChannels) {
1982 parseStr +=
"Invalid InputChannels or OutputChannels In BAcsElement\n";
1988 if (pNode->children && pNode->children->type == XML_TEXT_NODE && pNode->children->content) {
1992 if (!AllocData(nSize))
1994 icXmlGetHexData(m_pData, (
const char *)pNode->children->content, nSize);
2004 char buf[256], fix[256];
2006 sprintf(line,
"<EAcsElement InputChannels=\"%d\" OutputChannels=\"%d\" Signature=\"%s\"", NumInputChannels(), NumOutputChannels(),
2008 xml += blanks + line;
2011 sprintf(line,
" Reserved=\"%u\"", m_nReserved);
2015 if (m_pData && m_nDataSize) {
2020 xml += blanks +
"</EAcsElement>\n";
2033 m_nOutputChannels = atoi(
icXmlAttrValue(pNode,
"OutputChannels"));
2035 if (!m_nInputChannels || !m_nOutputChannels) {
2036 parseStr +=
"Invalid InputChannels or OutputChannels In EAcsElement\n";
2042 if (pNode->children && pNode->children->type == XML_TEXT_NODE && pNode->children->content) {
2046 if (!AllocData(nSize))
2048 icXmlGetHexData(m_pData, (
const char *)pNode->children->content, nSize);
2059 xml += blanks +
"<ColorAppearanceParams>\n";
2064 xml += blanks +
" <WhitePoint>\n";
2065 xml += blanks + line;
2066 xml += blanks +
" </WhitePoint>\n";
2069 xml += blanks + line;
2072 xml += blanks + line;
2075 xml += blanks + line;
2078 xml += blanks + line;
2081 xml += blanks + line;
2083 xml +=
"</ColorAppearanceParams>\n";
2092 parseStr +=
"Unable to find CAM Whitepoint\n";
2096 xmlNode *xyzNode =
icXmlFindNode(pChild->children,
"XYZNumber");
2099 parseStr +=
"Unable to find valid CAM WhitePoint XYZ\n";
2114 parseStr +=
"Invalid CAM WhitePoint XYZNumber\n";
2120 if (!pChild || !pChild->children || !pChild->children->content) {
2121 parseStr +=
"Invalid CAM Luminance\n";
2127 if (!pChild || !pChild->children || !pChild->children->content) {
2128 parseStr +=
"Invalid CAM Luminance\n";
2134 if (!pChild || !pChild->children || !pChild->children->content) {
2135 parseStr +=
"Invalid CAM ImpactSurround\n";
2141 if (!pChild || !pChild->children || !pChild->children->content) {
2142 parseStr +=
"Invalid CAM ChromaticInductionFactor\n";
2148 if (!pChild || !pChild->children || !pChild->children->content) {
2149 parseStr +=
"Invalid CAM AdaptationFactor\n";
2161 sprintf(line,
"<JabToXYZElement InputChannels=\"%d\" OutputChannels=\"%d\"" , NumInputChannels(), NumOutputChannels());
2162 xml += blanks + line;
2165 sprintf(line,
" Reserved=\"%u\"", m_nReserved);
2172 xml += blanks +
"</JabToXYZElement>\n";
2182 m_nOutputChannels = atoi(
icXmlAttrValue(pNode,
"OutputChannels"));
2184 if (m_nInputChannels!=3 || m_nOutputChannels!=3) {
2185 parseStr +=
"Invalid InputChannels or OutputChannels In JabToXYZElement\n";
2188 xmlNode *pChild =
icXmlFindNode(pNode->children,
"ColorAppearanceParams");
2201 parseStr +=
"Unable to find ColorAppearanceParams\n";
2212 sprintf(line,
"<XYZToJabElement InputChannels=\"%d\" OutputChannels=\"%d\"" , NumInputChannels(), NumOutputChannels());
2213 xml += blanks + line;
2216 sprintf(line,
" Reserved=\"%u\"", m_nReserved);
2223 xml += blanks +
"</XYZToJabElement>\n";
2233 m_nOutputChannels = atoi(
icXmlAttrValue(pNode,
"OutputChannels"));
2235 if (m_nInputChannels!=3 || m_nOutputChannels!=3) {
2236 parseStr +=
"Invalid InputChannels or OutputChannels In XYZToJabElement\n";
2239 xmlNode *pChild =
icXmlFindNode(pNode->children,
"ColorAppearanceParams");
2252 parseStr +=
"Unable to find ColorAppearanceParams\n";
2263 std::string blanks2 = blanks +
" ";
2265 sprintf(line,
"<CalculatorElement InputChannels=\"%d\" OutputChannels=\"%d\"", NumInputChannels(), NumOutputChannels());
2266 xml += blanks + line;
2269 sprintf(line,
" Reserved=\"%u\"", m_nReserved);
2276 if (m_SubElem && m_nSubElem) {
2277 xml += blanks2 +
"<SubElements>\n";
2278 for (i=0; i<(int)m_nSubElem; i++) {
2283 pMpe->
ToXml(xml, blanks2+
" ");
2293 xml += blanks2 +
"</SubElements>\n";
2299 xml += blanks2 +
"<MainFunction>\n";
2301 m_calcFunc->Describe(desc, 100, (
int)blanks2.size()+2);
2304 xml+= blanks2 +
"</MainFunction>\n";
2307 xml += blanks +
"</CalculatorElement>\n";
2313 if (bFirst && !((c >=
'A' && c <=
'Z') || (c >=
'a' && c <=
'z') || (c ==
'_')))
2315 else if (!((c >=
'A' && c <=
'Z') || (c >=
'a' && c <=
'z') || (c >=
'0' && c <=
'9') || (c ==
'_')))
2328 for (ptr =
szName; *ptr; ptr++) {
2329 if (!validNameChar(*ptr, ptr ==
szName))
2338 xmlNode *pChild, *pNext;
2343 for (pNext = pChild->children; pNext; pNext = pNext->next) {
2344 if (pNext->type == XML_ELEMENT_NODE) {
2345 if (!strcmp((
icChar*)pNext->name,
"Import")) {
2349 xmlNode *root_element = NULL;
2351 std::string look =
"*";
2355 if (strstr(importPath.c_str(), look.c_str())) {
2361 doc = xmlReadFile(file.c_str(), NULL, 0);
2364 parseStr +=
"Unable to import '";
2371 root_element = xmlDocGetRootElement(doc);
2372 if (strcmp((
icChar*)root_element->name,
"IccCalcImport")) {
2373 parseStr +=
"Invalid calc element import file '" + file +
"'\n";
2377 bool rv = ParseImport(root_element, importPath+file+
"*", parseStr);
2382 parseStr +=
"Missing import file specifier\n";
2387 parseStr +=
"Invalid import specifier\n";
2396 for (pNext = pChild->children; pNext; pNext = pNext->next) {
2397 if (pNext->type == XML_ELEMENT_NODE) {
2398 if (!strcmp((
icChar*)pNext->name,
"Declare")) {
2401 if (!validName(name.c_str())) {
2402 parseStr +=
"Invalid calc element variable name '" + name +
"'\n'";
2406 TempDeclVarMap::iterator v = m_declVarMap.find(name);
2407 if (v != m_declVarMap.end()) {
2408 parseStr +=
"Calc element variable '" + name +
"' was previously declared\n";
2416 if (offset && importPath !=
"*") {
2417 parseStr +=
"Position cannot be specified for imported variables";
2424 if (size < 1) size = 1;
2427 if (pNext->children && pNext->children->content) {
2433 std::string member = parse.
GetName();
2434 if (!validName(member.c_str())) {
2435 parseStr +=
"Invalid member name '" + member +
"' for calc element variable '" + name +
"'\n";
2438 size = 0; extra = 0;
2450 m_declVarMap[name] = var;
2453 parseStr +=
"Missing calc element variable name definition\n";
2458 parseStr +=
"Invalid calc element variable declaration\n";
2467 for (pNext = pChild->children; pNext; pNext = pNext->next) {
2468 if (pNext->type == XML_ELEMENT_NODE) {
2469 if (!strcmp((
icChar*)pNext->name,
"Macro")) {
2472 if (!validName(name.c_str())) {
2473 parseStr +=
"Invalid Macro name '" + name +
"'\n'";
2476 if (!pNext->children || !pNext->children->content || !pNext->children->content[0]) {
2477 parseStr +=
"Missing content for macro '" + name +
"'\n'";
2480 MacroMap::iterator m = m_macroMap.find(name);
2481 if (m != m_macroMap.end()) {
2482 if (!strcmp(m->second.c_str(), (
icChar*)pNext->children->content))
2484 parseStr +=
"Calc Element macro '" + name +
"' was previously defined differently\n";
2487 m_macroMap[name] = (
icChar*)(pNext->children->content);
2498 std::string member = parse.
GetName();
2499 if (!validName(member.c_str())) {
2500 parseStr +=
"Invalid local name '" + member +
"' for calc element macro '" + name +
"'\n";
2503 size = 0; extra = 0;
2515 m_macroLocalMap[name] = var;
2519 parseStr +=
"Missing macro name\n";
2524 parseStr +=
"Invalid macro declaration\n";
2533 for (pNext = pChild->children; pNext; pNext = pNext->next) {
2534 if (pNext->type == XML_ELEMENT_NODE) {
2539 if (!validName(name.c_str())) {
2540 parseStr +=
"Invalid SubElement name '" + name +
"'\n'";
2545 if (importPath !=
"*") {
2546 parseStr +=
"Imported Calc SubElments must be named.";
2551 MpePtrMap::iterator se = m_mpeMap.find(name);
2552 if (se != m_mpeMap.end()) {
2553 parseStr +=
"Duplicate declaration of SubElement '" + name +
"'\n";
2561 parseStr += std::string(
"Unknown Sub-Element Type (") + (
const icChar*)pNext->name +
")\n";
2565 if (!strcmp(pMpe->
GetClassName(),
"CIccMpeXmlCalculator")) {
2577 if (pXmlMpe->
ParseXml(pNext, parseStr)) {
2583 m_mpeList.push_back(
CIccMpePtr(pMpe, m_nNextMpe));
2592 sprintf(str,
" starting on line %d", pNext->line);
2593 parseStr += std::string(
"Unable to parse element of type ") + pMpe->
GetClassName() + str +
"\n";
2599 parseStr += std::string(
"Element ") + pMpe->
GetClassName() +
"isn't of type CIccMpeXml\n";
2605 parseStr += std::string(
"Element ") + pMpe->
GetClassName() +
"isn't of type CIccMpeXml\n";
2618 for (ptr = strstr(szMacroText,
"call{"); ptr; ptr = strstr(ptr,
"call{")) {
2623 MacroMap::const_iterator m = m_macroMap.find(name);
2624 if (m == m_macroMap.end()) {
2625 parseStr +=
"Call to undefined macro '" + name +
"'\n";
2628 std::string sm =
"*";
2630 if (strstr(macroStack.c_str(), sm.c_str())) {
2631 parseStr +=
"Macro recursion detected in call to '" + name +
"'\n";
2634 if (!ValidMacroCalls(m->second.c_str(), macroStack + name +
"*", parseStr)) {
2644 MacroMap::const_iterator m;
2646 for (m = m_macroMap.begin(); m != m_macroMap.end(); m++) {
2647 if (!ValidMacroCalls(m->second.c_str(),
"*", parseStr)) {
2659 std::string token = parse.
GetLast();
2660 const char *tok = token.c_str();
2661 if (!strncmp(tok,
"call{", 5) ||
2663 std::string nameiter;
2667 nameiter = token.substr(1);
2672 for (ptr = nameiter.c_str(); *ptr && *ptr !=
'[' && *ptr !=
'('; ptr++) name += *ptr;
2682 MacroMap::iterator m = m_macroMap.find(name.c_str());
2683 if (m != m_macroMap.end()) {
2685 TempDeclVarMap::iterator locals = m_macroLocalMap.find(macroName);
2686 if (locals != m_macroLocalMap.end()) {
2687 nLocalsSize = locals->second.m_size;
2691 for (i = 0; i < iter; i++) {
2692 Flatten(flatStr, name, m->second.c_str(), parseStr, nLocalsOffset+nLocalsSize);
2696 parseStr +=
"Call to undefined macro '" + name +
"'\n";
2700 else if (!strncmp(tok,
"in{", 3) ||
2701 !strncmp(tok,
"out{", 4)) {
2702 std::string op = parse.
GetName();
2704 std::string refroot;
2705 for (
const char *ptr = ref.c_str(); *ptr && *ptr !=
',' && *ptr !=
'(' && *ptr !=
'['; ptr++) refroot += *ptr;
2711 nChan = m_nInputChannels;
2714 pMap = &m_outputMap;
2715 nChan = m_nOutputChannels;
2718 ChanVarMap::iterator ci = pMap->find(refroot);
2719 if (ci == pMap->end()) {
2720 parseStr +=
"Invalid '" + op +
"' operation channel reference '" + refroot +
"'\n";
2723 if (refroot != ref) {
2724 std::string select = ref.substr(refroot.size());
2728 if (select[0] ==
'[' || select[1] ==
'(') {
2730 offset = atoi(select.c_str() + 1);
2731 for (ptr = select.c_str() + 1; *ptr && *ptr !=
')' && *ptr !=
']'; ptr++);
2736 size = atoi(select.c_str() + 1);
2738 if (size < 0 || offset<0 || ci->second.first + offset + size > m_nInputChannels) {
2739 parseStr +=
"Invalid '" + op +
"' operation channel offset or size '" + refroot +
"'\n";
2743 sprintf(index,
"(%d,%d)", ci->second.first+offset, size);
2744 flatStr += op + index +
" ";
2746 else if (ci->second.second>1) {
2748 sprintf(index,
"(%d,%d)", ci->second.first, ci->second.second);
2749 flatStr += op + index +
" ";
2753 sprintf(index,
"(%d)", ci->second.first);
2754 flatStr += op + index +
" ";
2757 else if (!strncmp(tok,
"tget{", 5) ||
2758 !strncmp(tok,
"tput{", 5) ||
2759 !strncmp(tok,
"tsav{", 5)) {
2760 std::string op = parse.
GetName();
2762 std::string refroot;
2763 for (
const char *ptr = ref.c_str(); *ptr && *ptr !=
'[' && *ptr !=
'('; ptr++) refroot += *ptr;
2765 if (macroName.size() && refroot.size() && refroot[0] ==
'@') {
2766 std::string localName = refroot.substr(1);
2767 TempDeclVarMap::iterator locals = m_macroLocalMap.find(macroName);
2768 if (locals == m_macroLocalMap.end()) {
2769 parseStr +=
"Reference to undeclared local variable '" + localName +
"' in macro '" + macroName +
"'\n";
2773 unsigned long nLocalOffset = 0;
2774 unsigned long nLocalSize = 0;
2775 TempVarList::iterator m = locals->second.m_members.begin();
2776 for (; m != locals->second.m_members.end(); m++) {
2777 if (localName == m->m_name) {
2778 nLocalOffset = m->m_pos;
2779 nLocalSize = m->m_size;
2783 if (m == locals->second.m_members.end()) {
2784 parseStr +=
"Reference to undeclared local variable '" + localName +
"' in macro '" + macroName +
"'\n";
2789 if (ref != refroot) {
2793 p2.
GetIndex(_voffset, _vsize, 0, 1);
2799 vsize = (int)nLocalSize;
2802 if (voffset + vsize > (
int)nLocalSize) {
2803 parseStr +=
"Out of bounds indexing of local '" + refroot +
"' in macro '" + macroName +
"'\n";
2807 if (nLocalsOffset + nLocalOffset + voffset + vsize > 65536) {
2808 parseStr +=
"Temporary variable addressing out of bounds\n";
2813 sprintf(idx,
"[%lu]", nLocalsOffset + nLocalOffset + voffset);
2816 sprintf(idx,
"[%lu,%d]", nLocalsOffset + nLocalOffset + voffset, vsize);
2819 flatStr += op.substr(1);
2824 TempVarMap::iterator var = m_varMap.find(refroot);
2825 if (var == m_varMap.end()) {
2827 for (
const char *ptr = refroot.c_str(); *ptr && *ptr !=
'.'; ptr++) root += *ptr;
2829 TempVarMap::iterator rootVar = m_varMap.find(root);
2830 if (refroot != root && rootVar == m_varMap.end()) {
2831 parseStr +=
"Reference to undeclared variable '" + ref +
"'\n";
2835 TempDeclVarMap::iterator decl = m_declVarMap.find(root);
2836 if (decl == m_declVarMap.end()) {
2837 parseStr +=
"Reference to undeclared variable '" + ref +
"'\n";
2841 if (decl->second.m_pos < 0) {
2842 m_varMap[root] =
CIccTempVar(root, m_nNextVar, decl->second.m_size);
2843 decl->second.m_pos = m_nNextVar;
2845 if (strchr(refroot.c_str(),
'.')) {
2846 TempVarList::iterator m = decl->second.m_members.begin();
2847 for (; m != decl->second.m_members.end(); m++) {
2848 std::string vm = root +
"." + m->m_name;
2849 m_varMap[vm] =
CIccTempVar(vm, m_nNextVar + m->m_pos, m->m_size);
2853 if (m_nNextVar + decl->second.m_size > 65536) {
2854 parseStr +=
"Temporary variable addressing out of bounds\n";
2857 m_nNextVar += decl->second.m_size;
2860 m_varMap[root] =
CIccTempVar(root, decl->second.m_pos, decl->second.m_size);
2862 if (strchr(refroot.c_str(),
'.')) {
2863 TempVarList::iterator m = decl->second.m_members.begin();
2864 for (; m != decl->second.m_members.end(); m++) {
2865 std::string vm = root +
"." + m->m_name;
2866 m_varMap[vm] =
CIccTempVar(vm, decl->second.m_pos + m->m_pos, m->m_size);
2869 if (decl->second.m_pos + decl->second.m_size > 65536) {
2870 parseStr +=
"Temporary variable addressing out of bounds\n";
2875 var = m_varMap.find(refroot);
2876 if (var == m_varMap.end()) {
2877 parseStr +=
"Reference to undeclared variable '" + refroot +
"'\n";
2883 if (ref != refroot) {
2887 p2.
GetIndex(_voffset, _vsize, 0, 1);
2893 vsize = var->second.m_size;
2896 if (voffset + vsize > var->second.m_size) {
2897 parseStr +=
"Out of bounds indexing of '" + refroot +
"'\n";
2900 if (var->second.m_pos + voffset + vsize > 65536) {
2901 parseStr +=
"Temporary variable addressing out of bounds\n";
2906 sprintf(idx,
"[%d]", var->second.m_pos + voffset);
2909 sprintf(idx,
"[%d,%d]", var->second.m_pos + voffset, vsize);
2911 flatStr += op + idx +
" ";
2914 else if (!strncmp(tok,
"elem{", 5) ||
2915 !strncmp(tok,
"curv{", 5) ||
2916 !strncmp(tok,
"clut{", 5) ||
2917 !strncmp(tok,
"mtx{", 4) ||
2918 !strncmp(tok,
"fJab{", 5) ||
2919 !strncmp(tok,
"tJab{", 5) ||
2920 !strncmp(tok,
"calc{", 5) ||
2921 !strncmp(tok,
"tint{", 5)) {
2922 std::string op = parse.
GetName();
2924 MpePtrMap::iterator e = m_mpeMap.find(ref);
2925 if (e == m_mpeMap.end()) {
2926 parseStr +=
"Unknown sub element reference to " + token +
"\n";
2929 if (e->second.m_nIndex<0) {
2930 if (e->second.m_ptr) {
2931 m_mpeList.push_back(
CIccMpePtr(e->second.m_ptr, m_nNextMpe));
2932 e->second.m_ptr = NULL;
2933 e->second.m_nIndex = m_nNextMpe;
2937 parseStr +=
"Invalid sub-element reference: " + token +
"\n";
2942 sprintf(idx,
"(%d)", e->second.m_nIndex);
2943 flatStr += op + idx +
" ";
2960 std::string token = parse.
GetLast();
2961 const char *tok = token.c_str();
2963 if (!strncmp(tok,
"lget[", 5) ||
2964 !strncmp(tok,
"lput[", 5) ||
2965 !strncmp(tok,
"lsav[", 5)) {
2966 std::string op = parse.
GetName();
2971 p2.
GetIndex(_voffset, _vsize, 0, 1);
2972 voffset = _voffset + nLocalsOffset;
2975 if (voffset + vsize > 65535) {
2976 parseStr +=
"Local variable out of bounds - too many variables.\n";
2982 sprintf(idx,
"[%d]", voffset);
2985 sprintf(idx,
"[%d,%d]", voffset, vsize);
2988 func += op.substr(1);
3003 m_declVarMap.clear();
3007 MpePtrList::iterator ml;
3008 for (ml = m_mpeList.begin(); ml != m_mpeList.end(); ml++) {
3014 MpePtrMap::iterator mm;
3015 for (mm = m_mpeMap.begin(); mm != m_mpeMap.end(); mm++) {
3016 if (mm->second.m_ptr)
3017 delete mm->second.m_ptr;
3037 for (i = 0, ptr = szNames; *ptr && i < nChannels; ptr++) {
3038 bool bFirst = name.empty();
3043 chanMap[name] = isp;
3049 else if (*ptr ==
'[' || *ptr ==
'(') {
3050 size = atoi(ptr + 1);
3051 if (size<0 || i + size>nChannels)
3054 for (; *ptr && *ptr !=
']' && *ptr !=
')'; ptr++);
3058 else if (validNameChar(*ptr, bFirst)) {
3066 if (!name.empty() && i < nChannels) {
3069 chanMap[name] = isp;
3084 if (!ParseChanMap(m_inputMap,
icXmlAttrValue(pNode,
"InputNames"), m_nInputChannels)) {
3085 parseStr +=
"Invalid name for InputChannels";
3089 if (!ParseChanMap(m_outputMap,
icXmlAttrValue(pNode,
"OutputNames"), m_nOutputChannels)) {
3090 parseStr +=
"Invalid name for InputChannels";
3094 if (!ParseImport(pNode,
"*", parseStr))
3097 if (!ValidateMacroCalls(parseStr)) {
3102 if (pChild && pNode->children && pChild->children->content) {
3103 char *content = (
char*)pChild->children->content;
3104 std::string flatFunc;
3107 TempDeclVarMap::iterator declVar;
3108 for (declVar = m_declVarMap.begin(); declVar != m_declVarMap.end(); declVar++) {
3109 if (declVar->second.m_pos >= 0) {
3110 int next = declVar->second.m_pos + declVar->second.m_size;
3111 if (next > m_nNextVar)
3116 if (!Flatten(flatFunc,
"", content, parseStr, 0)) {
3120 if (m_macroLocalMap.size()) {
3121 std::string localFunc;
3122 if (!UpdateLocals(localFunc, flatFunc, parseStr, m_nNextVar)) {
3125 flatFunc = localFunc;
3129 MpePtrList::iterator m;
3130 for (m = m_mpeList.begin(), n = 0; m != m_mpeList.end(); m++, n++) {
3131 this->SetSubElem(n, m->m_ptr);
3136 FILE *ff = fopen(
"flatfunc.txt",
"wb");
3137 fwrite(flatFunc.c_str(), flatFunc.size(), 1, ff);
3144 int len =
icIntMin(64, (
int)strlen(flatFunc.c_str()));
3145 strncpy(buf, flatFunc.c_str(), len);
3150 parseStr +=
"Syntax Error occurred while parsing Main Calculator Function from \"";
3153 parseStr +=
"Invalid Operation found while parsing Main Calculator Function from \"";
3156 parseStr +=
"Stack underflow detected while parsing Main Calculator Function from \"";
3159 parseStr +=
"Invalid Channel detected while parsing Main Calculator Function from \"";
3162 parseStr +=
"Unable to parse Main Calculator Function from \"";
3178 std::string reserved;
3180 xml += blanks +
"<EmissionCLutElement";
3183 sprintf(buf,
" Reserved=\"%u\"", m_nReserved);
3187 sprintf(buf,
" InputChannels=\"%d\" OutputChannels=\"%d\" Flags=\"%d\" StorageType=\"%d\">\n", NumInputChannels(), NumOutputChannels(), m_flags, m_nStorageType);
3191 xml += blanks + buf;
3196 xml += blanks +
" <WhiteData>\n";
3198 xml += blanks +
" ";
3199 for (i=0; i<(int)m_Range.steps; i++) {
3205 xml += blanks +
" </WhiteData>\n";
3211 xml += blanks +
"</EmissionCLutElement>\n";
3221 m_nOutputChannels = atoi(
icXmlAttrValue(pNode,
"OutputChannels"));
3224 if (!m_nInputChannels || !m_nOutputChannels) {
3225 parseStr +=
"Invalid InputChannels or OutputChannels In CLutElement\n";
3237 if (dStart >= dEnd ||!nSteps) {
3238 parseStr +=
"Invalid Spectral Range\n";
3243 m_Range.steps = nSteps;
3246 parseStr +=
"Missing Spectral Range\n";
3255 parseStr +=
"White buffer memory error\n";
3266 parseStr +=
"Missing White Data";
3275 delete m_pApplyCLUT;
3276 m_pApplyCLUT = NULL;
3291 std::string reserved;
3293 xml += blanks +
"<ReflectanceCLutElem";
3296 sprintf(buf,
" Reserved=\"%u\"", m_nReserved);
3300 sprintf(buf,
" InputChannels=\"%d\" OutputChannels=\"%d\" Flags=\"%d\">\n", NumInputChannels(), NumOutputChannels(), m_flags);
3309 xml += blanks +
" <WhiteData>\n";
3311 xml += blanks +
" ";
3312 for (i=0; i<(int)m_Range.steps; i++) {
3318 xml += blanks +
" </WhiteData>\n";
3324 xml += blanks +
"</ReflectanceCLutElem>\n";
3334 m_nOutputChannels = atoi(
icXmlAttrValue(pNode,
"OutputChannels"));
3337 if (!m_nInputChannels || !m_nOutputChannels) {
3338 parseStr +=
"Invalid InputChannels or OutputChannels In CLutElement\n";
3350 if (dStart >= dEnd ||!nSteps) {
3351 parseStr +=
"Invalid Spectral Range\n";
3356 m_Range.steps = nSteps;
3359 parseStr +=
"Missing Spectral Range\n";
3368 parseStr +=
"White buffer memory error\n";
3379 parseStr +=
"Missing WhiteData";
3388 delete m_pApplyCLUT;
3389 m_pApplyCLUT = NULL;
3407 if (!nInputChannels || !nOutputChannels) {
3408 parseStr +=
"Invalid InputChannels or OutputChannels In EmissionObserverElement\n";
3420 if (dStart >= dEnd || nSteps != nInputChannels) {
3421 parseStr +=
"Invalid Spectral Range\n";
3426 m_Range.steps = nSteps;
3429 SetSize(nInputChannels, nOutputChannels, m_Range);
3431 parseStr +=
"Unable to SetSize\n";
3442 parseStr +=
"Missing White Data";
3451 sprintf(buf,
"<EmissionObserverElement InputChannels=\"%d\" OutputChannels=\"%d\" Flags=\"%d\"", NumInputChannels(), NumOutputChannels(), m_flags);
3452 xml += blanks + buf;
3455 sprintf(buf,
" Reserved=\"%u\"", m_nReserved);
3466 xml += blanks +
" <WhiteData>\n";
3468 xml += blanks +
" ";
3469 for (i=0; i<(int)m_Range.steps; i++) {
3475 xml += blanks +
" </WhiteData>\n";
3478 xml += blanks +
"</EmissionObserverElement>\n";
3489 if (!nInputChannels || !nOutputChannels) {
3490 parseStr +=
"Invalid InputChannels or OutputChannels In ReflectanceObserverElement\n";
3502 if (dStart >= dEnd || nSteps != nInputChannels) {
3503 parseStr +=
"Invalid Spectral Range\n";
3508 m_Range.steps = nSteps;
3511 SetSize(nInputChannels, nOutputChannels, m_Range);
3513 parseStr +=
"Unable to SetSize\n";
3524 parseStr +=
"Missing White Data";
3533 sprintf(buf,
"<ReflectanceObserverElement InputChannels=\"%d\" OutputChannels=\"%d\" Flags=\"%d\"", NumInputChannels(), NumOutputChannels(), m_flags);
3534 xml += blanks + buf;
3537 sprintf(buf,
" Reserved=\"%u\"", m_nReserved);
3548 xml += blanks +
" <WhiteData>\n";
3550 xml += blanks +
" ";
3551 for (i=0; i<(int)m_Range.steps; i++) {
3557 xml += blanks +
" </WhiteData>\n";
3560 xml += blanks +
"</ReflectanceObserverElement>\n";
3565#ifdef USEREFICCMAXNAMESPACE
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
#define ICFLOATSFX
String formating macros need to match precision of icFloatNumber If precision is double change the "f...
CIccIO * IccOpenFileIO(const icChar *szFilename, const char *szAttr)
@ icFuncParseStackUnderflow
@ icFuncParseInvalidOperation
@ icFuncParseInvalidChannel
static icCurveSetCurvePtr ParseXmlCurve(xmlNode *pNode, std::string parseStr)
static char * icSegPos(char *buf, icFloatNumber pos)
static bool icXmlParseColorAppearanceParams(xmlNode *pNode, std::string &parseStr, CIccCamConverter *pCam)
static bool icXmlDumpColorAppearanceParams(std::string &xml, std::string blanks, CIccCamConverter *pCam)
CIccCLUT * icCLutFromXml(xmlNode *pNode, int nIn, int nOut, icConvertType nType, std::string &parseStr)
static bool ToXmlCurve(std::string &xml, std::string blanks, icCurveSetCurvePtr pCurve)
icFloatNumber icGetSegPos(const char *str)
std::pair< int, int > IndexSizePair
std::map< std::string, IndexSizePair > ChanVarMap
IIccMatrixInverter * IccGetDefaultMatrixInverter()
Name: IccGetDefaultMatrixInverter()
icFloat16Number icFtoF16(icFloat32Number num)
icUInt32Number icIntMin(icUInt32Number v1, icUInt32Number v2)
icUInt32Number icGetSigVal(const icChar *pBuf)
icFloatNumber icF16toF(icFloat16Number num)
const icChar * icGetSigStr(icChar *pBuf, icUInt32Number nSig)
icUInt32Number icXmlGetHexDataSize(const char *szText)
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
xmlNode * icXmlFindNode(xmlNode *pNode, const char *szNodeName)
icUInt32Number icXmlGetHexData(void *pBuf, const char *szText, icUInt32Number nBufSize)
icTagTypeSignature icGetTypeNameTagSig(const icChar *szTagType)
const icChar * icGetTagSigTypeName(icTagTypeSignature tagTypeSig)
icUInt32Number icXmlDumpHexData(std::string &xml, std::string blanks, void *pBuf, icUInt32Number nBufSize)
bool icCLUTDataToXml(std::string &xml, CIccCLUT *pCLUT, icConvertType nType, std::string blanks, bool bSaveGridPoints)
const char * icFixXml(std::string &buf, const char *szStr)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
icSignature icXmlStrToSig(const char *szStr)
bool icCLUTToXml(std::string &xml, CIccCLUT *pCLUT, icConvertType nType, std::string blanks, bool bSaveGridPoints, const char *szExtraAttrs, const char *szName)
#define icXmlStrCmp(x, y)
unsigned int icUInt32Number
void SetParameter_Nc(icFloatNumber Nc)
void SetParameter_La(icFloatNumber La)
void SetParameter_F(icFloatNumber F)
void GetParameter_WhitePoint(icFloatNumber *whitePoint)
void SetParameter_C(icFloatNumber c)
icFloatNumber GetParameter_C()
icFloatNumber GetParameter_Nc()
icFloatNumber GetParameter_Yb()
icFloatNumber GetParameter_F()
void SetParameter_Yb(icFloatNumber YB)
icFloatNumber GetParameter_La()
void SetParameter_WhitePoint(icFloatNumber *whitePoint)
virtual icCurveSegSignature GetType() const =0
Class: CIccCurveSetCurve.
virtual icCurveElemSignature GetType() const =0
bool GetIndex(icUInt16Number &v1, icUInt16Number &v2, icUInt16Number initV1=0, icUInt16Number initV2=0)
std::string GetName() const
std::string GetReference() const
bool GetNext(bool bForceNoRefs=false)
icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1)
virtual icInt32Number GetLength()
virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1)
icInt32Number Read16(void *pBuf16, icInt32Number nNum=1)
const icChar * GetTagTypeSigName(icTagTypeSignature sig)
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
bool ParseChanMap(ChanVarMap &chanMap, const char *szNames, int nChannels)
bool UpdateLocals(std::string &func, std::string szFunc, std::string &parseStr, int nLocalsOffset)
bool Flatten(std::string &flatStr, std::string macroName, const char *szFunc, std::string &parseStr, icUInt32Number nLocalsOffset=0)
bool ParseImport(xmlNode *pNode, std::string importPath, std::string &parseStr)
bool ValidMacroCalls(const char *szMacroText, std::string macroStack, std::string &parseStr) const
bool ValidateMacroCalls(std::string &parseStr) const
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
static bool validNameChar(char c, bool bFirst)
static bool validName(const char *saName)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)=0
virtual bool ToXml(std::string &xml, std::string blanks="")=0
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
Class: CIccMultiProcessElement.
virtual IIccExtensionMpe * GetExtension()
virtual const icChar * GetClassName() const =0
icUInt32Number m_nReserved
Class: CIccSampledCalculatorCurve.
bool ToXml(std::string &xml, std::string blanks)
bool ParseXml(xmlNode *pNode, std::string &parseStr)
CIccSampledCalculatorCurveXml(icFloatNumber first=0, icFloatNumber last=0)
Class: CIccSampledCurveSegment.
bool ParseXml(xmlNode *pNode, std::string &parseStr)
CIccSampledCurveSegmentXml(icFloatNumber start, icFloatNumber end)
bool ToXml(std::string &xml, std::string blanks)
bool ParseXml(xmlNode *pNode, std::string &parseStr)
bool ToXml(std::string &xml, std::string blanks)
CIccSinglSampledeCurveXml(icFloatNumber first=0, icFloatNumber last=0)
bool ParseXml(xmlNode *pNode, std::string &parseStr)
bool ToXml(std::string &xml, std::string blanks)
Class: CIccSingleSampledCurve.
icUInt32Number m_nReserved
static CIccTag * Create(icTagTypeSignature sig)
Name: CIccTag::Create.
virtual bool IsNumArrayType() const
virtual IIccExtensionTag * GetExtension()
virtual bool ToXml(std::string &xml, std::string blanks="")=0
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)=0
static CIccMultiProcessElement * CreateElement(const icChar *szElementNodeName)
static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode)
bool ParseTextArrayNum(const char *szText, icUInt32Number num, std::string &parseStr)
static bool DumpArray(std::string &xml, std::string blanks, T *buf, icUInt32Number nBufSize, icConvertType nType, icUInt8Number nColumns)
virtual CIccToneMapFunc * NewCopy()
virtual bool ParseXml(xmlNode *pNode, std::string &parseStr)
virtual bool ToXml(std::string &xml, std::string blanks="")
virtual const char * GetExtClassName()=0
virtual const char * GetExtClassName() const =0
Structure: IIccMatrixInverter.
virtual bool Invert(icFloatNumber *dMatrix, icUInt16Number nRows, icUInt16Number nCols)=0
Member Function: Invert.