Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
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.

Classes

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 int icTranValues []
 

Typedef Documentation

◆ icIndexName

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

Definition at line 1074 of file IccCmmConfig.cpp.

◆ icValueVector

typedef std::vector<CIccIndexValue> icValueVector

Definition at line 1075 of file IccCmmConfig.cpp.

Function Documentation

◆ icGetJsonColorEncoding()

const char * icGetJsonColorEncoding ( icFloatColorEncoding v)

Definition at line 135 of file IccCmmConfig.cpp.

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[]
static icFloatColorEncoding clrEncValues[]

References clrEncNames, and clrEncValues.

Referenced by CIccCfgDataApply::toJson().

+ Here is the caller graph for this function:

◆ icGetJsonFileEncoding()

const char * icGetJsonFileEncoding ( icFloatColorEncoding v)

Definition at line 161 of file IccCmmConfig.cpp.

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[]
static const char * fileEncNames[]

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

Definition at line 77 of file IccCmmConfig.cpp.

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

Definition at line 565 of file IccCmmConfig.cpp.

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
Convenience Enum Definitions - Not defined in ICC specification.
@ icRelative
@ icPerceptual
@ icAbsolute
@ icSaturation

References icAbsolute, icPerceptual, icRelative, icSaturation, and icUnknownIntent.

Referenced by CIccCfgProfile::fromJson().

+ Here is the caller graph for this function:

◆ icSetJsonColorEncoding()

icFloatColorEncoding icSetJsonColorEncoding ( const char * szEncode)

Definition at line 112 of file IccCmmConfig.cpp.

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

References clrEncNames, clrEncValues, and stricmp.

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

+ Here is the caller graph for this function:

◆ icSetJsonFileEncoding()

icFloatColorEncoding icSetJsonFileEncoding ( const char * szEncode)

Definition at line 149 of file IccCmmConfig.cpp.

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, fileEncValues, and stricmp.

Referenced by CIccCfgImageApply::fromJson().

+ Here is the caller graph for this function:

◆ jsonFromEnvMap()

static bool jsonFromEnvMap ( json & j,
const icCmmEnvSigMap & map )
static

Definition at line 663 of file IccCmmConfig.cpp.

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}
const icChar * icGetSigStr(icChar *pBuf, icUInt32Number nSig)
Definition IccUtil.cpp:1056

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 )

Definition at line 212 of file IccCmmConfig.cpp.

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
@ icCfgColorData
Definition IccCmmConfig.h:9
@ icCfgIt8
const icChar * szName

References icCfgColorData, icCfgIt8, icCfgLegacy, and szName.

Referenced by CIccCfgDataApply::toJson().

+ Here is the caller graph for this function:

◆ jsonToValue() [1/4]

bool jsonToValue ( const json & j,
icCfgDataType & v )

Definition at line 193 of file IccCmmConfig.cpp.

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)

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

+ Here is the call graph for this function:

◆ jsonToValue() [2/4]

bool jsonToValue ( const json & j,
icCmmEnvSigMap & v )

Definition at line 601 of file IccCmmConfig.cpp.

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}
icArraySignature sig
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
icUInt32Number icGetSigVal(const icChar *pBuf)
Definition IccUtil.cpp:1258
icColorSpaceSignature
Color Space Signatures.

References icGetSigVal(), jsonToValue(), and sig.

+ Here is the call graph for this function:

◆ jsonToValue() [3/4]

bool jsonToValue ( const json & j,
icDstBool & v )

Definition at line 314 of file IccCmmConfig.cpp.

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
@ icDstBoolFalse
@ icDstBoolFromSrc

References icDstBoolFalse, icDstBoolFromSrc, and icDstBoolTrue.

◆ jsonToValue() [4/4]

bool jsonToValue ( const json & j,
icFloatColorEncoding & v )

Definition at line 124 of file IccCmmConfig.cpp.

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)

References icSetJsonColorEncoding(), and jsonToValue().

Referenced by CIccCfgColorData::fromJson(), CIccCfgCreateLink::fromJson(), CIccCfgDataApply::fromJson(), CIccCfgDataEntry::fromJson(), CIccCfgImageApply::fromJson(), CIccCfgProfile::fromJson(), jsonToValue(), jsonToValue(), and jsonToValue().

+ 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

Definition at line 955 of file IccCmmConfig.cpp.

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}
char icChar
Definition IccDefs.h:109
unsigned int icUInt32Number

Referenced by CIccCfgColorData::fromLegacy().

+ Here is the caller graph for this function:

◆ ParseNextNumber()

static bool ParseNextNumber ( icFloatNumber & num,
icChar ** text )
static

Definition at line 934 of file IccCmmConfig.cpp.

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

Definition at line 910 of file IccCmmConfig.cpp.

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:106

References ICFLOATFMT.

Referenced by CIccCfgColorData::fromLegacy().

+ Here is the caller graph for this function:

◆ setDstBool()

static void setDstBool ( json & j,
const char * szName,
icDstBool v )
static

Definition at line 385 of file IccCmmConfig.cpp.

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, icDstBoolTrue, and szName.

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

Definition at line 1077 of file IccCmmConfig.cpp.

1078{
1079 size_t nPos = samples.size() - 1;
1080 for (int i = 0; i < samples[nPos].size(); i++) {
1081 if (!strcmp(szFmt, szChannels[i])) {
1082 samples[nPos][i].nIndex = index;
1083 }
1084 }
1085}

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 }

Definition at line 107 of file IccCmmConfig.cpp.

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 }

Definition at line 109 of file IccCmmConfig.cpp.

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

Definition at line 146 of file IccCmmConfig.cpp.

146{ "8Bit", "16Bit", "float", "sameAsSource", nullptr};

Referenced by icGetJsonFileEncoding(), and icSetJsonFileEncoding().

◆ fileEncValues

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

Definition at line 147 of file IccCmmConfig.cpp.

147{ icEncode8Bit, icEncode16Bit, icEncodeFloat, icEncodeUnknown, icEncode8Bit };

Referenced by icGetJsonFileEncoding(), and icSetJsonFileEncoding().

◆ icInterpNames

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

Definition at line 597 of file IccCmmConfig.cpp.

597{ "linear", "tetrahedral", nullptr };

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

◆ icInterpValues

Definition at line 599 of file IccCmmConfig.cpp.

@ 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 }

Definition at line 589 of file IccCmmConfig.cpp.

589 { "default", "named", "colorimetric", "spectral",
590 "MCS", "preview", "gamut", "brdfParam",
591 "brdfDirect", "brdfMcsParam" , nullptr };

Referenced by CIccCfgProfile::fromJson().

◆ icTranValues