Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccV5DspObsToV4Dsp.cpp File Reference
#include <stdio.h>
#include <cstring>
#include "IccProfile.h"
#include "IccTag.h"
#include "IccTagMPE.h"
#include "IccTagLut.h"
#include "IccMpeBasic.h"
#include "IccMpeSpectral.h"
#include "IccUtil.h"
#include "IccProfLibVer.h"
#include <memory>
+ Include dependency graph for IccV5DspObsToV4Dsp.cpp:

Go to the source code of this file.

Typedefs

typedef std::shared_ptr< CIccProfile > CIccProfileSharedPtr
 

Functions

int main (int argc, char *argv[])
 

Typedef Documentation

◆ CIccProfileSharedPtr

typedef std::shared_ptr<CIccProfile> CIccProfileSharedPtr

Definition at line 84 of file IccV5DspObsToV4Dsp.cpp.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 86 of file IccV5DspObsToV4Dsp.cpp.

87{
88 if (argc <= 3) {
89 printf("Usage: iccV5DspObsToV4Dsp v5DspIccPath v5ObsPcc v4DspIccPath\n");
90 printf("Built with IccProfLib version " ICCPROFLIBVER "\n");
91
92 return -1;
93 }
94
96
97 if (!dspIcc) {
98 printf("Unable to parse '%s'\n", argv[1]);
99 return -2;
100 }
101
102 if (dspIcc->m_Header.version < icVersionNumberV5 ||
103 dspIcc->m_Header.deviceClass != icSigDisplayClass) {
104 printf("%s is not a V5 display profile\n", argv[1]);
105 return -2;
106 }
107
109
110 if (!pTagIn) {
111 printf("%s doesn't have an AToB1Tag of type mulitProcessElementType\n", argv[1]);
112 return -2;
113 }
114
115 CIccMultiProcessElement *curveMpe, *matrixMpe;
116
117 if (pTagIn->NumElements() != 2 ||
118 pTagIn->NumInputChannels() != 3 ||
119 pTagIn->NumOutputChannels() != 3 ||
120 ((curveMpe = pTagIn->GetElement(0))==nullptr) ||
121 curveMpe->GetType()!= icSigCurveSetElemType ||
122 ((matrixMpe = pTagIn->GetElement(1))==nullptr) ||
123 matrixMpe->GetType()!=icSigEmissionMatrixElemType) {
124 printf("%s doesn't have a spectral emission AToB1Tag\n", argv[1]);
125 return -2;
126 }
127
129
130 if (!pccIcc) {
131 printf("Unable to parse '%s'\n", argv[2]);
132 return -2;
133 }
134
135 if (pccIcc->m_Header.version < icVersionNumberV5) {
136 printf("%s is not a V5 profile\n", argv[1]);
137 return -2;
138 }
139
142
143 if (!pTagSvcn ||
144 !pTagC2S ||
145 pTagC2S->NumInputChannels() != 3 ||
146 pTagC2S->NumOutputChannels() != 3) {
147 printf("%s doesn't have Profile Connection Conditions\n", argv[2]);
148 return -2;
149 }
150
151 pTagIn->Begin(icElemInterpLinear, dspIcc.get(), pccIcc.get());
152
153 std::shared_ptr<CIccApplyTagMpe> pApplyMpe = std::shared_ptr<CIccApplyTagMpe>(pTagIn->GetNewApply());
154
155 auto applyList = pApplyMpe->GetList();
156 auto applyIter = applyList->begin();
157 auto curveApply = applyIter->ptr;
158 applyIter++;
159 auto mtxApply = applyIter->ptr;
160
161 pTagC2S->Begin(icElemInterpLinear, pccIcc.get());
162
163 std::shared_ptr<CIccApplyTagMpe> pAppyC2S = std::shared_ptr<CIccApplyTagMpe>(pTagC2S->GetNewApply());
164
165
166 CIccProfilePtr pIcc = CIccProfilePtr(new CIccProfile());
167
168 pIcc->InitHeader();
169 pIcc->m_Header.deviceClass = icSigDisplayClass;
170 pIcc->m_Header.version = icVersionNumberV4_3;
171
172 CIccTag* pDesc = dspIcc->FindTag(icSigProfileDescriptionTag);
173
175 std::string text;
176 if (!icGetTagText(pDesc, text))
177 text = std::string("Display profile from '") + argv[1] + "' and PCC '" + argv[2] + "'";
178 pDspText->SetText(text.c_str());
179
180 pIcc->AttachTag(icSigProfileDescriptionTag, pDspText);
181
182 pDspText = new CIccTagMultiLocalizedUnicode();
183 pDspText->SetText("Copyright (C) 2023 International Color Consortium");
184
185 pIcc->AttachTag(icSigCopyrightTag, pDspText);
186
187 CIccTagCurve* pTrcR = new CIccTagCurve(2048);
188 CIccTagCurve* pTrcG = new CIccTagCurve(2048);
189 CIccTagCurve* pTrcB = new CIccTagCurve(2048);
190
191 icFloatNumber in[3], out[3];
192 for (icUInt16Number i=0; i<2048; i++) {
193 in[0] = in[1] = in[2] = (icFloatNumber)i / 2047.0f;
194 curveMpe->Apply(curveApply, out, in);
195 (*pTrcR)[i] = out[0];
196 (*pTrcG)[i] = out[1];
197 (*pTrcB)[i] = out[2];
198 }
199
200 const icFloatNumber rRGB[3] = { 1.0f, 0.0f, 0.0f };
201 const icFloatNumber gRGB[3] = { 0.0f, 1.0f, 0.0f };
202 const icFloatNumber bRGB[3] = { 0.0f, 0.0f, 1.0f };
203
204 CIccTagS15Fixed16* primaryXYZ;
205
206 matrixMpe->Apply(mtxApply, in, rRGB);
207 pTagC2S->Apply(pAppyC2S.get(), out, in);
208
209 primaryXYZ = new CIccTagS15Fixed16(3);
210 (*primaryXYZ)[0] = icDtoF(out[0]); (*primaryXYZ)[1] = icDtoF(out[1]); (*primaryXYZ)[2] = icDtoF(out[2]);
211 pIcc->AttachTag(icSigRedColorantTag, primaryXYZ);
212
213 matrixMpe->Apply(mtxApply, in, gRGB);
214 pTagC2S->Apply(pAppyC2S.get(), out, in);
215
216 primaryXYZ = new CIccTagS15Fixed16(3);
217 (*primaryXYZ)[0] = icDtoF(out[0]); (*primaryXYZ)[1] = icDtoF(out[1]); (*primaryXYZ)[2] = icDtoF(out[2]);
218 pIcc->AttachTag(icSigGreenColorantTag, primaryXYZ);
219
220 matrixMpe->Apply(mtxApply, in, bRGB);
221 pTagC2S->Apply(pAppyC2S.get(), out, in);
222
223 primaryXYZ = new CIccTagS15Fixed16(3);
224 (*primaryXYZ)[0] = icDtoF(out[0]); (*primaryXYZ)[1] = icDtoF(out[1]); (*primaryXYZ)[2] = icDtoF(out[2]);
225 pIcc->AttachTag(icSigBlueColorantTag, primaryXYZ);
226
227 SaveIccProfile(argv[3], pIcc);
228 printf("%s successfully created\n", argv[3]);
229
230 return 0;
231 }
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
#define ICCPROFLIBVER
bool SaveIccProfile(const icChar *szFilename, CIccProfile *pIcc, icProfileIDSaveMethod nWriteId)
Name: SaveIccProfile.
CIccProfile * ReadIccProfile(const icChar *szFilename, bool bUseSubProfile)
Name: ReadIccProfile.
bool icGetTagText(const CIccTag *pTag, std::string &text)
CIccTagFixedNum< icS15Fixed16Number, icSigS15Fixed16ArrayType > CIccTagS15Fixed16
Class: CIccTagS15Fixed16.
@ icElemInterpLinear
Definition IccTagMPE.h:94
icS15Fixed16Number icDtoF(icFloatNumber num)
Definition IccUtil.cpp:545
std::shared_ptr< CIccProfile > CIccProfileSharedPtr
Class: CIccMultiProcessElement.
Definition IccTagMPE.h:146
virtual void Apply(CIccApplyMpe *pApply, icFloatNumber *pDestPixel, const icFloatNumber *pSrcPixel) const =0
virtual icElemTypeSignature GetType() const =0
Class: CIccTagCurve.
Definition IccTagLut.h:128
Class: CIccTagFixedNum.
Class: CIccTag.
Class: CIccTagMultiLocalizedUnicode.
void SetText(const icChar *szText, icLanguageCode nLanguageCode=icLanguageCodeEnglish, icCountryCode nRegionCode=icCountryCodeUSA)
Name: refIccMAX::CIccTagMultiLocalizedUnicode::SetText.
Class: CIccTagMultiProcessElement.
Definition IccTagMPE.h:358
icUInt16Number NumInputChannels() const
Definition IccTagMPE.h:393
virtual bool Begin(icElemInterp nInterp=icElemInterpLinear, IIccProfileConnectionConditions *pProfilePCC=NULL, IIccProfileConnectionConditions *pAppliedPCC=NULL, IIccCmmEnvVarLookup *pCmmEnvVarLookup=NULL)
Name: CIccTagMultiProcessElement::Begin.
icUInt16Number NumOutputChannels() const
Definition IccTagMPE.h:394
virtual CIccApplyTagMpe * GetNewApply()
Name: CIccTagMultiProcessElement::GetNewApply.
virtual void Apply(CIccApplyTagMpe *pApply, icFloatNumber *pDestPixel, const icFloatNumber *pSrcPixel) const
Name: CIccTagMultiProcessElement::Apply.
icUInt32Number NumElements() const
Definition IccTagMPE.h:398
CIccMultiProcessElement * GetElement(int nIndex)
Name: CIccTagMultiProcessElement::GetElement.
Class: CIccTagSpectralViewingConditions.
#define icVersionNumberV4_3
unsigned short icUInt16Number
@ icSigDisplayClass
@ icSigEmissionMatrixElemType
@ icSigCurveSetElemType
@ icSigMultiProcessElementType
@ icSigSpectralViewingConditionsType
#define icVersionNumberV5
@ icSigSpectralViewingConditionsTag
@ icSigCustomToStandardPccTag
@ icSigProfileDescriptionTag
@ icSigRedColorantTag
@ icSigCopyrightTag
@ icSigAToB1Tag
@ icSigGreenColorantTag
@ icSigBlueColorantTag

References CIccMultiProcessElement::Apply(), CIccTagMultiProcessElement::Apply(), CIccTagMultiProcessElement::Begin(), CIccTagMultiProcessElement::GetElement(), CIccTagMultiProcessElement::GetNewApply(), CIccMultiProcessElement::GetType(), ICCPROFLIBVER, icDtoF(), icElemInterpLinear, icGetTagText(), icSigAToB1Tag, icSigBlueColorantTag, icSigCopyrightTag, icSigCurveSetElemType, icSigCustomToStandardPccTag, icSigDisplayClass, icSigEmissionMatrixElemType, icSigGreenColorantTag, icSigMultiProcessElementType, icSigProfileDescriptionTag, icSigRedColorantTag, icSigSpectralViewingConditionsTag, icSigSpectralViewingConditionsType, icVersionNumberV4_3, icVersionNumberV5, CIccTagMultiProcessElement::NumElements(), CIccTagMultiProcessElement::NumInputChannels(), CIccTagMultiProcessElement::NumOutputChannels(), ReadIccProfile(), SaveIccProfile(), and CIccTagMultiLocalizedUnicode::SetText().

+ Here is the call graph for this function: