IccMAX 2.1.27
Color Profile Tools
Loading...
Searching...
No Matches
IccCmmConfig.cpp File Reference
#include "IccCmmConfig.h"
#include <stdio.h>
#include <fstream>
#include <string.h>
+ Include dependency graph for IccCmmConfig.cpp:

Go to the source code of this file.

Data Structures

class  CIccIndexValue
 
class  CIccIt8Parser
 

Typedefs

typedef std::pair< int, std::string > icIndexName
 
typedef std::vector< CIccIndexValueicValueVector
 

Functions

const char * icGetJsonColorEncoding (icFloatColorEncoding v)
 
const char * icGetJsonFileEncoding (icFloatColorEncoding v)
 
static const icCharicGetJsonFloatColorEncoding (icFloatColorEncoding val)
 
static bool icGetJsonRenderingIntent (const json &j, int &v)
 
icFloatColorEncoding icSetJsonColorEncoding (const char *szEncode)
 
icFloatColorEncoding icSetJsonFileEncoding (const char *szEncode)
 
static bool jsonFromEnvMap (json &j, const icCmmEnvSigMap &map)
 
void jsonSetValue (json &j, const char *szName, icCfgDataType v)
 
bool jsonToValue (const json &j, icCfgDataType &v)
 
bool jsonToValue (const json &j, icCmmEnvSigMap &v)
 
bool jsonToValue (const json &j, icDstBool &v)
 
bool jsonToValue (const json &j, icFloatColorEncoding &v)
 
static bool ParseName (icChar *pName, icChar *pString)
 
static bool ParseNextNumber (icFloatNumber &num, icChar **text)
 
static bool ParseNumbers (icFloatNumber *pData, icChar *pString, icUInt32Number nSamples)
 
static void setDstBool (json &j, const char *szName, icDstBool v)
 
static void setSampleIndex (std::vector< icValueVector > &samples, int index, const char *szFmt, const char **szChannels)
 

Variables

static const char * clrEncNames []
 
static icFloatColorEncoding clrEncValues []
 
static const char * fileEncNames [] = { "8Bit", "16Bit", "float", "sameAsSource", nullptr}
 
static icFloatColorEncoding fileEncValues [] = { icEncode8Bit, icEncode16Bit, icEncodeFloat, icEncodeUnknown, icEncode8Bit }
 
static const char * icInterpNames [] = { "linear", "tetrahedral", nullptr }
 
static icXformInterp icInterpValues [] = { icInterpLinear, icInterpTetrahedral, icInterpTetrahedral }
 
static const char * icTranNames []
 
static icXformLutType icTranValues []
 

Typedef Documentation

◆ icIndexName

typedef std::pair<int, std::string> icIndexName

◆ icValueVector

typedef std::vector<CIccIndexValue> icValueVector

Function Documentation

◆ icGetJsonColorEncoding()

const char * icGetJsonColorEncoding ( icFloatColorEncoding  v)
136{
137 int i;
138 for (i = 0; clrEncNames[i]; i++) {
139 if (v==clrEncValues[i])
140 break;
141 }
142
143 return clrEncNames[i] ? clrEncNames[i] : clrEncNames[0];
144}
static const char * clrEncNames[]
Definition IccCmmConfig.cpp:107
static icFloatColorEncoding clrEncValues[]
Definition IccCmmConfig.cpp:109

References clrEncNames, and clrEncValues.

Referenced by CIccCfgDataApply::toJson().

+ Here is the caller graph for this function:

◆ icGetJsonFileEncoding()

const char * icGetJsonFileEncoding ( icFloatColorEncoding  v)
162{
163
164 int i;
165 for (i = 0; fileEncNames[i]; i++) {
166 if (v == fileEncValues[i])
167 break;
168 }
169
170 return fileEncNames[i] ? fileEncNames[i] : clrEncNames[0];
171}
static icFloatColorEncoding fileEncValues[]
Definition IccCmmConfig.cpp:147
static const char * fileEncNames[]
Definition IccCmmConfig.cpp:146

References clrEncNames, fileEncNames, and fileEncValues.

Referenced by CIccCfgImageApply::toJson().

+ Here is the caller graph for this function:

◆ icGetJsonFloatColorEncoding()

static const icChar * icGetJsonFloatColorEncoding ( icFloatColorEncoding  val)
static
78{
79 switch (val) {
80
81 case icEncodeValue:
82 return "value";
83
84 case icEncodeFloat:
85 return "float";
86
87 case icEncodeUnitFloat:
88 return "unitFloat";
89
90 case icEncodePercent:
91 return "percent";
92
93 case icEncode8Bit:
94 return "8Bit";
95
96 case icEncode16Bit:
97 return "16Bit";
98
99 case icEncode16BitV2:
100 return "16BitV2";
101
102 default:
103 return "unknown";
104 }
105}

Referenced by CIccCfgColorData::toJson().

+ Here is the caller graph for this function:

◆ icGetJsonRenderingIntent()

static bool icGetJsonRenderingIntent ( const json j,
int &  v 
)
static
566{
567 if (j.is_string()) {
568 std::string str = j.get<std::string>();
569 if (str == "perceptual")
570 v = icPerceptual;
571 else if (str == "relative")
572 v = icRelative;
573 else if (str == "saturation")
574 v = icSaturation;
575 else if (str == "absolute")
576 v = icAbsolute;
577 else
578 v = icUnknownIntent;
579 }
580 else if (j.is_number_integer()) {
581 v = j.get<int>();
582 }
583 else
584 return false;
585
586 return true;
587}
#define icUnknownIntent
Definition icProfileHeader.h:1152
@ icRelative
Definition icProfileHeader.h:1145
@ icPerceptual
Definition icProfileHeader.h:1143
@ icAbsolute
Definition icProfileHeader.h:1148
@ icSaturation
Definition icProfileHeader.h:1146

References icAbsolute, icPerceptual, icRelative, and icSaturation.

Referenced by CIccCfgProfile::fromJson().

+ Here is the caller graph for this function:

◆ icSetJsonColorEncoding()

icFloatColorEncoding icSetJsonColorEncoding ( const char *  szEncode)
113{
114
115 int i;
116 for (i = 0; clrEncNames[i]; i++) {
117 if (!stricmp(szEncode, clrEncNames[i]))
118 break;
119 }
120
121 return clrEncValues[i];
122}
#define stricmp
Definition IccProfLibConf.h:149

References clrEncNames, and clrEncValues.

Referenced by CIccCfgColorData::fromJson(), and jsonToValue().

+ Here is the caller graph for this function:

◆ icSetJsonFileEncoding()

icFloatColorEncoding icSetJsonFileEncoding ( const char *  szEncode)
150{
151
152 int i;
153 for (i = 0; fileEncNames[i]; i++) {
154 if (!stricmp(szEncode, fileEncNames[i]))
155 break;
156 }
157
158 return fileEncValues[i];
159}

References fileEncNames, and fileEncValues.

Referenced by CIccCfgImageApply::fromJson().

+ Here is the caller graph for this function:

◆ jsonFromEnvMap()

static bool jsonFromEnvMap ( json j,
const icCmmEnvSigMap map 
)
static
664{
665 char buf[30];
666 j.clear();
667 for (auto e = map.begin(); e != map.end(); e++) {
668 json var;
669 var["name"] = icGetSigStr(buf, e->first);
670 var["value"] = e->second;
671 j.push_back(var);
672 }
673 return j.is_array() && j.size() > 0;
674}
ICCPROFLIB_API const icChar * icGetSigStr(icChar *pBuf, icUInt32Number nSig)
Definition IccUtil.cpp:1056
nlohmann::json json
Definition IccJsonUtil.h:81

References icGetSigStr().

Referenced by CIccCfgProfile::toJson().

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

◆ jsonSetValue()

void jsonSetValue ( json j,
const char *  szName,
icCfgDataType  v 
)
213{
214 if (v == icCfgColorData)
215 j[szName] = "colorData";
216 else if (v == icCfgLegacy)
217 j[szName] = "legacy";
218 else if (v == icCfgIt8)
219 j[szName] = "it8";
220}
@ icCfgLegacy
Definition IccCmmConfig.h:14
@ icCfgColorData
Definition IccCmmConfig.h:13
@ icCfgIt8
Definition IccCmmConfig.h:15

References icCfgColorData, icCfgIt8, and icCfgLegacy.

Referenced by CIccCfgDataApply::toJson().

+ Here is the caller graph for this function:

◆ jsonToValue() [1/4]

bool jsonToValue ( const json j,
icCfgDataType v 
)
194{
195 std::string str;
196 if (jsonToValue(j, str)) {
197 if (str == "colorData")
198 v = icCfgColorData;
199 else if (str == "legacy")
200 v = icCfgLegacy;
201 else if (str == "it8")
202 v = icCfgIt8;
203 else
204 return false;
205 }
206 else
207 return false;
208
209 return true;
210}
bool jsonToValue(const json &j, icFloatColorEncoding &v)
Definition IccCmmConfig.cpp:124

References icCfgColorData, icCfgIt8, icCfgLegacy, and jsonToValue().

Referenced by CIccCfgDataApply::fromJson().

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

◆ jsonToValue() [2/4]

bool jsonToValue ( const json j,
icCmmEnvSigMap v 
)
602{
603 if (!j.is_array())
604 return false;
605
606 for (auto e = j.begin(); e != j.end(); e++) {
607 if (e->is_object()) {
608 std::string name;
609 icFloatNumber value;
610 if (jsonToValue((*e)["name"], name) && jsonToValue((*e)["value"], value)) {
612 v[sig]=value;
613 }
614 }
615 }
616 return true;
617}
icColorSpaceSignature
Definition icProfileHeader.h:843
float icFloatNumber
Definition IccDefs.h:101
ICCPROFLIB_API icUInt32Number icGetSigVal(const icChar *pBuf)
Definition IccUtil.cpp:1258

References icGetSigVal(), and jsonToValue().

Referenced by CIccCfgProfile::fromJson().

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

◆ jsonToValue() [3/4]

bool jsonToValue ( const json j,
icDstBool v 
)
315{
316 if (j.is_boolean())
317 v = j.get<bool>() ? icDstBoolTrue : icDstBoolFalse;
318 else if (j.is_string()) {
319 std::string str = j.get<std::string>();
320 if (str == "true")
321 v = icDstBoolTrue;
322 else if (str == "false")
323 v = icDstBoolFalse;
324 else if (str == "sameAsSource")
326 else
327 return false;
328 }
329 else
330 return false;
331
332 return true;
333}
@ icDstBoolTrue
Definition IccCmmConfig.h:53
@ icDstBoolFalse
Definition IccCmmConfig.h:52
@ icDstBoolFromSrc
Definition IccCmmConfig.h:54

References icDstBoolFalse, icDstBoolFromSrc, and icDstBoolTrue.

Referenced by CIccCfgImageApply::fromJson().

+ Here is the caller graph for this function:

◆ jsonToValue() [4/4]

bool jsonToValue ( const json j,
icFloatColorEncoding &  v 
)
125{
126 std::string str;
127 if (jsonToValue(j, str)) {
128 v = icSetJsonColorEncoding(str.c_str());
129 return true;
130 }
131
132 return false;
133}
icFloatColorEncoding icSetJsonColorEncoding(const char *szEncode)
Definition IccCmmConfig.cpp:112

References icSetJsonColorEncoding(), and jsonToValue().

Referenced by CIccCfgDataApply::fromJson().

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

◆ ParseName()

static bool ParseName ( icChar pName,
icChar pString 
)
static
956{
957 if (strncmp(pString, "{ \"", 3))
958 return false;
959
960 icChar* ptr = strstr(pString, "\" }");
961
962 if (!ptr)
963 return false;
964
965 icUInt32Number nNameLen = (icUInt32Number)(ptr - (pString + 3));
966
967 if (!nNameLen)
968 return false;
969
970 strncpy(pName, pString + 3, nNameLen);
971 pName[nNameLen] = '\0';
972
973 return true;
974}
unsigned long icUInt32Number
Definition icProfileHeader.h:262
char icChar
Definition IccDefs.h:110

Referenced by CIccCfgColorData::fromLegacy().

+ Here is the caller graph for this function:

◆ ParseNextNumber()

static bool ParseNextNumber ( icFloatNumber num,
icChar **  text 
)
static
935{
936 if (!text)
937 return false;
938
939 icChar* ptr = *text;
940 while (*ptr == ' ') ptr++;
941 if ((*ptr >= '0' && *ptr <= '9') || *ptr == '.') {
942 num = (icFloatNumber)atof(ptr);
943
944 while (*ptr && *ptr != ' ') ptr++;
945
946 *text = ptr;
947
948 return true;
949 }
950 return false;
951}

Referenced by CIccCfgColorData::fromLegacy().

+ Here is the caller graph for this function:

◆ ParseNumbers()

static bool ParseNumbers ( icFloatNumber pData,
icChar pString,
icUInt32Number  nSamples 
)
static
911{
912 icUInt32Number nNumbersRead = 0;
913
914 icChar* ptr = pString;
915
916 while (*ptr && nNumbersRead < nSamples) {
917 while (*ptr == ' ' || *ptr == '\t' || *ptr == '\n' || *ptr == '\r')
918 ptr++;
919 if (sscanf(ptr, ICFLOATFMT, &pData[nNumbersRead]) == 1)
920 nNumbersRead++;
921 else
922 break;
923 while (*ptr && *ptr != ' ' && *ptr != '\t' && *ptr != 'n' && *ptr != '\r')
924 ptr++;
925 }
926
927 if (nNumbersRead != nSamples) {
928 return false;
929 }
930
931 return true;
932}
#define ICFLOATFMT
Definition IccDefs.h:107

Referenced by CIccCfgColorData::fromLegacy().

+ Here is the caller graph for this function:

◆ setDstBool()

static void setDstBool ( json j,
const char *  szName,
icDstBool  v 
)
static
386{
387 if (v == icDstBoolTrue)
388 j[szName] = true;
389 else if (v == icDstBoolFalse)
390 j[szName] = false;
391 else if (v = icDstBoolFromSrc)
392 j[szName] = "sameAsSoure";
393}

References icDstBoolFalse, icDstBoolFromSrc, and icDstBoolTrue.

Referenced by CIccCfgImageApply::toJson().

+ Here is the caller graph for this function:

◆ setSampleIndex()

static void setSampleIndex ( std::vector< icValueVector > &  samples,
int  index,
const char *  szFmt,
const char **  szChannels 
)
static
1079{
1080 size_t nPos = samples.size() - 1;
1081 for (int i = 0; i < samples[nPos].size(); i++) {
1082 if (!strcmp(szFmt, szChannels[i])) {
1083 samples[nPos][i].nIndex = index;
1084 }
1085 }
1086}

References CIccIndexValue::nIndex.

Referenced by CIccCfgColorData::fromIt8().

+ Here is the caller graph for this function:

Variable Documentation

◆ clrEncNames

const char* clrEncNames[]
static
Initial value:
= { "value", "float", "unitFloat", "percent",
"8Bit", "16Bit", "16BitV2", nullptr }
107 { "value", "float", "unitFloat", "percent",
108 "8Bit", "16Bit", "16BitV2", nullptr };

Referenced by icGetJsonColorEncoding(), icGetJsonFileEncoding(), and icSetJsonColorEncoding().

◆ clrEncValues

icFloatColorEncoding clrEncValues[]
static
Initial value:
= { icEncodeValue, icEncodeFloat, icEncodeUnitFloat, icEncodePercent,
icEncode8Bit, icEncode16Bit, icEncode16BitV2, icEncodeUnknown }
109 { icEncodeValue, icEncodeFloat, icEncodeUnitFloat, icEncodePercent,
110 icEncode8Bit, icEncode16Bit, icEncode16BitV2, icEncodeUnknown };

Referenced by icGetJsonColorEncoding(), and icSetJsonColorEncoding().

◆ fileEncNames

const char* fileEncNames[] = { "8Bit", "16Bit", "float", "sameAsSource", nullptr}
static
146{ "8Bit", "16Bit", "float", "sameAsSource", nullptr};

Referenced by icGetJsonFileEncoding(), and icSetJsonFileEncoding().

◆ fileEncValues

icFloatColorEncoding fileEncValues[] = { icEncode8Bit, icEncode16Bit, icEncodeFloat, icEncodeUnknown, icEncode8Bit }
static
147{ icEncode8Bit, icEncode16Bit, icEncodeFloat, icEncodeUnknown, icEncode8Bit };

Referenced by icGetJsonFileEncoding(), and icSetJsonFileEncoding().

◆ icInterpNames

const char* icInterpNames[] = { "linear", "tetrahedral", nullptr }
static
597{ "linear", "tetrahedral", nullptr };

Referenced by CIccCfgProfile::fromJson(), and CIccCfgProfile::toJson().

◆ icInterpValues

@ icInterpTetrahedral
Definition IccCmm.h:115
@ icInterpLinear
Definition IccCmm.h:114

Referenced by CIccCfgProfile::fromJson(), and CIccCfgProfile::toJson().

◆ icTranNames

const char* icTranNames[]
static
Initial value:
= { "default", "named", "colorimetric", "spectral",
"MCS", "preview", "gamut", "brdfParam",
"brdfDirect", "brdfMcsParam" , nullptr }
589 { "default", "named", "colorimetric", "spectral",
590 "MCS", "preview", "gamut", "brdfParam",
591 "brdfDirect", "brdfMcsParam" , nullptr };

Referenced by CIccCfgProfile::fromJson().

◆ icTranValues

icXformLutType icTranValues[]
static
Initial value:
@ icXformLutNamedColor
Definition IccCmm.h:127
@ icXformLutBRDFDirect
Definition IccCmm.h:132
@ icXformLutBRDFMcsParam
Definition IccCmm.h:133
@ icXformLutGamut
Definition IccCmm.h:129
@ icXformLutColorimetric
Definition IccCmm.h:135
@ icXformLutMCS
Definition IccCmm.h:134
@ icXformLutColor
Definition IccCmm.h:126
@ icXformLutSpectral
Definition IccCmm.h:136
@ icXformLutPreview
Definition IccCmm.h:128
@ icXformLutBRDFParam
Definition IccCmm.h:131

Referenced by CIccCfgProfile::fromJson().