Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
iccFromCube.cpp File Reference
#include <stdio.h>
#include <string>
#include "IccProfile.h"
#include "IccTagBasic.h"
#include "IccTagMPE.h"
#include "IccMpeBasic.h"
#include "IccProfLibVer.h"
#include "IccUtil.h"
+ Include dependency graph for iccFromCube.cpp:

Go to the source code of this file.

Classes

class  CubeFile
 

Macros

#define MAX_LINE_LEN   255
 

Functions

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

Macro Definition Documentation

◆ MAX_LINE_LEN

#define MAX_LINE_LEN   255

Definition at line 300 of file iccFromCube.cpp.

Referenced by CubeFile::getNextLine().

Function Documentation

◆ main()

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

Definition at line 333 of file iccFromCube.cpp.

334{
335 int nArg = 1;
336 long int verbosity = 100; // default is maximum verbosity (old behaviour)
337
338 if (argc <= 2) {
339 printf("Usage: iccFromCube cube_file output_icc_file\n");
340 printf("Built with IccProfLib version " ICCPROFLIBVER "\n");
341
342 return -1;
343 }
344
345 CubeFile cube(argv[1]);
346
347 if (!cube.parseHeader()) {
348 printf("Unable to parse '%s'\n", argv[1]);
349 return -2;
350 }
351
352 if (!cube.sizeLut3D()) {
353 printf("3DLUT not found in '%s'\n", argv[1]);
354 return -3;
355 }
356
357 CIccProfile profile;
358
359 //Initialize profile header
360 profile.InitHeader();
361 profile.m_Header.version = icVersionNumberV5;
362 profile.m_Header.colorSpace = icSigRgbData;
363 profile.m_Header.pcs = icSigRgbData;
364 profile.m_Header.deviceClass = icSigLinkClass;
365
366 //Create A2B0 Tag with LUT
368 if (cube.isCustomInputRange()) {
369 icFloatNumber* minVal = cube.getMinInput();
370 icFloatNumber* maxVal = cube.getMaxInput();
371 CIccMpeCurveSet* pCurves = new CIccMpeCurveSet(3);
372 CIccSingleSampledCurve* pCurve0 = new CIccSingleSampledCurve(minVal[0], maxVal[0]);
373
374 pCurve0->SetSize(2);
375 pCurve0->GetSamples()[0] = 0;
376 pCurve0->GetSamples()[1] = 1;
377
378 pCurves->SetCurve(0, pCurve0);
379
380 CIccSingleSampledCurve* pCurve1 = pCurve0;
381 if (minVal[1] != minVal[0] || maxVal[1] != maxVal[0]) {
382 pCurve1 = new CIccSingleSampledCurve(minVal[1], maxVal[1]);
383
384 pCurve1->SetSize(2);
385 pCurve1->GetSamples()[0] = 0;
386 pCurve1->GetSamples()[1] = 1;
387 }
388
389 pCurves->SetCurve(1, pCurve1);
390
391 CIccSingleSampledCurve* pCurve2 = pCurve0;
392
393 if (minVal[2] != minVal[0] || maxVal[2] != maxVal[0]) {
394 if (minVal[2] == minVal[1] && maxVal[2] == maxVal[1])
395 pCurve2 = pCurve1;
396 else {
397 pCurve2 = new CIccSingleSampledCurve(minVal[2], maxVal[2]);
398
399 pCurve2->SetSize(2);
400 pCurve2->GetSamples()[0] = 0;
401 pCurve2->GetSamples()[1] = 1;
402 }
403 }
404
405 pCurves->SetCurve(2, pCurve2);
406
407 pTag->Attach(pCurves);
408 }
409
410 CIccMpeCLUT* pMpeCLUT = new CIccMpeCLUT();
411 CIccCLUT* pCLUT = new CIccCLUT(3, 3);
412 pCLUT->Init(cube.sizeLut3D());
413 bool bSuccess = cube.parse3DTable(pCLUT->GetData(0), pCLUT->NumPoints()*3);
414
415 pMpeCLUT->SetCLUT(pCLUT);
416 pTag->Attach(pMpeCLUT);
417
418 profile.AttachTag(icSigAToB0Tag, pTag);
419
420 cube.close();
421
422 if (!bSuccess) {
423 printf("Unable to parse LUT from '%s'\n", argv[1]);
424 return (-4);
425 }
426
427 //Add description Tag
429 std::string desc = cube.getDescription();
430 if (desc.size()) {
431 pTextTag->SetText(desc.c_str());
432 }
433 else {
434 pTextTag->SetText((std::string("Device link created from ") + argv[1]).c_str());
435 }
436 profile.AttachTag(icSigProfileDescriptionTag, pTextTag);
437
438
439 //Add copyright Tag
440 if (cube.getCopyright().size()) {
441 pTextTag = new CIccTagMultiLocalizedUnicode();
442 pTextTag->SetText(cube.getCopyright().c_str());
443 profile.AttachTag(icSigCopyrightTag, pTextTag);
444 }
445
446 if (SaveIccProfile(argv[2], &profile)) {
447 printf("'%s' successfully created\n", argv[2]);
448 }
449 else {
450 printf("Unable to save profile '%s'\n", argv[2]);
451 return -5;
452 }
453
454 return 0;
455}
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.
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: 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: 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.
@ icSigLinkClass
@ icSigRgbData
#define icVersionNumberV5
@ icSigAToB0Tag
@ icSigProfileDescriptionTag
@ icSigCopyrightTag

References CIccTagMultiProcessElement::Attach(), CubeFile::close(), CubeFile::getCopyright(), CIccCLUT::GetData(), CubeFile::getDescription(), CubeFile::getMaxInput(), CubeFile::getMinInput(), CIccSingleSampledCurve::GetSamples(), ICCPROFLIBVER, icSigAToB0Tag, icSigCopyrightTag, icSigLinkClass, icSigProfileDescriptionTag, icSigRgbData, icVersionNumberV5, CIccCLUT::Init(), CubeFile::isCustomInputRange(), CIccCLUT::NumPoints(), CubeFile::parse3DTable(), CubeFile::parseHeader(), SaveIccProfile(), CIccMpeCLUT::SetCLUT(), CIccMpeCurveSet::SetCurve(), CIccSingleSampledCurve::SetSize(), CIccTagMultiLocalizedUnicode::SetText(), and CubeFile::sizeLut3D().

+ Here is the call graph for this function: