Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CIccDefaultEncProfileConverter Class Reference
+ Inheritance diagram for CIccDefaultEncProfileConverter:
+ Collaboration diagram for CIccDefaultEncProfileConverter:

Public Member Functions

 CIccDefaultEncProfileConverter ()
 
virtual icStatusEncConvert ConvertFromParams (CIccProfilePtr &newIcc, CIccTagStruct *pParams, icHeader *pHeader)
 
- Public Member Functions inherited from IIccEncProfileConverter
virtual ~IIccEncProfileConverter ()
 

Additional Inherited Members

- Static Public Member Functions inherited from IIccEncProfileConverter
static IIccEncProfileConverterGetHandler ()
 
static void SetEncProfileConverter (IIccEncProfileConverter *pConverter)
 

Detailed Description

Definition at line 117 of file IccEncoding.cpp.

Constructor & Destructor Documentation

◆ CIccDefaultEncProfileConverter()

CIccDefaultEncProfileConverter::CIccDefaultEncProfileConverter ( )
inline

Definition at line 120 of file IccEncoding.cpp.

120{}

Member Function Documentation

◆ ConvertFromParams()

icStatusEncConvert CIccDefaultEncProfileConverter::ConvertFromParams ( CIccProfilePtr & newIcc,
CIccTagStruct * pParams,
icHeader * pHeader )
virtual

Implements IIccEncProfileConverter.

Definition at line 142 of file IccEncoding.cpp.

143{
144 newIcc = NULL;
145
146 if (!pParams || pParams->GetTagStructType()!= icSigColorEncodingParamsSruct || !pHeader)
148
151
152 if (!pWhitePt || pWhitePt->GetNumValues()<2) {
154 }
155
156 if (!pMediaWhitePt)
157 pMediaWhitePt = pWhitePt;
158
159 if (!pMediaWhitePt || pMediaWhitePt->GetNumValues()<2) {
161 }
162
163 CIccProfile *pIcc = new CIccProfile;
164 pIcc->m_Header = *pHeader;
165
166 struct tm *newtime;
167 time_t long_time;
168
169 time( &long_time ); /* Get time as long integer. */
170 newtime = gmtime( &long_time );
171
172 pIcc->m_Header.date.year = newtime->tm_year+1900;
173 pIcc->m_Header.date.month = newtime->tm_mon+1;
174 pIcc->m_Header.date.day = newtime->tm_mday;
175 pIcc->m_Header.date.hours = newtime->tm_hour;
176 pIcc->m_Header.date.minutes = newtime->tm_min;
177 pIcc->m_Header.date.seconds = newtime->tm_sec;
178
179 float XYZWhite[3];
180 icYxy2XYZVector(XYZWhite, 1.0f, &(*pWhitePt)[0], 1);
181 //Fill header from pParams
182 pIcc->m_Header.pcs = icSigXYZPcsData;
183 pIcc->m_Header.deviceClass = icSigDisplayClass;
184 pIcc->m_Header.illuminant.X = icDtoF(XYZWhite[0]);
185 pIcc->m_Header.illuminant.Y = icDtoF(XYZWhite[1]);
186 pIcc->m_Header.illuminant.Z = icDtoF(XYZWhite[2]);
187
188 //Fill Media White Point tag
189 CIccTagXYZ *pXYZ = new CIccTagXYZ();
190 float XYZMedia[3];
191 icYxy2XYZVector(XYZMedia, 1.0f, &(*pMediaWhitePt)[0], 1);
192 if (!pXYZ->SetSize(1))
194
195 (*pXYZ)[0].X = icDtoF(XYZMedia[0]);
196 (*pXYZ)[0].Y = icDtoF(XYZMedia[1]);
197 (*pXYZ)[0].Z = icDtoF(XYZMedia[2]);
198 pIcc->AttachTag(icSigMediaWhitePointTag, pXYZ);
199
200 //Create A2B tag from pParams
202 if (!pMpeTag) {
203 delete pIcc;
205 }
206
207 pMpeTag->SetChannels(3, 3);
208
209 CIccMpeMatrix *pMtx;
211 icFloatNumber lumMtx[9];
212 bool bHaveLumMtx = false;
213 if (pLumMtx) {
214 if (pLumMtx->GetSize()<9) {
215 delete pMpeTag;
216 delete pIcc;
218 }
220 if (!pMtx) {
221 delete pMpeTag;
222 delete pIcc;
224 }
225 if (!pMtx->SetSize(3, 3))
227
228 pLumMtx->GetValues(pMtx->GetMatrix(), 0, 9);
229 pLumMtx->GetValues(&lumMtx[0], 0, 9);
230 pMpeTag->Attach(pMtx);
231 delete pLumMtx;
232 bHaveLumMtx = true;
233 }
234
236 if (pSegCurve && pSegCurve->GetCurve()) {
237 CIccSegmentedCurve *pCurve = pSegCurve->GetCurve();
239 if (!pCurves) {
240 delete pMpeTag;
241 delete pIcc;
243 }
244 pCurves->SetSize(3);
245 pCurves->SetCurve(0, pCurve->NewCopy());
246 pCurves->SetCurve(1, pCurve->NewCopy());
247 pCurves->SetCurve(2, pCurve->NewCopy());
248 pMpeTag->Attach(pCurves);
249 }
251 if (!pMtx) {
252 delete pMpeTag;
253 delete pIcc;
255 }
256
257 CIccTagFloat32 *pxy;
258 if (!pMtx->SetSize(3,3)) {
259 delete pMtx;
260 delete pMpeTag;
261 delete pIcc;
263 }
264 icFloatNumber *mtx=pMtx->GetMatrix();
265
267 if (!pxy || pxy->GetSize()<2) {
268 delete pMpeTag;
269 delete pIcc;
271 }
272 mtx[0]=(*pxy)[0] * XYZMedia[0];
273 mtx[3]=(*pxy)[1] * XYZMedia[1];
274 mtx[6]=(1.0f - (*pxy)[0] - (*pxy)[1]) * XYZMedia[2];
275
277 if (!pxy || pxy->GetSize()<2) {
278 delete pMpeTag;
279 delete pIcc;
281 }
282 mtx[1]=(*pxy)[0] * XYZMedia[0];
283 mtx[4]=(*pxy)[1] * XYZMedia[1];
284 mtx[7]=(1.0f - (*pxy)[0] - (*pxy)[1]) * XYZMedia[2];
285
287 if (!pxy || pxy->GetSize()<2) {
288 delete pMpeTag;
289 delete pIcc;
291 }
292 mtx[2]=(*pxy)[0] * XYZMedia[0];
293 mtx[5]=(*pxy)[1] * XYZMedia[1];
294 mtx[8]=(1.0f - (*pxy)[0] - (*pxy)[1]) * XYZMedia[2];
295
296 CIccMpeMatrix *pMtx2 = (CIccMpeMatrix*)pMtx->NewCopy();
297 pMpeTag->Attach(pMtx);
298
299 pIcc->AttachTag(icSigAToB3Tag, pMpeTag);
300
301 if (!icMatrixInvert3x3(pMtx2->GetMatrix())) {
302 delete pMtx2;
303 delete pIcc;
305 }
306
307 //Create B2A tag from pParams
309 if (!pMpeTag) {
310 delete pMtx2;
311 delete pIcc;
313 }
314
315 pMpeTag->SetChannels(3, 3);
316
317 pMpeTag->Attach(pMtx2);
318
320 if (pSegCurve && pSegCurve->GetCurve()) {
321 CIccSegmentedCurve *pCurve = pSegCurve->GetCurve();
323 if (!pCurves || !pCurves->SetSize(3)) {
324 delete pMpeTag;
325 delete pIcc;
327 }
328 pCurves->SetCurve(0, pCurve->NewCopy());
329 pCurves->SetCurve(1, pCurve->NewCopy());
330 pCurves->SetCurve(2, pCurve->NewCopy());
331 pMpeTag->Attach(pCurves);
332 }
333
334 if (bHaveLumMtx) {
335 if (!icMatrixInvert3x3(&lumMtx[0])) {
336 delete pMpeTag;
337 delete pIcc;
339 }
340
342 if (!pMtx) {
343 delete pMpeTag;
344 delete pIcc;
346 }
347 pMpeTag->Attach(pMtx);
348 }
349 pIcc->AttachTag(icSigBToA3Tag, pMpeTag);
350
351 //Add ProfileConnectionConditions (if needed)
352 if (pIcc->m_Header.illuminant.X!=icDtoF(icD50XYZ[0]) ||
353 pIcc->m_Header.illuminant.Y!=icDtoF(icD50XYZ[1]) ||
354 pIcc->m_Header.illuminant.Z!=icDtoF(icD50XYZ[2])) {
355
356 //Set Spectral Viewing Conditions
358 if (!pCond) {
359 delete pIcc;
361 }
362
363 icFloatNumber illXYZ[3];
365 pCond->setIlluminant(XYZWhite);
366 //pCond->m_stdIlluminant = icIlluminantCustom;
367 illXYZ[0] = pCond->m_illuminantXYZ.X = Lw * XYZWhite[0];
368 illXYZ[1] = pCond->m_illuminantXYZ.Y = Lw * XYZWhite[1];
369 illXYZ[2] = pCond->m_illuminantXYZ.Z = Lw * XYZWhite[2];
370
373 if (pSurround && pSurround->GetSize()>=2) {
374 icFloatNumber XYZSurround[3];
375 icYxy2XYZVector(XYZSurround, 1, &(*pSurround)[0], 1);
376 pCond->m_surroundXYZ.X = La * XYZSurround[0];
377 pCond->m_surroundXYZ.Y = La * XYZSurround[1];
378 pCond->m_surroundXYZ.Z = La * XYZSurround[2];
379 }
380 else {
381 pCond->m_surroundXYZ.X = La * XYZWhite[0];
382 pCond->m_surroundXYZ.Y = La * XYZWhite[1];
383 pCond->m_surroundXYZ.Z = La * XYZWhite[2];
384 }
385
386 pIcc->AttachTag(icSigSpectralViewingConditionsTag, pCond);
387
388 icFloatNumber Lsw=pParams->GetElemNumberValue(icSigCeptViewingSurroundMbr, Lw/5.0f - 0.001f);
389 CIccCamConverter *pCstmConvert = new CIccCamConverter();
390 if (!pCstmConvert) {
391 delete pIcc;
393 }
394 pCstmConvert->SetParameter_WhitePoint(&illXYZ[0]);
395 pCstmConvert->SetParameter_La(La);
396 pCstmConvert->SetParameter_Yb(Lw);
397
398 icFloatNumber SWr = Lsw / Lw;
399
400 if (SWr>0.2) { //Average Surround
401 pCstmConvert->SetParameter_C(0.69f);
402 pCstmConvert->SetParameter_Nc(1.0f);
403 pCstmConvert->SetParameter_F(1.0f);
404 }
405 else if (SWr>0.0) { //Dim Surround
406 pCstmConvert->SetParameter_C(0.59f);
407 pCstmConvert->SetParameter_Nc(0.95f);
408 pCstmConvert->SetParameter_F(0.9f);
409 }
410 else { //Dark Surround
411 pCstmConvert->SetParameter_C(0.525f);
412 pCstmConvert->SetParameter_Nc(0.8f);
413 pCstmConvert->SetParameter_F(0.8f);
414 }
415
416 CIccCamConverter *pCstmConvert2 = new CIccCamConverter();
417 if (!pCstmConvert2) {
418 delete pCstmConvert;
419 delete pIcc;
421 }
422 *pCstmConvert2 = *pCstmConvert;
423
424 //By default New CIccCamConverter objects are initialized with default PCS conditions
425 CIccCamConverter *pStdConvert = new CIccCamConverter();
426 if (!pStdConvert) {
427 delete pCstmConvert;
428 delete pCstmConvert2;
429 delete pIcc;
431 }
432 CIccCamConverter *pStdConvert2 = new CIccCamConverter();
433 if (!pStdConvert2) {
434 delete pCstmConvert;
435 delete pCstmConvert2;
436 delete pStdConvert;
437 delete pIcc;
439 }
440
441 CIccMpeCAM *pCam;
443 if (!pMpeTag) {
444 delete pCstmConvert;
445 delete pStdConvert;
446 delete pCstmConvert2;
447 delete pStdConvert2;
448 delete pIcc;
450 }
451 pMpeTag->SetChannels(3, 3);
452
454 if (!pCam) {
455 delete pCstmConvert;
456 delete pStdConvert;
457 delete pCstmConvert2;
458 delete pStdConvert2;
459 delete pIcc;
461 }
462 pCam->SetCAM(pCstmConvert);
463 pMpeTag->Attach(pCam);
464
466 if (!pCam) {
467 delete pStdConvert;
468 delete pCstmConvert2;
469 delete pStdConvert2;
470 delete pIcc;
472 }
473 pCam->SetCAM(pStdConvert);
474 pMpeTag->Attach(pCam);
475 pIcc->AttachTag(icSigCustomToStandardPccTag, pMpeTag);
476
478 if (!pMpeTag) {
479 delete pIcc;
481 }
482 pMpeTag->SetChannels(3,3);
483
485 if (!pCam) {
486 delete pCstmConvert2;
487 delete pStdConvert2;
488 delete pIcc;
490 }
491 pCam->SetCAM(pStdConvert2);
492 pMpeTag->Attach(pCam);
493
495 if (!pCam) {
496 delete pCstmConvert2;
497 delete pIcc;
499 }
500 pCam->SetCAM(pCstmConvert2);
501 pMpeTag->Attach(pCam);
502 pIcc->AttachTag(icSigStandardToCustomPccTag, pMpeTag);
503 }
504
505#if 1 && defined(_DEBUG)
506 SaveIccProfile("WEncConv.icc", pIcc);
507#endif
508
509 newIcc = pIcc;
510 return icEncConvertOk;
511}
icFloatNumber icD50XYZ[3]
Definition IccUtil.cpp:782
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
static void icYxy2XYZVector(icFloatNumber *XYZ, icFloatNumber Y, icFloatNumber *xy, icUInt8Number idxOffset=1)
@ icEncConvertBadParams
Definition IccEncoding.h:79
@ icEncConvertOk
Definition IccEncoding.h:75
@ icEncConvertMemoryError
Definition IccEncoding.h:80
bool SaveIccProfile(const icChar *szFilename, CIccProfile *pIcc, icProfileIDSaveMethod nWriteId)
Name: SaveIccProfile.
bool icMatrixInvert3x3(icFloatNumber *M)
Name: icMatrixInvert3x3.
Definition IccUtil.cpp:391
icS15Fixed16Number icDtoF(icFloatNumber num)
Definition IccUtil.cpp:545
void SetParameter_Nc(icFloatNumber Nc)
Definition IccCAM.cpp:402
void SetParameter_La(icFloatNumber La)
Definition IccCAM.cpp:375
void SetParameter_F(icFloatNumber F)
Definition IccCAM.cpp:411
void SetParameter_C(icFloatNumber c)
Definition IccCAM.cpp:393
void SetParameter_Yb(icFloatNumber YB)
Definition IccCAM.cpp:384
void SetParameter_WhitePoint(icFloatNumber *whitePoint)
Definition IccCAM.cpp:364
Class: CIccMpeCAM.
void SetCAM(CIccCamConverter *pCAM)
Class: CIccMpeCurveSet.
bool SetSize(int nNewSize)
Name: CIccMpeCurveSet::SetSize.
bool SetCurve(int nIndex, icCurveSetCurvePtr newCurve)
Name: CIccMpeCurveSet::SetCurve.
Class: CIccMpeMatrix.
icFloatNumber * GetMatrix() const
bool SetSize(icUInt16Number nInputChannels, icUInt16Number nOutputChannels, bool bUseConstants=true)
Name: CIccMpeMatrix::SetSize.
virtual CIccMultiProcessElement * NewCopy() const
static CIccMultiProcessElement * Create(icElemTypeSignature sig)
Name: CIccMultiProcessElement::Create.
Class: CIccSegmentedCurve.
virtual CIccCurveSetCurve * NewCopy() const
Class: CIccTagFloatNum.
virtual bool GetValues(icFloatNumber *DstVector, icUInt32Number nStart=0, icUInt32Number nVectorSize=1) const
Name: CIccTagFloatNum::GetValues.
virtual icUInt32Number GetNumValues() const
icUInt32Number GetSize() const
Returns the size of the data array.
static CIccTag * Create(icTagTypeSignature sig)
Name: CIccTag::Create.
Class: CIccTagMultiProcessElement.
Definition IccTagMPE.h:358
virtual void Attach(CIccMultiProcessElement *pElement)
Name: CIccTagMultiProcessElement::Attach.
void SetChannels(icUInt16Number nInputChannels, icUInt16Number nOutputChannels)
Definition IccTagMPE.h:396
Class: CIccTagSegmentedCurve.
Definition IccTagLut.h:221
CIccSegmentedCurve * GetCurve()
Definition IccTagLut.h:239
Class: CIccTagSpectralViewingConditions.
bool setIlluminant(icIlluminant illumId, const icSpectralRange &illumRange, const icFloatNumber *illum, icFloatNumber illumCCT=0.0f)
CIccTag * FindElemOfType(icSignature sig, icTagTypeSignature sigType)
Name: CIccTagStruct::FindElemOfType.
icFloatNumber GetElemNumberValue(icSignature sig, icFloatNumber defaultValue=0)
Name: CIccTagStruct::GetElemNumberValue.
virtual icStructSignature GetTagStructType() const
Class: CIccTagXYZ.
bool SetSize(icUInt32Number nSize, bool bZeroNew=true)
Name: CIccTagXYZ::SetSize.
@ icSigDisplayClass
@ icSigCeptViewingSurroundMbr
@ icSigCeptLumaChromaMatrixMbr
@ icSigCeptWhitePointLuminanceMbr
@ icSigCeptMediumWhitePointChromaticityMbr
@ icSigCeptRedPrimaryXYZMbr
@ icSigCeptInverseTransferFunctionMbr
@ icSigCeptTransferFunctionMbr
@ icSigCeptAmbientWhitePointChromaticityMbr
@ icSigCeptGreenPrimaryXYZMbr
@ icSigCeptWhitePointChromaticityMbr
@ icSigCeptBluePrimaryXYZMbr
@ icSigCeptAmbientWhitePointLuminanceMbr
#define icSigXYZPcsData
@ icSigCurveSetElemType
@ icSigXYZToJabElemType
@ icSigJabToXYZElemType
@ icSigMatrixElemType
@ icSigSegmentedCurveType
@ icSigMultiProcessElementType
@ icSigSpectralViewingConditionsType
@ icSigFloat32ArrayType
@ icSigColorEncodingParamsSruct
@ icSigSpectralViewingConditionsTag
@ icSigAToB3Tag
@ icSigCustomToStandardPccTag
@ icSigMediaWhitePointTag
@ icSigBToA3Tag
@ icSigStandardToCustomPccTag
icFloat32Number Z
icFloat32Number Y
icFloat32Number X

References CIccTagMultiProcessElement::Attach(), CIccMultiProcessElement::Create(), CIccTag::Create(), CIccTagStruct::FindElemOfType(), CIccTagSegmentedCurve::GetCurve(), CIccTagStruct::GetElemNumberValue(), CIccMpeMatrix::GetMatrix(), CIccTagFloatNum< T, Tsig >::GetNumValues(), CIccTagFloatNum< T, Tsig >::GetSize(), CIccTagStruct::GetTagStructType(), CIccTagFloatNum< T, Tsig >::GetValues(), icD50XYZ, icDtoF(), icEncConvertBadParams, icEncConvertMemoryError, icEncConvertOk, icMatrixInvert3x3(), icSigAToB3Tag, icSigBToA3Tag, icSigCeptAmbientWhitePointChromaticityMbr, icSigCeptAmbientWhitePointLuminanceMbr, icSigCeptBluePrimaryXYZMbr, icSigCeptGreenPrimaryXYZMbr, icSigCeptInverseTransferFunctionMbr, icSigCeptLumaChromaMatrixMbr, icSigCeptMediumWhitePointChromaticityMbr, icSigCeptRedPrimaryXYZMbr, icSigCeptTransferFunctionMbr, icSigCeptViewingSurroundMbr, icSigCeptWhitePointChromaticityMbr, icSigCeptWhitePointLuminanceMbr, icSigColorEncodingParamsSruct, icSigCurveSetElemType, icSigCustomToStandardPccTag, icSigDisplayClass, icSigFloat32ArrayType, icSigJabToXYZElemType, icSigMatrixElemType, icSigMediaWhitePointTag, icSigMultiProcessElementType, icSigSegmentedCurveType, icSigSpectralViewingConditionsTag, icSigSpectralViewingConditionsType, icSigStandardToCustomPccTag, icSigXYZPcsData, icSigXYZToJabElemType, icYxy2XYZVector(), CIccTagSpectralViewingConditions::m_illuminantXYZ, CIccTagSpectralViewingConditions::m_surroundXYZ, CIccMpeMatrix::NewCopy(), CIccSegmentedCurve::NewCopy(), SaveIccProfile(), CIccMpeCAM::SetCAM(), CIccTagMultiProcessElement::SetChannels(), CIccMpeCurveSet::SetCurve(), CIccTagSpectralViewingConditions::setIlluminant(), CIccCamConverter::SetParameter_C(), CIccCamConverter::SetParameter_F(), CIccCamConverter::SetParameter_La(), CIccCamConverter::SetParameter_Nc(), CIccCamConverter::SetParameter_WhitePoint(), CIccCamConverter::SetParameter_Yb(), CIccMpeCurveSet::SetSize(), CIccMpeMatrix::SetSize(), CIccTagXYZ::SetSize(), icFloatXYZNumber::X, icFloatXYZNumber::Y, and icFloatXYZNumber::Z.

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: