#include "IccCmmConfig.h"
#include <stdio.h>
#include <fstream>
#include <string.h>
Go to the source code of this file.
|
const char * | icGetJsonColorEncoding (icFloatColorEncoding v) |
|
const char * | icGetJsonFileEncoding (icFloatColorEncoding v) |
|
static const icChar * | icGetJsonFloatColorEncoding (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) |
|
|
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 [] |
|
◆ icIndexName
◆ icValueVector
◆ icGetJsonColorEncoding()
const char * icGetJsonColorEncoding |
( |
icFloatColorEncoding |
v | ) |
|
136{
137 int i;
140 break;
141 }
142
144}
static const char * clrEncNames[]
Definition IccCmmConfig.cpp:107
static icFloatColorEncoding clrEncValues[]
Definition IccCmmConfig.cpp:109
References clrEncNames, and clrEncValues.
Referenced by CIccCfgDataApply::toJson().
◆ icGetJsonFileEncoding()
const char * icGetJsonFileEncoding |
( |
icFloatColorEncoding |
v | ) |
|
◆ 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().
◆ 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")
571 else if (str == "relative")
573 else if (str == "saturation")
575 else if (str == "absolute")
577 else
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().
◆ icSetJsonColorEncoding()
icFloatColorEncoding icSetJsonColorEncoding |
( |
const char * |
szEncode | ) |
|
◆ icSetJsonFileEncoding()
icFloatColorEncoding icSetJsonFileEncoding |
( |
const char * |
szEncode | ) |
|
◆ jsonFromEnvMap()
664{
665 char buf[30];
666 j.clear();
667 for (auto e = map.begin(); e != map.end(); e++) {
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().
◆ jsonSetValue()
213{
215 j[szName] = "colorData";
217 j[szName] = "legacy";
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().
◆ jsonToValue() [1/4]
194{
195 std::string str;
197 if (str == "colorData")
199 else if (str == "legacy")
201 else if (str == "it8")
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().
◆ jsonToValue() [2/4]
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;
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().
◆ jsonToValue() [3/4]
315{
316 if (j.is_boolean())
318 else if (j.is_string()) {
319 std::string str = j.get<std::string>();
320 if (str == "true")
322 else if (str == "false")
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().
◆ jsonToValue() [4/4]
bool jsonToValue |
( |
const json & |
j, |
|
|
icFloatColorEncoding & |
v |
|
) |
| |
◆ ParseName()
956{
957 if (strncmp(pString, "{ \"", 3))
958 return false;
959
960 icChar* ptr = strstr(pString,
"\" }");
961
962 if (!ptr)
963 return false;
964
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().
◆ ParseNextNumber()
935{
936 if (!text)
937 return false;
938
940 while (*ptr == ' ') ptr++;
941 if ((*ptr >= '0' && *ptr <= '9') || *ptr == '.') {
943
944 while (*ptr && *ptr != ' ') ptr++;
945
946 *text = ptr;
947
948 return true;
949 }
950 return false;
951}
Referenced by CIccCfgColorData::fromLegacy().
◆ ParseNumbers()
911{
913
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().
◆ setDstBool()
static void setDstBool |
( |
json & |
j, |
|
|
const char * |
szName, |
|
|
icDstBool |
v |
|
) |
| |
|
static |
◆ 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().
◆ 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 |
◆ fileEncValues
icFloatColorEncoding fileEncValues[] = { icEncode8Bit, icEncode16Bit, icEncodeFloat, icEncodeUnknown, icEncode8Bit } |
|
static |
◆ icInterpNames
const char* icInterpNames[] = { "linear", "tetrahedral", nullptr } |
|
static |
◆ icInterpValues
◆ 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
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().