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

Public Member Functions

virtual bool begin (icColorSpaceSignature srcSpace, icColorSpaceSignature dstSpace)
 
 CDevLinkWriter ()
 
virtual bool finish ()
 
virtual void iterate (const CIccXform *pXform)
 
virtual void setCmm (CIccCmm *pCmm)
 
virtual bool setFile (const char *szOutputFile)
 
virtual void setInputRange (icFloatNumber fMinInput, icFloatNumber fMaxInput)
 
virtual bool setLutSize (icUInt8Number nGridSize)
 
virtual void setNextNode (icFloatNumber *pPixel)
 
virtual void setOption (int nOptionValue)
 
virtual void setTitle (const char *szTitle)
 
virtual ~CDevLinkWriter ()
 

Protected Attributes

bool m_bWriteV5 = true
 
std::string m_description
 
std::string m_filename
 
icFloatNumber m_fMaxInput = 1.0
 
icFloatNumber m_fMinInput = 0.0
 
int m_grid = 0
 
icUInt32Number m_nCountdown = 0
 
icUInt16Number m_nOutSamples
 
CIccCmm * m_pCmm = nullptr
 
const CIccProfile * m_pFirstProfile = nullptr
 
const CIccProfile * m_pLastProfile = nullptr
 
icFloatNumberm_pLutPtr = nullptr
 
CIccProfile * m_pProfile = nullptr
 
CIccTagProfileSeqDescm_pTagSeq = nullptr
 
std::string m_title
 

Detailed Description

Definition at line 256 of file iccApplyToLink.cpp.

Constructor & Destructor Documentation

◆ CDevLinkWriter()

CDevLinkWriter::CDevLinkWriter ( )
inline

Definition at line 259 of file iccApplyToLink.cpp.

259{ }

◆ ~CDevLinkWriter()

virtual CDevLinkWriter::~CDevLinkWriter ( )
inlinevirtual

Definition at line 260 of file iccApplyToLink.cpp.

261 {
262 if (m_pProfile)
263 delete m_pProfile;
264 }

References m_pProfile.

Member Function Documentation

◆ begin()

virtual bool CDevLinkWriter::begin ( icColorSpaceSignature srcSpace,
icColorSpaceSignature dstSpace )
inlinevirtual

Implements ILinkWriter.

Definition at line 301 of file iccApplyToLink.cpp.

302 {
303 icUInt16Number nSrcSamples = (icUInt16Number)icGetSpaceSamples(srcSpace);
304 icUInt16Number nDstSamples = (icUInt16Number)icGetSpaceSamples(dstSpace);
305 m_nOutSamples = nDstSamples;
306
307 if (!nSrcSamples || (!m_bWriteV5 && nSrcSamples > 15) || (m_bWriteV5 && nSrcSamples > 16)) {
308 printf("Invalid number of source samples\n");
309 return false;
310 }
311 if (!nDstSamples || (!m_bWriteV5 && nDstSamples > 15)) {
312 printf("Invalid number of destination samples\n");
313 return false;
314 }
315
316 CIccInfo Info;
317 if (!Info.IsValidSpace(srcSpace)) {
318 printf("Invalid source color space\n");
319 return false;
320 }
321 if (!Info.IsValidSpace(dstSpace)) {
322 printf("Invalid destination color space\n");
323 return false;
324 }
325
326 m_pProfile = new CIccProfile();
327
328 //Initialize profile header
329 m_pProfile->InitHeader();
330 m_pProfile->m_Header.colorSpace = srcSpace;
331 m_pProfile->m_Header.pcs = dstSpace;
332 m_pProfile->m_Header.deviceClass = icSigLinkClass;
333
334 //Add description Tag
336 if (m_title.size()) {
337 pTextTag->SetText(m_title.c_str());
338 }
339 else {
340 pTextTag->SetText("Device link created by iccApplyToLink");
341 }
342 m_pProfile->AttachTag(icSigProfileDescriptionTag, pTextTag);
343
344 pTextTag = new CIccTagMultiLocalizedUnicode();
345 pTextTag->SetText("Copyright ICC");
346 m_pProfile->AttachTag(icSigCopyrightTag, pTextTag);
347
348 if (m_bWriteV5) {
349 m_pProfile->m_Header.version = icVersionNumberV5;
350
351 //Create A2B0 Tag with LUT
352 CIccTagMultiProcessElement* pTag = new CIccTagMultiProcessElement(nSrcSamples, nDstSamples);
353
354 if (!icIsNear(m_fMinInput, 0.0) || !icIsNear(m_fMaxInput, 1.0)) {
355 CIccMpeCurveSet* pCurves = new CIccMpeCurveSet(nSrcSamples);
357
358 pCurve0->SetSize(2);
359 pCurve0->GetSamples()[0] = 0;
360 pCurve0->GetSamples()[1] = 1;
361
362 pCurves->SetCurve(0, pCurve0);
363
364 for (icUInt16Number i = 1; i < nSrcSamples; i++) {
365 pCurves->SetCurve(1, pCurve0);
366 }
367
368 pTag->Attach(pCurves);
369 }
370
371 CIccMpeCLUT* pMpeCLUT = new CIccMpeCLUT();
372 CIccCLUT* pCLUT = new CIccCLUT((icUInt8Number)nSrcSamples, (icUInt8Number)nDstSamples);
373 pCLUT->Init(m_grid);
374 m_pLutPtr = pCLUT->GetData(0);
375 m_nCountdown = pCLUT->NumPoints();
376
377 pMpeCLUT->SetCLUT(pCLUT);
378 pTag->Attach(pMpeCLUT);
379
380 m_pProfile->AttachTag(icSigAToB0Tag, pTag);
381 }
382 else {
383 m_pProfile->m_Header.version = icVersionNumberV4_3;
384
385 m_pFirstProfile = nullptr;
386 m_pLastProfile = nullptr;
387
389
390 if (m_pCmm) {
391 m_pCmm->IterateXforms(this);
392 }
393
396 }
397 else {
398 delete m_pTagSeq;
399 m_pTagSeq = nullptr;
400 }
401
402 if (icIsSpaceCLR(srcSpace) && m_pFirstProfile) {
403 if (m_pFirstProfile->m_Header.version < icVersionNumberV5) {
404 const CIccTag* pTagColor = m_pFirstProfile->FindTagConst(icSigColorantTableTag);
405 if (pTagColor) {
406 m_pProfile->AttachTag(icSigColorantTableTag, pTagColor->NewCopy());
407 }
408 }
409 else if (m_pFirstProfile->m_Header.version >= icVersionNumberV5) {
410
411 }
412 }
413
414 if (icIsSpaceCLR(dstSpace) && m_pLastProfile) {
415 if (m_pLastProfile->m_Header.deviceClass == icSigLinkClass) {
416 if (m_pLastProfile->m_Header.version < icVersionNumberV5) {
417 const CIccTag* pTagColor = m_pLastProfile->FindTagConst(icSigColorantTableOutTag);
418 if (pTagColor) {
419 m_pProfile->AttachTag(icSigColorantTableTag, pTagColor->NewCopy());
420 }
421 }
422 else if (m_pLastProfile->m_Header.version >= icVersionNumberV5) {
423
424 }
425 }
426 else if (m_pLastProfile->m_Header.version < icVersionNumberV5) {
427 const CIccTag* pTagColor = m_pLastProfile->FindTagConst(icSigColorantTableTag);
428 if (pTagColor) {
429 m_pProfile->AttachTag(icSigColorantTableOutTag, pTagColor->NewCopy());
430 }
431 }
432 else if (m_pLastProfile->m_Header.version >= icVersionNumberV5) {
433
434 }
435 }
436
437 CIccTagLutAtoB* pTagLut = new CIccTagLutAtoB();
438 pTagLut->Init((icUInt8Number)nSrcSamples, (icUInt8Number)nDstSamples);
439 LPIccCurve *pCurves = pTagLut->NewCurvesA();
440 for (icUInt16Number i = 0; i < nSrcSamples; i++) {
441 pCurves[i] = new CIccTagCurve();
442 }
443 pCurves = pTagLut->NewCurvesB();
444 for (icUInt16Number i = 0; i < nDstSamples; i++) {
445 pCurves[i] = new CIccTagCurve();
446 }
447 CIccCLUT* pCLUT = pTagLut->NewCLUT(m_grid);
448 m_pLutPtr = pCLUT->GetData(0);
449 m_nCountdown = pCLUT->NumPoints();
450
451 m_pProfile->AttachTag(icSigAToB0Tag, pTagLut);
452 }
453
454 return true;
455 }
icUInt32Number icGetSpaceSamples(icColorSpaceSignature sig)
Definition IccUtil.cpp:1303
bool icIsNear(icFloatNumber v1, icFloatNumber v2, icFloatNumber nearRange)
Name: icIsNear.
Definition IccUtil.cpp:142
bool icIsSpaceCLR(icColorSpaceSignature sig)
Definition IccUtil.cpp:262
Class: CIccCLUT.
Definition IccTagLut.h:326
icUInt32Number NumPoints() const
Definition IccTagLut.h:348
icFloatNumber * GetData(int index)
Definition IccTagLut.h:347
bool Init(icUInt8Number nGridPoints, icUInt32Number nMaxSize=0, icUInt8Number nBytesPerPoint=4)
Name: CIccCLUT::Init.
Class: CIccCurve.
Definition IccTagLut.h:91
Type: Class.
Definition IccUtil.h:303
bool IsValidSpace(icColorSpaceSignature sig)
Definition IccUtil.cpp:2531
LPIccCurve * NewCurvesB()
Name: CIccMBB::NewCurvesB.
LPIccCurve * NewCurvesA()
Name: CIccMBB::NewCurvesA.
CIccCLUT * NewCLUT(icUInt8Number nGridPoints, icUInt8Number nPrecision=2)
Name: CIccMBB::NewCLUT.
void Init(icUInt8Number nInputChannels, icUInt8Number nOutputChannels)
Name: CIccMBB::Init.
Class: CIccMpeCLUT.
void SetCLUT(CIccCLUT *pCLUT)
Name: CIccMpeCLUT::SetCLUT.
Class: CIccMpeCurveSet.
bool SetCurve(int nIndex, icCurveSetCurvePtr newCurve)
Name: CIccMpeCurveSet::SetCurve.
Class: CIccSingleSampledCurve.
virtual icFloatNumber * GetSamples()
virtual bool SetSize(icUInt32Number nSize, bool bZeroAlloc=true)
Name: CIccSingleSampledCurve::SetSize.
Class: CIccTagCurve.
Definition IccTagLut.h:128
Class: CIccTag.
virtual CIccTag * NewCopy() const
Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
Class: CIccTagLutAtoB.
Definition IccTagLut.h:502
Class: CIccTagMultiLocalizedUnicode.
void SetText(const icChar *szText, icLanguageCode nLanguageCode=icLanguageCodeEnglish, icCountryCode nRegionCode=icCountryCodeUSA)
Name: refIccMAX::CIccTagMultiLocalizedUnicode::SetText.
Class: CIccTagMultiProcessElement.
Definition IccTagMPE.h:358
virtual void Attach(CIccMultiProcessElement *pElement)
Name: CIccTagMultiProcessElement::Attach.
Class: CIccTagProfileSeqDesc.
CIccProfileSeqDesc * m_Descriptions
unsigned char icUInt8Number
Number definitions.
#define icVersionNumberV4_3
unsigned short icUInt16Number
@ icSigLinkClass
#define icVersionNumberV5
@ icSigAToB0Tag
@ icSigColorantTableTag
@ icSigProfileSequenceDescTag
@ icSigProfileDescriptionTag
@ icSigCopyrightTag
@ icSigColorantTableOutTag

References CIccTagMultiProcessElement::Attach(), CIccCLUT::GetData(), CIccSingleSampledCurve::GetSamples(), icGetSpaceSamples(), icIsNear(), icIsSpaceCLR(), icSigAToB0Tag, icSigColorantTableOutTag, icSigColorantTableTag, icSigCopyrightTag, icSigLinkClass, icSigProfileDescriptionTag, icSigProfileSequenceDescTag, icVersionNumberV4_3, icVersionNumberV5, CIccCLUT::Init(), CIccMBB::Init(), CIccInfo::IsValidSpace(), m_bWriteV5, CIccTagProfileSeqDesc::m_Descriptions, m_fMaxInput, m_fMinInput, m_grid, m_nCountdown, m_nOutSamples, m_pCmm, m_pFirstProfile, m_pLastProfile, m_pLutPtr, m_pProfile, m_pTagSeq, m_title, CIccMBB::NewCLUT(), CIccTag::NewCopy(), CIccMBB::NewCurvesA(), CIccMBB::NewCurvesB(), CIccCLUT::NumPoints(), CIccMpeCLUT::SetCLUT(), CIccMpeCurveSet::SetCurve(), CIccSingleSampledCurve::SetSize(), and CIccTagMultiLocalizedUnicode::SetText().

+ Here is the call graph for this function:

◆ finish()

virtual bool CDevLinkWriter::finish ( )
inlinevirtual

Implements ILinkWriter.

Definition at line 534 of file iccApplyToLink.cpp.

535 {
536 bool rv = false;
537 if (m_pProfile) {
538 rv = SaveIccProfile(m_filename.c_str(), m_pProfile);
539 delete m_pProfile;
540 }
541
542 m_pProfile = nullptr;
543
544 return rv;
545 }
bool SaveIccProfile(const icChar *szFilename, CIccProfile *pIcc, icProfileIDSaveMethod nWriteId)
Name: SaveIccProfile.

References m_filename, m_pProfile, and SaveIccProfile().

+ Here is the call graph for this function:

◆ iterate()

virtual void CDevLinkWriter::iterate ( const CIccXform * pXform)
inlinevirtual

Definition at line 457 of file iccApplyToLink.cpp.

458 {
459 if (pXform) {
460 const CIccProfile* pProfile = pXform->GetProfile();
461 if (pProfile) {
462 if (!m_pFirstProfile)
463 m_pFirstProfile = pProfile;
464 m_pLastProfile = pProfile;
465
466 if (!m_bWriteV5 && m_pTagSeq) {
468
469 psd.m_deviceMfg = pProfile->m_Header.manufacturer;
470 psd.m_deviceModel = pProfile->m_Header.model;
471 psd.m_attributes = pProfile->m_Header.attributes;
472 const CIccTag* pTag = pProfile->FindTagConst(icSigTechnologyTag);
473 if (pTag && pTag->GetType() == icSigSignatureType) {
474 const CIccTagSignature* pSigTag = (const CIccTagSignature*)pTag;
475
477 }
478
479 pTag = pProfile->FindTagConst(icSigDeviceMfgDescTag);
480 if (pTag) {
481 if (pTag->GetType() == icSigTextDescriptionType) {
482 const CIccTagTextDescription* pTextTag = (const CIccTagTextDescription*)pTag;
483
486 if (pText)
487 *pText = *pTextTag;
488 }
489 else if (pTag->GetType() == icSigMultiLocalizedUnicodeType) {
490 const CIccTagMultiLocalizedUnicode* pTextTag = (const CIccTagMultiLocalizedUnicode*)pTag;
491
494 if (pText)
495 *pText = *pTextTag;
496 }
497 }
498
499 pTag = pProfile->FindTagConst(icSigDeviceModelDescTag);
500 if (pTag) {
501 if (pTag->GetType() == icSigTextDescriptionType) {
502 const CIccTagTextDescription* pTextTag = (const CIccTagTextDescription*)pTag;
503
506 if (pText)
507 *pText = *pTextTag;
508 }
509 else if (pTag->GetType() == icSigMultiLocalizedUnicodeType) {
510 const CIccTagMultiLocalizedUnicode* pTextTag = (const CIccTagMultiLocalizedUnicode*)pTag;
511
514 if (pText)
515 *pText = *pTextTag;
516 }
517 }
518
519 m_pTagSeq->m_Descriptions->push_back(psd);
520 }
521 }
522 }
523 }
Data Class: CIccProfileDescStruct.
CIccProfileDescText m_deviceMfgDesc
icSignature m_deviceModel
icTechnologySignature m_technology
CIccProfileDescText m_deviceModelDesc
icUInt64Number m_attributes
bool SetType(icTagTypeSignature nType)
Name: CIccProfileDescText::SetType.
CIccTag * GetTag() const
virtual icTagTypeSignature GetType() const
Function: GetType()
Class: CIccTagSignature.
icUInt32Number GetValue() const
Class: CIccTagTextDescription()
icTechnologySignature
technology signature descriptions
@ icSigMultiLocalizedUnicodeType
@ icSigTextDescriptionType
@ icSigSignatureType
@ icSigDeviceMfgDescTag
@ icSigDeviceModelDescTag
@ icSigTechnologyTag

References CIccProfileDescText::GetTag(), CIccTag::GetType(), CIccTagSignature::GetValue(), icSigDeviceMfgDescTag, icSigDeviceModelDescTag, icSigMultiLocalizedUnicodeType, icSigSignatureType, icSigTechnologyTag, icSigTextDescriptionType, CIccProfileDescStruct::m_attributes, m_bWriteV5, CIccTagProfileSeqDesc::m_Descriptions, CIccProfileDescStruct::m_deviceMfg, CIccProfileDescStruct::m_deviceMfgDesc, CIccProfileDescStruct::m_deviceModel, CIccProfileDescStruct::m_deviceModelDesc, m_pFirstProfile, m_pLastProfile, m_pTagSeq, CIccProfileDescStruct::m_technology, and CIccProfileDescText::SetType().

+ Here is the call graph for this function:

◆ setCmm()

virtual void CDevLinkWriter::setCmm ( CIccCmm * pCmm)
inlinevirtual

Implements ILinkWriter.

Definition at line 283 of file iccApplyToLink.cpp.

284 {
285 m_pCmm = pCmm;
286 }

References m_pCmm.

◆ setFile()

virtual bool CDevLinkWriter::setFile ( const char * szOutputFile)
inlinevirtual

Implements ILinkWriter.

Definition at line 266 of file iccApplyToLink.cpp.

267 {
268 m_filename = szOutputFile;
269
270 return true;
271 }

References m_filename.

◆ setInputRange()

virtual void CDevLinkWriter::setInputRange ( icFloatNumber fMinInput,
icFloatNumber fMaxInput )
inlinevirtual

Implements ILinkWriter.

Definition at line 295 of file iccApplyToLink.cpp.

296 {
297 m_fMinInput = fMinInput;
298 m_fMaxInput = fMaxInput;
299 }

References m_fMaxInput, and m_fMinInput.

◆ setLutSize()

virtual bool CDevLinkWriter::setLutSize ( icUInt8Number nGridSize)
inlinevirtual

Implements ILinkWriter.

Definition at line 288 of file iccApplyToLink.cpp.

289 {
290 m_grid = nGridSize;
291
292 return true;
293 }

References m_grid.

◆ setNextNode()

virtual void CDevLinkWriter::setNextNode ( icFloatNumber * pPixel)
inlinevirtual

Implements ILinkWriter.

Definition at line 525 of file iccApplyToLink.cpp.

526 {
527 if (m_nCountdown) {
528 memcpy(m_pLutPtr, pPixel, m_nOutSamples * sizeof(icFloatNumber));
530 m_nCountdown--;
531 }
532 }
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100

References m_nCountdown, m_nOutSamples, and m_pLutPtr.

◆ setOption()

virtual void CDevLinkWriter::setOption ( int nOptionValue)
inlinevirtual

Implements ILinkWriter.

Definition at line 273 of file iccApplyToLink.cpp.

274 {
275 m_bWriteV5 = nOptionValue != 0;
276 }

References m_bWriteV5.

◆ setTitle()

virtual void CDevLinkWriter::setTitle ( const char * szTitle)
inlinevirtual

Implements ILinkWriter.

Definition at line 278 of file iccApplyToLink.cpp.

279 {
280 m_title = szTitle;
281 }

References m_title.

Member Data Documentation

◆ m_bWriteV5

bool CDevLinkWriter::m_bWriteV5 = true
protected

Definition at line 549 of file iccApplyToLink.cpp.

Referenced by begin(), iterate(), and setOption().

◆ m_description

std::string CDevLinkWriter::m_description
protected

Definition at line 552 of file iccApplyToLink.cpp.

◆ m_filename

std::string CDevLinkWriter::m_filename
protected

Definition at line 548 of file iccApplyToLink.cpp.

Referenced by finish(), and setFile().

◆ m_fMaxInput

icFloatNumber CDevLinkWriter::m_fMaxInput = 1.0
protected

Definition at line 559 of file iccApplyToLink.cpp.

Referenced by begin(), and setInputRange().

◆ m_fMinInput

icFloatNumber CDevLinkWriter::m_fMinInput = 0.0
protected

Definition at line 558 of file iccApplyToLink.cpp.

Referenced by begin(), and setInputRange().

◆ m_grid

int CDevLinkWriter::m_grid = 0
protected

Definition at line 556 of file iccApplyToLink.cpp.

Referenced by begin(), and setLutSize().

◆ m_nCountdown

icUInt32Number CDevLinkWriter::m_nCountdown = 0
protected

Definition at line 562 of file iccApplyToLink.cpp.

Referenced by begin(), and setNextNode().

◆ m_nOutSamples

icUInt16Number CDevLinkWriter::m_nOutSamples
protected

Definition at line 564 of file iccApplyToLink.cpp.

Referenced by begin(), and setNextNode().

◆ m_pCmm

CIccCmm* CDevLinkWriter::m_pCmm = nullptr
protected

Definition at line 554 of file iccApplyToLink.cpp.

Referenced by begin(), and setCmm().

◆ m_pFirstProfile

const CIccProfile* CDevLinkWriter::m_pFirstProfile = nullptr
protected

Definition at line 569 of file iccApplyToLink.cpp.

Referenced by begin(), and iterate().

◆ m_pLastProfile

const CIccProfile* CDevLinkWriter::m_pLastProfile = nullptr
protected

Definition at line 570 of file iccApplyToLink.cpp.

Referenced by begin(), and iterate().

◆ m_pLutPtr

icFloatNumber* CDevLinkWriter::m_pLutPtr = nullptr
protected

Definition at line 561 of file iccApplyToLink.cpp.

Referenced by begin(), and setNextNode().

◆ m_pProfile

CIccProfile* CDevLinkWriter::m_pProfile = nullptr
protected

Definition at line 566 of file iccApplyToLink.cpp.

Referenced by begin(), finish(), and ~CDevLinkWriter().

◆ m_pTagSeq

CIccTagProfileSeqDesc* CDevLinkWriter::m_pTagSeq = nullptr
protected

Definition at line 572 of file iccApplyToLink.cpp.

Referenced by begin(), and iterate().

◆ m_title

std::string CDevLinkWriter::m_title
protected

Definition at line 550 of file iccApplyToLink.cpp.

Referenced by begin(), and setTitle().


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