Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CIccTagCurve Class Reference

Class: CIccTagCurve. More...

#include <IccTagLut.h>

+ Inheritance diagram for CIccTagCurve:
+ Collaboration diagram for CIccTagCurve:

Public Member Functions

virtual icFloatNumber Apply (icFloatNumber v) const
 Name: CIccTagCurve::Apply.
 
virtual void Begin ()
 
 CIccTagCurve (const CIccTagCurve &ITCurve)
 Name: CIccTagCurve::CIccTagCurve.
 
 CIccTagCurve (int nSize=0)
 Name: CIccTagCurve::CIccTagCurve.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccTagCurve::Describe.
 
virtual void DumpLut (std::string &sDescription, const icChar *szName, icColorSpaceSignature csSig, int nIndex, int nVerboseness)
 Name: CIccTagCurve::DumpLut.
 
virtual const icCharGetClassName () const
 
icFloatNumberGetData (icUInt32Number index)
 
icUInt32Number GetSize () const
 
virtual icTagTypeSignature GetType () const
 Function: GetType()
 
virtual bool IsIdentity ()
 Name: CIccTagCurve::IsIdentity.
 
virtual CIccTagNewCopy () const
 Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
 
CIccTagCurveoperator= (const CIccTagCurve &CurveTag)
 Name: CIccTagCurve::operator=.
 
icFloatNumberoperator[] (icUInt32Number index)
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccTagCurve::Read.
 
bool SetGamma (icFloatNumber gamma)
 Name: refIccMAX::CIccTagCurve::SetGamma.
 
bool SetSize (icUInt32Number nSize, icTagCurveSizeInit nSizeOpt=icInitZero)
 Name: CIccTagCurve::SetSize.
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccProfile *pProfile=NULL) const
 Name: CIccTagCurve::Validate.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccTagCurve::Write.
 
virtual ~CIccTagCurve ()
 Name: CIccTagCurve::~CIccTagCurve.
 
- Public Member Functions inherited from CIccCurve
 CIccCurve ()
 
icFloatNumber Find (icFloatNumber v)
 
virtual ~CIccCurve ()
 
- Public Member Functions inherited from CIccTag
 CIccTag ()
 Name: CIccTag::CIccTag.
 
virtual void DetachIO ()
 Function: ReadAll() - Read All sub data for tag from file.
 
virtual IIccExtensionTagGetExtension ()
 
virtual icArraySignature GetTagArrayType () const
 
virtual icStructSignature GetTagStructType () const
 
virtual bool IsArrayType ()
 
virtual bool IsMBBType ()
 
virtual bool IsNumArrayType () const
 
virtual bool IsSupported ()
 Function: IsSupported(size, pIO) - Check if tag fully supported for apply purposes.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO, CIccProfile *pProfile)
 Function: Read(size, pIO) - Read tag from file.
 
virtual bool ReadAll ()
 Function: ReadAll() - Read All sub data for tag from file.
 
virtual ~CIccTag ()
 Name: CIccTag::CIccTag.
 

Protected Attributes

icFloatNumberm_Curve
 
icUInt16Number m_nMaxIndex
 
icUInt32Number m_nSize
 

Additional Inherited Members

- Static Public Member Functions inherited from CIccTag
static CIccTagCreate (icTagTypeSignature sig)
 Name: CIccTag::Create.
 
- Public Attributes inherited from CIccTag
icUInt32Number m_nReserved
 
- Protected Member Functions inherited from CIccCurve
icFloatNumber Find (icFloatNumber v, icFloatNumber p0, icFloatNumber v0, icFloatNumber p1, icFloatNumber v1)
 Name: CIccCurve::Find.
 

Detailed Description

Class: CIccTagCurve.

Purpose: The curveType tag

Definition at line 127 of file IccTagLut.h.

Constructor & Destructor Documentation

◆ CIccTagCurve() [1/2]

CIccTagCurve::CIccTagCurve ( int nSize = 0)

Name: CIccTagCurve::CIccTagCurve.

Purpose: Constructor

Definition at line 143 of file IccTagLut.cpp.

144{
145 m_nSize = nSize <0 ? 0 : nSize;
146 if (m_nSize>0)
147 m_Curve = (icFloatNumber*)calloc(nSize, sizeof(icFloatNumber));
148 else
149 m_Curve = NULL;
150}
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
icUInt32Number m_nSize
Definition IccTagLut.h:159
icFloatNumber * m_Curve
Definition IccTagLut.h:158

◆ CIccTagCurve() [2/2]

CIccTagCurve::CIccTagCurve ( const CIccTagCurve & ITCurve)

Name: CIccTagCurve::CIccTagCurve.

Purpose: Copy Constructor

Args: ITCurve = The CIccTagCurve object to be copied

Definition at line 163 of file IccTagLut.cpp.

164{
165 m_nSize = ITCurve.m_nSize;
166 m_nMaxIndex = ITCurve.m_nMaxIndex;
167
168 m_Curve = (icFloatNumber*)calloc(m_nSize, sizeof(icFloatNumber));
169 memcpy(m_Curve, ITCurve.m_Curve, m_nSize*sizeof(icFloatNumber));
170}
icUInt16Number m_nMaxIndex
Definition IccTagLut.h:160

References m_Curve, m_nMaxIndex, and m_nSize.

◆ ~CIccTagCurve()

CIccTagCurve::~CIccTagCurve ( )
virtual

Name: CIccTagCurve::~CIccTagCurve.

Purpose: Destructor

Definition at line 208 of file IccTagLut.cpp.

209{
210 if (m_Curve)
211 free(m_Curve);
212}

Member Function Documentation

◆ Apply()

icFloatNumber CIccTagCurve::Apply ( icFloatNumber v) const
virtual

Name: CIccTagCurve::Apply.

Purpose: Applies the curve to the value passed.

Args: v = value to be passed through the curve.

Return: The value modified by the curve.

Reimplemented from CIccCurve.

Definition at line 568 of file IccTagLut.cpp.

569{
570 if(v<0.0) v = 0.0;
571 else if(v>1.0) v = 1.0;
572
574
575 if (!m_nSize) {
576 return v;
577 }
578 if (m_nSize==1) {
579 //Convert 0.0 to 1.0 float to 16bit and then convert from u8Fixed8Number
580 icFloatNumber dGamma = (icFloatNumber)(m_Curve[0] * 65535.0 / 256.0);
581 return (icFloatNumber)pow(v, dGamma);
582 }
583 if (nIndex == m_nMaxIndex) {
584 return m_Curve[nIndex];
585 }
586 else {
587 icFloatNumber nDif = v*m_nMaxIndex - nIndex;
588 icFloatNumber p0 = m_Curve[nIndex];
589
590 icFloatNumber rv = p0 + (m_Curve[nIndex+1]-p0)*nDif;
591 if (rv>1.0)
592 rv=1.0;
593
594 return rv;
595 }
596}
unsigned int icUInt32Number

Referenced by CIccTagLut8::Write().

+ Here is the caller graph for this function:

◆ Begin()

virtual void CIccTagCurve::Begin ( )
inlinevirtual

Reimplemented from CIccCurve.

Definition at line 152 of file IccTagLut.h.

unsigned short icUInt16Number

◆ Describe()

void CIccTagCurve::Describe ( std::string & sDescription,
int nVerboseness )
virtual

Name: CIccTagCurve::Describe.

Purpose: Dump data associated with the tag to a string

Args: sDescription - string to concatenate tag dump to

Reimplemented from CIccTag.

Definition at line 318 of file IccTagLut.cpp.

319{
320 icChar buf[128], *ptr;
321
322 if (!m_nSize) {
323 sprintf(buf, "BEGIN_CURVE In_Out\n");
324 sDescription += buf;
325 sDescription += "Y = X\n";
326 }
327 else if (m_nSize==1) {
328 icFloatNumber dGamma = (icFloatNumber)(m_Curve[0] * 256.0);
329 sprintf(buf, "BEGIN_CURVE In_Out\n");
330 sDescription += buf;
331 sprintf(buf, "Y = X ^ %.4lf\n", dGamma);
332 sDescription += buf;
333 }
334 else {
335 int i;
336
337 sprintf(buf, "BEGIN_LUT In_Out 1 1\n");
338 sDescription += buf;
339
340 if (nVerboseness > 75) {
341 sDescription += "IN OUT\n";
342
343 for (i=0; i<(int)m_nSize; i++) {
344 ptr = buf;
345
347 ptr += strlen(buf);
348
349 strcpy(ptr, " ");
350 ptr ++;
351
353
354 ptr += strlen(ptr);
355
356 strcpy(ptr, "\n");
357 sDescription += buf;
358 }
359 }
360 }
361}
char icChar
Definition IccDefs.h:109
void icColorValue(icChar *szValue, icFloatNumber nValue, icColorSpaceSignature csSig, int nIndex, bool bUseLegacy)
Definition IccUtil.cpp:330
@ icSigMCH1Data

References icColorValue(), and icSigMCH1Data.

+ Here is the call graph for this function:

◆ DumpLut()

void CIccTagCurve::DumpLut ( std::string & sDescription,
const icChar * szName,
icColorSpaceSignature csSig,
int nIndex,
int nVerboseness )
virtual

Name: CIccTagCurve::DumpLut.

Purpose: Dump data associated with the tag to a string. Basically has the same function as Describe()

Args: sDescription = string to concatenate tag dump to, szName = name of the curve to be printed, csSig = color space signature of the LUT data, nIndex = the channel number of color space

Reimplemented from CIccCurve.

Definition at line 378 of file IccTagLut.cpp.

380{
381 icChar buf[128], *ptr;
382
383 if (!m_nSize) {
384 sprintf(buf, "BEGIN_CURVE %s\n", szName);
385 sDescription += buf;
386 sDescription += "Y = X\n";
387 }
388 else if (m_nSize==1) {
389 icFloatNumber dGamma = (icFloatNumber)(m_Curve[0] * 256.0);
390 sprintf(buf, "BEGIN_CURVE %s\n", szName);
391 sDescription += buf;
392 sprintf(buf, "Y = X ^ %.4lf\n", dGamma);
393 sDescription += buf;
394 }
395 else {
396 int i;
397
398 sprintf(buf, "BEGIN_LUT %s 1 1\n", szName);
399
400 if (nVerboseness > 75) {
401 sDescription += buf;
402 sDescription += "IN OUT\n";
403
404 sDescription.reserve(sDescription.size() + m_nSize * 20);
405
406 for (i=0; i<(int)m_nSize; i++) {
407 ptr = buf;
408
409 icColorValue(buf, (icFloatNumber)i/(m_nSize-1), csSig, nIndex);
410 ptr += strlen(buf);
411
412 strcpy(ptr, " ");
413 ptr ++;
414
415 icColorValue(ptr, m_Curve[i], csSig, nIndex);
416
417 ptr += strlen(ptr);
418
419 strcpy(ptr, "\n");
420
421 sDescription += buf;
422 }
423 }
424 }
425}
const icChar * szName

References icColorValue(), and szName.

+ Here is the call graph for this function:

◆ GetClassName()

virtual const icChar * CIccTagCurve::GetClassName ( ) const
inlinevirtual

Reimplemented from CIccTag.

Reimplemented in CIccTagXmlCurve.

Definition at line 137 of file IccTagLut.h.

137{ return "CIccTagCurve"; }

◆ GetData()

icFloatNumber * CIccTagCurve::GetData ( icUInt32Number index)
inline

Definition at line 147 of file IccTagLut.h.

147{return &m_Curve[index];}

◆ GetSize()

icUInt32Number CIccTagCurve::GetSize ( ) const
inline

Definition at line 148 of file IccTagLut.h.

148{ return m_nSize; }

Referenced by CIccTagLut16::Validate(), CIccTagLut8::Validate(), and CIccTagLut8::Write().

+ Here is the caller graph for this function:

◆ GetType()

virtual icTagTypeSignature CIccTagCurve::GetType ( ) const
inlinevirtual

Function: GetType()

Purpose: Get Tag Type. Each derived tag will implement it's own GetType() function.

Reimplemented from CIccTag.

Definition at line 136 of file IccTagLut.h.

136{ return icSigCurveType; }
@ icSigCurveType

References icSigCurveType.

◆ IsIdentity()

bool CIccTagCurve::IsIdentity ( )
virtual

Name: CIccTagCurve::IsIdentity.

Purpose: Checks if this is an identity curve.

Return: true if the curve is an identity

Reimplemented from CIccCurve.

Definition at line 535 of file IccTagLut.cpp.

536{
537 if (!m_nSize) {
538 return true;
539 }
540
541 if (m_nSize==1) {
542 return IsUnity(icFloatNumber(m_Curve[0]*65535.0/256.0));
543 }
544
546 for (i=0; i<m_nSize; i++) {
548 return false;
549 }
550 }
551
552 return true;
553}
static bool IsUnity(const icFloatNumber &num)
const icFloatNumber VERYSMALLNUM

References IsUnity(), and VERYSMALLNUM.

+ Here is the call graph for this function:

◆ NewCopy()

virtual CIccTag * CIccTagCurve::NewCopy ( ) const
inlinevirtual

Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.

Parameter(s): none

Returns a new CIccTag object that is a copy of this object.

Reimplemented from CIccCurve.

Definition at line 133 of file IccTagLut.h.

133{ return new CIccTagCurve(*this);}
CIccTagCurve(int nSize=0)
Name: CIccTagCurve::CIccTagCurve.

◆ operator=()

CIccTagCurve & CIccTagCurve::operator= ( const CIccTagCurve & CurveTag)

Name: CIccTagCurve::operator=.

Purpose: Copy Operator

Args: CurveTag = The CIccTagCurve object to be copied

Definition at line 183 of file IccTagLut.cpp.

184{
185 if (&CurveTag == this)
186 return *this;
187
188 m_nSize = CurveTag.m_nSize;
189 m_nMaxIndex = CurveTag.m_nMaxIndex;
190
191 if (m_Curve)
192 free(m_Curve);
193 m_Curve = (icFloatNumber*)calloc(m_nSize, sizeof(icFloatNumber));
194 memcpy(m_Curve, CurveTag.m_Curve, m_nSize*sizeof(icFloatNumber));
195
196 return *this;
197}

References m_Curve, m_nMaxIndex, and m_nSize.

◆ operator[]()

icFloatNumber & CIccTagCurve::operator[] ( icUInt32Number index)
inline

Definition at line 146 of file IccTagLut.h.

146{return m_Curve[index];}

◆ Read()

bool CIccTagCurve::Read ( icUInt32Number size,
CIccIO * pIO )
virtual

Name: CIccTagCurve::Read.

Purpose: Read in the tag contents into a data block

Args: size - # of bytes in tag, pIO - IO object to read tag from

Return: true = successful, false = failure

Reimplemented from CIccTag.

Definition at line 229 of file IccTagLut.cpp.

230{
232
233 icUInt32Number headerSize = sizeof(icTagTypeSignature) +
234 sizeof(icUInt32Number) +
235 sizeof(icUInt32Number);
236 if (headerSize > size)
237 return false;
238
239 if (!pIO) {
240 return false;
241 }
242
243 if (!pIO->Read32(&sig))
244 return false;
245
246 if (!pIO->Read32(&m_nReserved))
247 return false;
248
249 icUInt32Number nSize;
250
251 if (!pIO->Read32(&nSize))
252 return false;
253
254 if (headerSize + (icUInt64Number)nSize * sizeof(icUInt16Number) > size)
255 return false;
256
257 if (!SetSize(nSize, icInitNone))
258 return false;
259
260 if (m_nSize) {
262 return false;
263 }
264
265 return true;
266}
icArraySignature sig
@ icInitNone
Definition IccTagLut.h:115
icTagTypeSignature
icInt32Number ReadUInt16Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:236
icInt32Number Read32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:143
bool SetSize(icUInt32Number nSize, icTagCurveSizeInit nSizeOpt=icInitZero)
Name: CIccTagCurve::SetSize.
icUInt32Number m_nReserved
long icInt32Number
icUInt32Number icUInt64Number[2]

References icInitNone, CIccIO::Read32(), CIccIO::ReadUInt16Float(), and sig.

+ Here is the call graph for this function:

◆ SetGamma()

bool CIccTagCurve::SetGamma ( icFloatNumber gamma)

Name: refIccMAX::CIccTagCurve::SetGamma.

Purpose: Set the curve with a single gamma value.

Args: gamma - gamma value to use

Definition at line 502 of file IccTagLut.cpp.

503{
504 if (!SetSize(1, icInitNone))
505 return false;
506
507 icInt16Number whole = (icInt16Number)gamma;
508 icFloatNumber frac = gamma - (icFloatNumber)whole;
509
510 m_Curve[0] = (icFloatNumber)((whole * 256) + (frac*256.0)) / (icFloatNumber)65535.0;
511 return true;
512}
short icInt16Number

References icInitNone.

◆ SetSize()

bool CIccTagCurve::SetSize ( icUInt32Number nSize,
icTagCurveSizeInit nSizeOpt = icInitZero )

Name: CIccTagCurve::SetSize.

Purpose: Sets the size of the curve array.

Args: nSize - number of entries in the curve, nSizeOpt - flag to zero newly formed values

Definition at line 439 of file IccTagLut.cpp.

440{
441 if (nSize==m_nSize)
442 return true;
443
444 if (!nSize && m_Curve) {
445 free(m_Curve);
446 m_Curve = NULL;
447 }
448 else {
449 if (!m_Curve)
450 m_Curve = (icFloatNumber*)malloc(nSize*sizeof(icFloatNumber));
451 else
453
454 if (!m_Curve) {
455 m_nSize = 0;
456 return false;
457 }
458
459 switch (nSizeOpt) {
460 case icInitNone:
461 default:
462 break;
463
464 case icInitZero:
465 if (m_nSize < nSize) {
466 memset(&m_Curve[m_nSize], 0, (nSize-m_nSize)*sizeof(icFloatNumber));
467 }
468 break;
469
470 case icInitIdentity:
471 if (nSize>1) {
473 icFloatNumber last = (icFloatNumber)(nSize-1);
474
475 for (i=0; i<nSize; i++) {
476 m_Curve[i] = (icFloatNumber)i/last;
477 }
478 }
479 else if (nSize==1) {
480 //Encode a gamma 1.0 u8Fixed8Number converted to 16 bit as a 0.0 to 1.0 float
481 m_Curve[0] = (icFloatNumber)(0x0100) / (icFloatNumber)65535.0;
482 }
483 break;
484 }
485 }
486 m_nSize = nSize;
487 m_nMaxIndex = (icUInt16Number)(nSize - 1);
488
489 return true;
490}
@ icInitZero
Definition IccTagLut.h:116
@ icInitIdentity
Definition IccTagLut.h:117
void * icRealloc(void *ptr, size_t size)
Name: icRealloc.
Definition IccUtil.cpp:111

References icInitIdentity, icInitNone, icInitZero, and icRealloc().

Referenced by CIccTagLut16::Read(), CIccTagLut8::Read(), CIccTagLut16::SetColorSpaces(), and CIccTagLut8::SetColorSpaces().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Validate()

icValidateStatus CIccTagCurve::Validate ( std::string sigPath,
std::string & sReport,
const CIccProfile * pProfile = NULL ) const
virtual

Name: CIccTagCurve::Validate.

Purpose: Check tag data validity.

Args: sig = signature of tag being validated, sReport = String to add report information to

Return: icValidateStatusOK if valid, or other error status.

Reimplemented from CIccTag.

Definition at line 613 of file IccTagLut.cpp.

614{
615 icValidateStatus rv = CIccTag::Validate(sigPath, sReport, pProfile);
616
617 CIccInfo Info;
618 std::string sSigPathName = Info.GetSigPathName(sigPath);
620
622 if (m_nSize>1) {
623 if (m_Curve) {
624 if (m_Curve[0]>0.0 || m_Curve[m_nSize-1]<1.0) {
625 sReport += icMsgValidateWarning;
626 sReport += sSigPathName;
627 sReport += " - Curve cannot be accurately inverted.\n";
629 }
630 }
631 }
632 }
633
634 return rv;
635}
icValidateStatus
Definition IccDefs.h:118
@ icValidateWarning
Definition IccDefs.h:120
icValidateStatus icMaxStatus(icValidateStatus s1, icValidateStatus s2)
Name: icMaxStatus.
Definition IccUtil.cpp:244
const char * icMsgValidateWarning
Definition IccUtil.cpp:90
icSignature icGetFirstSigPathSig(std::string sigPath)
Definition IccUtil.cpp:1201
Type: Class.
Definition IccUtil.h:303
std::string GetSigPathName(std::string sigPath)
Definition IccUtil.cpp:1614
virtual icValidateStatus Validate(std::string sigPath, std::string &sReport, const CIccProfile *pProfile=NULL) const
Function: Validate Each derived tag will implement it's own IsValid() function.
icUInt32Number icSignature
@ icSigGrayTRCTag
@ icSigGreenTRCTag
@ icSigRedTRCTag
@ icSigBlueTRCTag

References CIccInfo::GetSigPathName(), icGetFirstSigPathSig(), icMaxStatus(), icMsgValidateWarning, icSigBlueTRCTag, icSigGrayTRCTag, icSigGreenTRCTag, icSigRedTRCTag, icValidateWarning, sig, and CIccTag::Validate().

+ Here is the call graph for this function:

◆ Write()

bool CIccTagCurve::Write ( CIccIO * pIO)
virtual

Name: CIccTagCurve::Write.

Purpose: Write the tag to a file

Args: pIO - The IO object to write tag to.

Return: true = succesful, false = failure

Reimplemented from CIccTag.

Definition at line 282 of file IccTagLut.cpp.

283{
285
286 if (!pIO)
287 return false;
288
289 if (!pIO->Write32(&sig))
290 return false;
291
292 if (!pIO->Write32(&m_nReserved))
293 return false;
294
295 if (!pIO->Write32(&m_nSize))
296 return false;
297
298 if (m_nSize)
300 return false;
301
302 pIO->Align32();
303
304 return true;
305}
bool Align32()
Write operation to make sure that filelength is evenly divisible by 4.
Definition IccIO.cpp:341
icInt32Number Write32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:152
icInt32Number WriteUInt16Float(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:252
virtual icTagTypeSignature GetType() const
Function: GetType()
Definition IccTagLut.h:136

References CIccIO::Align32(), sig, CIccIO::Write32(), and CIccIO::WriteUInt16Float().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_Curve

icFloatNumber* CIccTagCurve::m_Curve
protected

Definition at line 158 of file IccTagLut.h.

Referenced by CIccTagCurve(), and operator=().

◆ m_nMaxIndex

icUInt16Number CIccTagCurve::m_nMaxIndex
protected

Definition at line 160 of file IccTagLut.h.

Referenced by CIccTagCurve(), and operator=().

◆ m_nSize

icUInt32Number CIccTagCurve::m_nSize
protected

Definition at line 159 of file IccTagLut.h.

Referenced by CIccTagCurve(), and operator=().


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