94 virtual bool setFile(
const char* szOutputFile) = 0;
98 virtual void setTitle(
const char* szTitle) = 0;
125 virtual bool setFile(
const char* szOutputFile)
165 if (nSrcSamples != 3) {
166 printf(
"# of source Samples is not 3\n");
170 if (nDstSamples != 3) {
171 printf(
"# of destination samples is not 3\n");
177 printf(
"Unable to open '%s'\n",
m_filename.c_str());
181 fprintf(
m_f,
"TITLE \"%s\"\n\n",
m_title.c_str());
183 fprintf(
m_f,
"# cube file created by iccApplyToLink version " ICCPROFLIBVER "\n#\n");
185 fprintf(
m_f,
"# Profiles applied (by profile description):\n");
186 m_pCmm->IterateXforms(
this);
190 fprintf(
m_f,
"LUT_3D_SIZE %d\n",
m_grid);
206 const CIccProfile* pProfile = pXform->GetProfile();
211 fprintf(
m_f,
"# - %s\n", text.c_str());
223 for (
int i = 0; i < 3; i++) {
226 fprintf(
m_f, fmt, pPixel[i]);
266 virtual bool setFile(
const char* szOutputFile)
308 printf(
"Invalid number of source samples\n");
311 if (!nDstSamples || (!
m_bWriteV5 && nDstSamples > 15)) {
312 printf(
"Invalid number of destination samples\n");
318 printf(
"Invalid source color space\n");
322 printf(
"Invalid destination color space\n");
340 pTextTag->
SetText(
"Device link created by iccApplyToLink");
345 pTextTag->
SetText(
"Copyright ICC");
391 m_pCmm->IterateXforms(
this);
460 const CIccProfile* pProfile = pXform->GetProfile();
581 printf(
"iccApplyToLink built with IccProfLib version " ICCPROFLIBVER "\n\n");
583 printf(
"Usage: iccApplyToLink dst_link_file link_type lut_size option title range_min range_max first_transform interp {{-ENV:sig value} profile_file_path rendering_intent {-PCC connection_conditions_path}}\n\n");
584 printf(
" dst_link_file is path of file to create\n\n");
586 printf(
" For link_type:\n");
587 printf(
" 0 - Device Link\n");
588 printf(
" 1 - .cube text file\n\n");
590 printf(
" Where lut_size represents the number of grid entries for each lut dimension.\n\n");
592 printf(
" For option when link_type is 0:\n");
593 printf(
" option represents the digits of precision for lut for .cube files\n");
594 printf(
" For option when link_type is 1:\n");
595 printf(
" 0 - version 4 profile with 16-bit table\n");
596 printf(
" 1 - version 5 profile\n\n");
598 printf(
" title is the title/description for the dest_link_file\n\n");
600 printf(
" range_min specifies the minimum input value (usually 0.0)\n");
601 printf(
" range_max specifies the maximum input value (usually 1.0)\n\n");
603 printf(
" For first_transform:\n");
604 printf(
" 0 - use source transform from first profile\n");
605 printf(
" 1 - use destination transform from first profile\n\n");
607 printf(
" For interp:\n");
608 printf(
" 0 - linear interpolation\n");
609 printf(
" 1 - tetrahedral interpolation\n\n");
611 printf(
" For rendering_intent:\n");
612 printf(
" 0 - Perceptual\n");
613 printf(
" 1 - Relative\n");
614 printf(
" 2 - Saturation\n");
615 printf(
" 3 - Absolute\n");
616 printf(
" 10 - Perceptual without D2Bx/B2Dx\n");
617 printf(
" 11 - Relative without D2Bx/B2Dx\n");
618 printf(
" 12 - Saturation without D2Bx/B2Dx\n");
619 printf(
" 13 - Absolute without D2Bx/B2Dx\n");
620 printf(
" 20 - Preview Perceptual\n");
621 printf(
" 21 - Preview Relative\n");
622 printf(
" 22 - Preview Saturation\n");
623 printf(
" 23 - Preview Absolute\n");
624 printf(
" 30 - Gamut\n");
625 printf(
" 33 - Gamut Absolute\n");
626 printf(
" 40 - Perceptual with BPC\n");
627 printf(
" 41 - Relative Colorimetric with BPC\n");
628 printf(
" 42 - Saturation with BPC\n");
629 printf(
" 50 - BDRF Parameters\n");
630 printf(
" 60 - BDRF Direct\n");
631 printf(
" 70 - BDRF MCS Parameters\n");
632 printf(
" 80 - MCS connection\n");
633 printf(
" +100 - Use Luminance based PCS adjustment\n");
634 printf(
" +1000 - Use V5 sub-profile if present\n");
647 int nNumProfiles, temp;
648 temp = argc - minargs;
652 printf(
"\nMissing arguments!\n");
657 nNumProfiles = temp/2;
668 printf(
"Unable to allocate writer\n");
674 pWriter->setFile(argv[1]);
676 int nLutSize = atoi(argv[3]);
677 pWriter->setLutSize(nLutSize);
679 pWriter->setOption(atoi(argv[4]));
681 pWriter->setTitle(argv[5]);
686 pWriter->setInputRange(loRange, hiRange);
689 bool bFirstTransform = atoi(argv[8]) != 0;
692 int nIntent, nType, nLuminance;
704 bool bUseD2BxB2DxTags;
711 for(i = 0, nCount=minargs; i<nNumProfiles; i++, nCount+=2) {
712#if defined(_WIN32) || defined(_WIN64)
713 if (!
strnicmp(argv[nCount],
"-ENV:", 5)) {
715 if (!strncasecmp(argv[nCount],
"-ENV:", 5)) {
722 else if (
stricmp(argv[nCount],
"-PCC")) {
723 bUseD2BxB2DxTags =
true;
724 nIntent = atoi(argv[nCount+1]);
725 bUseSubProfile = (nIntent / 1000) > 0;
726 nIntent = nIntent % 1000;
727 nLuminance = nIntent / 100;
728 nIntent = nIntent % 100;
729 nType = abs(nIntent) / 10;
730 nIntent = nIntent % 10;
731 CIccProfile *pPccProfile = NULL;
734 CIccCreateXformHintManager Hint;
738 bUseD2BxB2DxTags =
false;
747 Hint.AddHint(
new CIccLuminanceMatchingHint());
751 if (i+1<nNumProfiles && !
stricmp(argv[nCount+2],
"-PCC")) {
754 printf(
"Unable to open Profile Connections Conditions from '%s'\n", argv[nCount+3]);
758 pccList.push_back(pPccProfile);
763 if (sigMap.size()>0) {
768 CIccProfile* pXformProfile =
ReadIccProfile(argv[nCount], bUseSubProfile);
772 printf(
"Invalid Profile(%d): %s\n", stat, argv[nCount]);
781 if((stat=theCmm.Begin())) {
782 printf(
"Error %d - Unable to begin profile application - Possibly invalid or incompatible profiles\n", stat);
786 pWriter->setCmm(&theCmm);
789 IccProfilePtrList::iterator pcc;
790 for (pcc=pccList.begin(); pcc!=pccList.end(); pcc++) {
791 CIccProfile *pPccProfile = *pcc;
796 if (!pWriter->begin(theCmm.GetSourceSpace(), theCmm.GetDestSpace())) {
797 printf(
"Unable to begin writing LUT\n");
809 int* idx =
new int[nSrcSamples];
815 int curPer, lastPer = -1;
819 for (
auto i = 0; i < nSrcSamples; i++) {
821 lutCount *= nLutSize;
825 for (
int c = 0; j >= 0; c++) {
827 for (
auto i = 0; i < nSrcSamples; i++) {
828 srcPixel[i] = sizeRange * (
icFloatNumber)idx[i] / maxLut + loRange;
832 theCmm.Apply(dstPixel, srcPixel);
834 pWriter->setNextNode(dstPixel);
836 for (j = nSrcSamples - 1; j >= 0;) {
838 if (idx[j] >= nLutSize) {
847 curPer = (int)((
float)(c + 1) * 100.0f / (
float)lutCount);
848 if (curPer != lastPer) {
849 printf(
"\r%d%%", curPer);
858 if (pWriter->finish()) {
859 printf(
"\nLUT successfully written to '%s'\n", argv[1]);
862 printf(
"\nUnable to write LUT to '%s'\n", argv[1]);
icXformLutType
CMM Xform LUT types.
icXformInterp
CMM Interpolation types.
icStatusCMM
CMM return status values.
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
std::map< icSignature, icFloatNumber > icCmmEnvSigMap
bool SaveIccProfile(const icChar *szFilename, CIccProfile *pIcc, icProfileIDSaveMethod nWriteId)
Name: SaveIccProfile.
CIccProfile * ReadIccProfile(const icChar *szFilename, bool bUseSubProfile)
Name: ReadIccProfile.
CIccProfile * OpenIccProfile(const icChar *szFilename, bool bUseSubProfile)
Name: OpenIccProfile.
bool icGetTagText(const CIccTag *pTag, std::string &text)
icUInt32Number icGetSpaceSamples(icColorSpaceSignature sig)
bool icIsNear(icFloatNumber v1, icFloatNumber v2, icFloatNumber nearRange)
Name: icIsNear.
bool icIsSpaceCLR(icColorSpaceSignature sig)
icUInt32Number icGetSigVal(const icChar *pBuf)
int main()
Core and external libraries necessary for the fuzzer functionality.
unsigned int icUInt32Number
virtual void setNextNode(icFloatNumber *pPixel)
virtual bool setFile(const char *szOutputFile)
icFloatNumber m_fMinInput
virtual void setTitle(const char *szTitle)
virtual void setInputRange(icFloatNumber fMinInput, icFloatNumber fMaxInput)
virtual bool begin(icColorSpaceSignature srcSpace, icColorSpaceSignature dstSpace)
virtual void setCmm(CIccCmm *pCmm)
icFloatNumber m_fMaxInput
virtual bool setLutSize(icUInt8Number nGridSize)
virtual void setOption(int nOptionValue)
virtual void iterate(const CIccXform *pXform)
icFloatNumber * m_pLutPtr
virtual void setOption(int nOptionValue)
virtual void setNextNode(icFloatNumber *pPixel)
virtual bool setLutSize(icUInt8Number nGridSize)
icUInt32Number m_nCountdown
const CIccProfile * m_pLastProfile
virtual ~CDevLinkWriter()
icUInt16Number m_nOutSamples
CIccTagProfileSeqDesc * m_pTagSeq
icFloatNumber m_fMinInput
virtual void iterate(const CIccXform *pXform)
virtual void setCmm(CIccCmm *pCmm)
virtual void setTitle(const char *szTitle)
const CIccProfile * m_pFirstProfile
virtual bool setFile(const char *szOutputFile)
icFloatNumber m_fMaxInput
std::string m_description
virtual bool begin(icColorSpaceSignature srcSpace, icColorSpaceSignature dstSpace)
virtual void setInputRange(icFloatNumber fMinInput, icFloatNumber fMaxInput)
icUInt32Number NumPoints() const
icFloatNumber * GetData(int index)
bool Init(icUInt8Number nGridPoints, icUInt32Number nMaxSize=0, icUInt8Number nBytesPerPoint=4)
Name: CIccCLUT::Init.
bool IsValidSpace(icColorSpaceSignature sig)
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.
void SetCLUT(CIccCLUT *pCLUT)
Name: CIccMpeCLUT::SetCLUT.
bool SetCurve(int nIndex, icCurveSetCurvePtr newCurve)
Name: CIccMpeCurveSet::SetCurve.
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.
Class: CIccSingleSampledCurve.
virtual icFloatNumber * GetSamples()
virtual bool SetSize(icUInt32Number nSize, bool bZeroAlloc=true)
Name: CIccSingleSampledCurve::SetSize.
virtual icTagTypeSignature GetType() const
Function: GetType()
virtual CIccTag * NewCopy() const
Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
Class: CIccTagMultiLocalizedUnicode.
void SetText(const icChar *szText, icLanguageCode nLanguageCode=icLanguageCodeEnglish, icCountryCode nRegionCode=icCountryCodeUSA)
Name: refIccMAX::CIccTagMultiLocalizedUnicode::SetText.
Class: CIccTagMultiProcessElement.
virtual void Attach(CIccMultiProcessElement *pElement)
Name: CIccTagMultiProcessElement::Attach.
Class: CIccTagProfileSeqDesc.
CIccProfileSeqDesc * m_Descriptions
icUInt32Number GetValue() const
Class: CIccTagTextDescription()
virtual void setInputRange(icFloatNumber fMinInput, icFloatNumber fMaxInput)=0
virtual bool setLutSize(icUInt8Number nGridSize)=0
virtual void setTitle(const char *szTitle)=0
virtual void setCmm(CIccCmm *pCmm)=0
virtual bool begin(icColorSpaceSignature srcSpace, icColorSpaceSignature dstSpace)=0
virtual bool setFile(const char *szOutputFile)=0
virtual void setOption(int nOptionValue)=0
virtual void setNextNode(icFloatNumber *pPixel)=0
std::list< CIccProfile * > IccProfilePtrList
std::shared_ptr< ILinkWriter > LinkWriterPtr
std::list< CIccProfile * > IccProfilePtrList