98 size_t sizeSrc = strlen(szStr);
105 if (
m_str[0]==0xfeff) {
107 for (i=1;
m_str[i]; i++)
226 sizeSrc = strlen(szStr);
238 if (
m_str[0]==0xfeff) {
240 for (i=1;
m_str[i]; i++)
269 for (i=0; i<
m_len; i++) {
270 buf += (wchar_t)
m_str[i];
276const char *
icFixXml(std::string &buf,
const char *szStr)
305const char *
icFixXml(
char *szDest,
const char *szStr)
307 char *m_ptr = szDest;
312 strcpy(m_ptr,
"'");
316 strcpy(m_ptr,
"&");
320 strcpy(m_ptr,
""");
324 strcpy(m_ptr,
"<");
328 strcpy(m_ptr,
">");
350 char *szBuf = (
char *)malloc(n+1);
351 char *szDest = szBuf;
375 size_t len = strlen(szSrc)+1;
376 wchar_t *szUnicodeBuf = (
wchar_t*)malloc(len*
sizeof(
icUInt16Number)*2);
377 char *szBuf = (
char*)malloc(len*2);
381 n=MultiByteToWideChar(CP_ACP, 0, szSrc, (
int)len-1, szUnicodeBuf, (
int)len*2);
382 szUnicodeBuf[n] =
'\0';
384 n = WideCharToMultiByte(CP_UTF8, 0, (
const wchar_t*)szUnicodeBuf, (
int)n, szBuf, (
int)len*2, 0, NULL);
400 size_t len = strlen(szSrc)+1;
401 wchar_t *szUnicodeBuf = (
wchar_t*)malloc(len*
sizeof(
icUInt16Number)*2);
402 char *szBuf = (
char*)malloc(len*2);
406 n=MultiByteToWideChar(CP_UTF8, 0, szSrc, (
int)len, szUnicodeBuf, (
int)len*2);
407 szUnicodeBuf[n] =
'\0';
409 n = WideCharToMultiByte(CP_ACP, 0, (
const wchar_t*)szUnicodeBuf, (
int)n, szBuf, (
int)len*2,
"?", NULL);
459 sprintf(buf,
" %13.8f", pData[i]);
486 bool bSaveGridPoints)
489 int nStartType = nType;
494 if (bSaveGridPoints) {
495 xml += blanks +
" <GridPoints>";
500 sprintf(buf,
" %d", pCLUT->
GridPoint(i));
505 xml +=
"</GridPoints>\n";
511 if (nPixelsPerRow == 0) {
512 printf(
"\nError! - CLUT Table not found.\n");
518 xml += blanks +
" <TableData";
521 sprintf(buf,
" Precision=\"1\"");
531 xml += blanks +
" </TableData>\n";
538 bool bSaveGridPoints,
const char *szExtraAttrs,
const char *
szName)
541 xml += blanks +
"<" +
szName;
543 if (!bSaveGridPoints) {
544 sprintf(buf,
" GridGranularity=\"%d\"", pCLUT->
GridPoint(0));
548 if (szExtraAttrs && *szExtraAttrs) {
555 xml += blanks +
"</" +
szName +
">\n";
562 sscanf((
const char*)szStr,
"%f", &f);
574 if (attr && attr->children && attr->children->type == XML_TEXT_NODE && attr->children->content)
575 return (
const char*)attr->children->content;
591 if (!pNode || !pNode->children || !pNode->children->content)
594 return icGetSigVal((
const char*)pNode->children->content);
599 if (c>=
'0' && c<=
'9')
601 if (c>=
'A' && c<=
'F')
603 if (c>=
'a' && c<=
'f')
611 unsigned char *pDest = (
unsigned char*)pBuf;
614 while(*szText && rv<nBufSize) {
617 if (c1>=0 && c2>=0) {
637 if (c1>=0 && c2>=0) {
654 for (i=0; i<nBufSize; i++, m_ptr++) {
660 sprintf(buf,
"%02x", *m_ptr);
671 if (!pNode)
return NULL;
675 for (attr = pNode->properties; attr; attr = attr->next) {
676 if (attr->type != XML_ATTRIBUTE_NODE)
689 if (!pNode)
return NULL;
691 for (; pNode; pNode = pNode->next) {
692 if (pNode->type != XML_ELEMENT_NODE)
706 for (; pNode; pNode = pNode->next) {
707 if (pNode->type == XML_ELEMENT_NODE &&
718 for (; pNode; pNode = pNode->next) {
719 if (pNode->type == XML_ELEMENT_NODE &&
730 for (; pNode; pNode = pNode->next) {
731 if (pNode->type == XML_ELEMENT_NODE &&
739template <
class T, icTagTypeSignature Tsig>
746template <
class T, icTagTypeSignature Tsig>
754template <
class T, icTagTypeSignature Tsig>
757 char scanType[2] = {0};
766 return ParseArray(m_pBuf, m_nSize, pNode);
769 for ( ;pNode && pNode->type!= XML_TEXT_NODE; pNode=pNode->next);
771 if (!pNode || !pNode->content)
774 n = ParseTextCount((
const char*)pNode->content);
776 if (!n || !SetSize(n))
779 return ParseArray(m_pBuf, m_nSize, pNode);
782template <
class T, icTagTypeSignature Tsig>
791 return ParseText(m_pBuf, m_nSize, szText)==m_nSize;
797template <
class T, icTagTypeSignature Tsig>
800 if (pNode->children && pNode->children->type==XML_TEXT_NODE) {
801 return ParseTextArray((
const char*)pNode->children->content);
806template <
class T, icTagTypeSignature Tsig>
813 return ParseText(m_pBuf, m_nSize, szText)==m_nSize;
819template <
class T, icTagTypeSignature Tsig>
825 if (!nColumns) nColumns = 1;
828 for (i=0; i<nBufSize; i++) {
898 if (i%nColumns == nColumns-1) {
914 if ((c>=
'0' && c<=
'9') || c==
'.' || c==
'+' || c==
'-' || c==
'e' || c ==
'n' || c ==
'a')
921template <
class T, icTagTypeSignature Tsig>
935 else if (bInNum && !strncmp(szText,
"#QNAN", 5)) {
940 else if (!isspace(*szText) && i <= num ){
942 sprintf(line,
"Data '%c' in position %d is not a number. ", *szText, i);
960template <
class T, icTagTypeSignature Tsig>
972 else if (bInNum && !strncmp(szText,
"#QNAN", 5)) {
988template <
class T, icTagTypeSignature Tsig>
995 while (*szText && n<nSize) {
1003 if (b+2<
sizeof(num))
1008 if (!strncmp(num,
"nan", 3) || !strncmp(num,
"-nan", 4)) {
1009 pBuf[n] = (T)
nanf(num);
1012 pBuf[n] = (T)atof(num);
1021 if (!strncmp(num,
"nan", 3) || !strncmp(num,
"-nan", 4)) {
1022 pBuf[n] = (T)
nanf(num);
1025 pBuf[n] = (T)atof(num);
1033template <
class T, icTagTypeSignature Tsig>
1041 if (pNode->type!=XML_TEXT_NODE || !pNode->content)
1044 n = ParseTextCount((
const char*)pNode->content);
1048 ParseText(pBuf, n, (
const char*)pNode->content);
1055 for (i=0; i<nSize && pNode; pNode = pNode->next) {
1056 if (pNode->type == XML_ELEMENT_NODE &&
1059 pNode->children->content) {
1061 sscanf((
const char *)(pNode->children->content),
"%f", &f);
1072 if (pNode->type!=XML_TEXT_NODE || !pNode->content)
1075 n = ParseTextCount((
const char *)pNode->content);
1079 n = ParseText(pBuf, n, (
const char *)pNode->content);
1086 for (i=0; i<nSize && pNode; pNode = pNode->next) {
1087 if (pNode->type == XML_ELEMENT_NODE &&
1090 pNode->children->content) {
1091 pBuf[i] = (T)atol((
const char *)(pNode->children->content));
1101template <
class T, icTagTypeSignature Tsig>
1107 m_pBuf = (T*)malloc(nSize *
sizeof(T));
1129 if (!strcmp(szRenderingIntent,
"Perceptual"))
1131 else if (!strcmp(szRenderingIntent,
"Media-relative colorimetric"))
1133 else if (!strcmp(szRenderingIntent,
"Saturation"))
1135 else if (!strcmp(szRenderingIntent,
"ICC-absolute colorimetric"))
1147 return "PrivateType";
1164 return "PrivateTag";
1177 if (!strcmp(str,
"Unknown observer"))
1180 if (!strcmp(str,
"CIE 1931 (two degree) standard observer"))
1183 if (!strcmp(str,
"CIE 1964 (ten degree) standard observer"))
1192 if (!strcmp(str,
"Geometry Unknown"))
1195 if (!strcmp(str,
"Geometry 0-45 or 45-0"))
1198 if (!strcmp(str,
"Geometry 0-d or d-0"))
1201 if (!strcmp(str,
"Max Geometry"))
1209 if (!strcmp(str,
"Flare 0"))
1212 if (!strcmp(str,
"Flare 100"))
1215 if (!strcmp(str,
"Max Flare"))
1223 if (!strcmp(str,
"Illuminant Unknown"))
1226 if (!strcmp(str,
"Illuminant D50") || !strcmp(str,
"D50"))
1229 if (!strcmp(str,
"Illuminant D65") || !strcmp(str,
"D65"))
1232 if (!strcmp(str,
"Illuminant D93") || !strcmp(str,
"D93"))
1235 if (!strcmp(str,
"Illuminant F2") || !strcmp(str,
"F2"))
1238 if (!strcmp(str,
"Illuminant D55") || !strcmp(str,
"D55"))
1241 if (!strcmp(str,
"Illuminant A") || !strcmp(str,
"A"))
1244 if (!strcmp(str,
"Illuminant EquiPowerE") || !strcmp(str,
"Illuminant E") || !strcmp(str,
"E"))
1247 if (!strcmp(str,
"Illuminant F8") || !strcmp(str,
"F8"))
1250 if (!strcmp(str,
"Illuminant Black Body") || !strcmp(str,
"Black Body"))
1253 if (!strcmp(str,
"Illuminant Daylight") || !strcmp(str,
"Daylight"))
1256 if (!strcmp(str,
"Illuminant B") || !strcmp(str,
"B"))
1259 if (!strcmp(str,
"Illuminant C") || !strcmp(str,
"C"))
1262 if (!strcmp(str,
"Illuminant F1") || !strcmp(str,
"F1"))
1265 if (!strcmp(str,
"Illuminant F3") || !strcmp(str,
"F3"))
1268 if (!strcmp(str,
"Illuminant F4") || !strcmp(str,
"F4"))
1271 if (!strcmp(str,
"Illuminant F5") || !strcmp(str,
"F5"))
1274 if (!strcmp(str,
"Illuminant F6") || !strcmp(str,
"F6"))
1277 if (!strcmp(str,
"Illuminant F7") || !strcmp(str,
"F7"))
1280 if (!strcmp(str,
"Illuminant F9") || !strcmp(str,
"F9"))
1283 if (!strcmp(str,
"Illuminant F10") || !strcmp(str,
"F10"))
1286 if (!strcmp(str,
"Illuminant F11") || !strcmp(str,
"F11"))
1289 if (!strcmp(str,
"Illuminant F12") || !strcmp(str,
"F12"))
1299 return "Unknown Observer";
1302 return "CIE 1931 standard colorimetric observer";
1305 return "CIE 1964 standard colorimetric observer";
1308 return "Unknown Observer";
1314 unsigned int day=0, month=0, year=0, hours=0, minutes=0, seconds=0;
1319 struct tm * timeinfo;
1322 timeinfo = localtime ( &rawtime );
1323 year = timeinfo->tm_year+1900;
1324 month = timeinfo->tm_mon+1;
1325 day = timeinfo->tm_mday;
1326 hours = timeinfo->tm_hour;
1327 minutes = timeinfo->tm_min;
1328 seconds = timeinfo->tm_sec;
1331 sscanf(str,
"%d-%02d-%02dT%02d:%02d:%02d", &year, &month, &day, &hours, &minutes, &seconds);
1334 dateTime.
year = year;
1335 dateTime.
month = month;
1337 dateTime.
hours = hours;
1347 xmlAttr *attr =
icXmlFindAttr(pNode,
"ReflectiveOrTransparency");
1379 if (!strcmp(str,
"ITU-R BT.709"))
1382 if (!strcmp(str,
"SMPTE RP145-1994"))
1385 if (!strcmp(str,
"EBU Tech.3213-E"))
1388 if (!strcmp(str,
"P22"))
1396 if (!strcmp(str,
"Status A"))
1399 if (!strcmp(str,
"Status E"))
1402 if (!strcmp(str,
"Status I"))
1405 if (!strcmp(str,
"Status T"))
1408 if (!strcmp(str,
"Status M"))
1411 if (!strcmp(str,
"DIN with no polarizing filter"))
1414 if (!strcmp(str,
"DIN with polarizing filter"))
1417 if (!strcmp(str,
"Narrow band DIN with no polarizing filter"))
1420 if (!strcmp(str,
"Narrow band DIN with polarizing filter"))
1432 sprintf(line,
"<DeviceAttributes ReflectiveOrTransparency=\"transparency\"");
1434 sprintf(line,
"<DeviceAttributes ReflectiveOrTransparency=\"reflective\"");
1439 sprintf(line,
" GlossyOrMatte=\"matte\"");
1441 sprintf(line,
" GlossyOrMatte=\"glossy\"");
1446 sprintf(line,
" MediaPolarity=\"negative\"");
1448 sprintf(line,
" MediaPolarity=\"positive\"");
1452 sprintf(line,
" MediaColour=\"blackAndwhite\"");
1454 sprintf(line,
" MediaColour=\"colour\"");
1459 if (devAttr & otherAttr) {
1460 sprintf(line,
" VendorSpecific=\"%016llx\"", devAttr & otherAttr);
1475 sprintf(line,
"<ProfileFlags EmbeddedInFile=\"true\"");
1477 sprintf(line,
"<ProfileFlags EmbeddedInFile=\"false\"");
1481 sprintf(line,
" UseWithEmbeddedDataOnly=\"true\"");
1483 sprintf(line,
" UseWithEmbeddedDataOnly=\"false\"");
1487 sprintf(line,
" ExtendedRangePCS=\"true\"");
1495 sprintf(line,
" MCSNeedsSubset=\"true\"");
1497 sprintf(line,
" MCSNeedsSubset=\"false\"");
1500 otherFlags &= ~icMCSNeedsSubsetTrue;
1503 if (flags & otherFlags) {
1504 sprintf(line,
" VendorFlags=\"%08x\"", flags & otherFlags);
1515 std::string space =
"";
1516 if ( value >=0 && value < 10)
1518 if ( value >=10 && value < 100)
1520 if ( value >=100 && value < 1000 )
icUtfConversionResult icConvertUTF8toUTF16(const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, icUtfConversionFlags flags)
icUtfConversionResult icConvertUTF16toUTF8(const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, icUtfConversionFlags flags)
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
void * icRealloc(void *ptr, size_t size)
Name: icRealloc.
icUInt32Number icGetSigVal(const icChar *pBuf)
icMeasurementGeometry icGeNamedtMeasurementGeometryValue(const icChar *str)
const char * icUtf8ToAnsi(std::string &buf, const char *szSrc)
const std::string icGetDeviceAttrName(icUInt64Number devAttr)
icUInt32Number icXmlNodeCount3(xmlNode *pNode, const char *szNodeName1, const char *szNodeName2, const char *szNodeName3)
icColorantEncoding icGetColorantValue(const icChar *str)
icUInt32Number icXmlNodeCount(xmlNode *pNode, const char *szNodeName)
icUInt32Number icXmlGetHexDataSize(const char *szText)
icDateTimeNumber icGetDateTimeValue(const icChar *str)
const char * icUtf16ToUtf8(std::string &buf, const icUInt16Number *szSrc, int sizeSrc)
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
icUInt32Number icXmlNodeCount2(xmlNode *pNode, const char *szNodeName1, const char *szNodeName2)
xmlNode * icXmlFindNode(xmlNode *pNode, const char *szNodeName)
icUInt32Number icXmlGetHexData(void *pBuf, const char *szText, icUInt32Number nBufSize)
icTagTypeSignature icGetTypeNameTagSig(const icChar *szTagType)
const unsigned short * icUtf8ToUtf16(CIccUTF16String &buf, const char *szSrc, int sizeSrc)
icUInt32Number icXmlGetChildSigVal(xmlNode *pNode)
static bool icIsNumChar(char c)
icMeasurementFlare icGetNamedMeasurementFlareValue(const icChar *str)
const icChar * icGetStandardObserverName(icStandardObserver str)
const icChar * icGetTagSigTypeName(icTagTypeSignature tagTypeSig)
icUInt32Number icXmlDumpHexData(std::string &xml, std::string blanks, void *pBuf, icUInt32Number nBufSize)
const icChar * icGetTagSigName(icTagSignature tagTypeSig)
bool icCLUTDataToXml(std::string &xml, CIccCLUT *pCLUT, icConvertType nType, std::string blanks, bool bSaveGridPoints)
icTagSignature icGetTagNameSig(const icChar *szName)
icUInt64Number icGetDeviceAttrValue(xmlNode *pNode)
const std::string icGetHeaderFlagsName(icUInt32Number flags, bool bUsesMCS)
const std::string icGetPadSpace(double value)
const char * icFixXml(std::string &buf, const char *szStr)
icIlluminant icGetIlluminantValue(const icChar *str)
icMeasurementUnitSig icGetMeasurementValue(const icChar *str)
icStandardObserver icGetNamedStandardObserverValue(const icChar *str)
static int hexValue(char c)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
icRenderingIntent icGetRenderingIntentValue(const icChar *szRenderingIntent)
icFloatNumber icXmlStrToFloat(const xmlChar *szStr)
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)
const char * icAnsiToUtf8(std::string &buf, const char *szSrc)
#define icSigFloatArrayType
#define icXmlStrCmp(x, y)
const char * icUtf16ToUtf8(std::string &buf, const icUInt16Number *szSrc, int sizeSrc=0)
float nanf(const char *tagp)
unsigned int icUInt32Number
icUInt8Number GetInputDim() const
icUInt16Number GetOutputChannels() const
void Iterate(IIccCLUTExec *pExec)
Name: CIccCLUT::Iterate.
icUInt8Number GridPoint(int index) const
icUInt8Number GetPrecision()
icUInt32Number m_nCurPixel
CIccDumpXmlCLUT(std::string *xml, icConvertType nType, std::string blanks, icUInt16Number nSamples, icUInt8Number nPixelsPerRow)
icUInt16Number m_nSamples
icUInt8Number m_nPixelsPerRow
virtual void PixelOp(icFloatNumber *pGridAdr, icFloatNumber *pData)
static icTagTypeSignature GetTagTypeNameSig(const icChar *szName)
Function: GetTagTypeNameSig(szTypeName) Get signature based on display name of tag type.
static const icChar * GetTagSigName(icTagSignature tagTypeSig)
Function: GetTagSigName(tagSig) Get display name of tagSig.
static icTagSignature GetTagNameSig(const icChar *szName)
Function: GetTagNameSig(szTagName) Get signature from tag display name.
static const icChar * GetTagTypeSigName(icTagTypeSignature tagTypeSig)
Function: GetTagTypeSigName(tagTypeSig) Get display name of tagTypeSig.
static size_t AllocSize(size_t n)
const char * ToUtf8(std::string &buf)
static size_t WStrlen(const icUInt16Number *uzStr)
bool FromUtf8(const char *szStr, size_t sizeSrc=0)
virtual ~CIccUTF16String()
const icUInt16Number * c_str()
CIccUTF16String & operator=(const CIccUTF16String &wstr)
const wchar_t * ToWString(std::wstring &buf)
icUInt32Number ParseText(T *pBuf, icUInt32Number nSize, const char *szText)
bool ParseTextArray(const char *szText)
bool SetSize(icUInt32Number nSize)
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)
static icUInt32Number ParseTextCountNum(const char *szText, icUInt32Number num, std::string &parseStr)
static icUInt32Number ParseTextCount(const char *szText)
Interface Class: IIccCLUTExec.
The base date time number.