Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CIccTagFixedNum< T, Tsig > Class Template Reference

Class: CIccTagFixedNum. More...

#include <IccTagBasic.h>

+ Inheritance diagram for CIccTagFixedNum< T, Tsig >:
+ Collaboration diagram for CIccTagFixedNum< T, Tsig >:

Public Member Functions

 CIccTagFixedNum (const CIccTagFixedNum< T, Tsig > &ITFN)
 Name: CIccTagFixedNum::CIccTagFixedNum.
 
 CIccTagFixedNum (int nSize=1)
 Name: CIccTagFixedNum::CIccTagFixedNum.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccTagFixedNum::Describe.
 
virtual const icCharGetClassName () const
 Name: CIccTagFixedNum::GetClassName.
 
virtual icUInt32Number GetNumValues () const
 
icUInt32Number GetSize () const
 Returns the size of the data array.
 
virtual icTagTypeSignature GetType () const
 Function: GetType()
 
virtual bool GetValues (icFloatNumber *DstVector, icUInt32Number nStart=0, icUInt32Number nVectorSize=1) const
 Name: CIccTagFixedNum::GetValues.
 
virtual bool Interpolate (icFloatNumber *DstVector, icFloatNumber val, icUInt32Number nVectorSize=1, icFloatNumber *zeroVals=NULL) const
 Name: CIccTagFixedNum::Interpolate.
 
virtual bool IsArrayType ()
 
virtual bool IsMatrixArray () const
 
virtual bool IsNumArrayType () const
 
virtual CIccTagNewCopy () const
 Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
 
CIccTagFixedNumoperator= (const CIccTagFixedNum< T, Tsig > &FixedNumTag)
 Name: CIccTagFixedNum::operator=.
 
T & operator[] (icUInt32Number index)
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccTagFixedNum::Read.
 
bool SetSize (icUInt32Number nSize, bool bZeroNew=true)
 Name: CIccTagFixedNum::SetSize.
 
virtual bool ValuePos (icFloatNumber &DstPos, icFloatNumber val, bool &bNoZero) const
 Name: CIccTagFixedNum::ValuePos.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccTagFixedNum::Write.
 
virtual ~CIccTagFixedNum ()
 Name: CIccTagFixedNum::~CIccTagFixedNum.
 
- 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 IsMBBType ()
 
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 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.
 
virtual ~CIccTag ()
 Name: CIccTag::CIccTag.
 

Protected Attributes

icUInt32Number m_nSize
 
T * m_Num
 

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
 

Detailed Description

template<class T, icTagTypeSignature Tsig>
class CIccTagFixedNum< T, Tsig >

Class: CIccTagFixedNum.

Purpose: A template class for arrays of Fixed point numbers

Derived Tags: CIccTagS15Fixed16 and CIccTagU16Fixed16

Definition at line 896 of file IccTagBasic.h.

Constructor & Destructor Documentation

◆ CIccTagFixedNum() [1/2]

template<class T , icTagTypeSignature Tsig>
CIccTagFixedNum< T, Tsig >::CIccTagFixedNum ( int nSize = 1)

Name: CIccTagFixedNum::CIccTagFixedNum.

Purpose: CIccTagFixedNumConstructor

Args: nSize = number of data entries

Definition at line 5125 of file IccTagBasic.cpp.

5126{
5127 m_nSize = nSize;
5128 if (m_nSize <1)
5129 m_nSize = 1;
5130 m_Num = (T*)calloc(nSize, sizeof(T));
5131}
icUInt32Number m_nSize

◆ CIccTagFixedNum() [2/2]

template<class T , icTagTypeSignature Tsig>
CIccTagFixedNum< T, Tsig >::CIccTagFixedNum ( const CIccTagFixedNum< T, Tsig > & ITFN)

Name: CIccTagFixedNum::CIccTagFixedNum.

Purpose: Copy Constructor

Args: ITFN = The CIccTagFixedNum object to be copied

Definition at line 5145 of file IccTagBasic.cpp.

5146{
5147 m_nSize = ITFN.m_nSize;
5148 m_Num = (T*)calloc(m_nSize, sizeof(T));
5149 memcpy(m_Num, ITFN.m_Num, m_nSize*sizeof(T));
5150}

References CIccTagFixedNum< T, Tsig >::m_nSize, and CIccTagFixedNum< T, Tsig >::m_Num.

◆ ~CIccTagFixedNum()

template<class T , icTagTypeSignature Tsig>
CIccTagFixedNum< T, Tsig >::~CIccTagFixedNum ( )
virtual

Name: CIccTagFixedNum::~CIccTagFixedNum.

Purpose: Destructor

Definition at line 5190 of file IccTagBasic.cpp.

5191{
5192 if (m_Num)
5193 free(m_Num);
5194}

Member Function Documentation

◆ Describe()

template<class T , icTagTypeSignature Tsig>
void CIccTagFixedNum< T, Tsig >::Describe ( std::string & sDescription,
int nVerboseness )
virtual

Name: CIccTagFixedNum::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 5304 of file IccTagBasic.cpp.

5305{
5306 icChar buf[128] = { 0 };
5307
5308 if (m_nSize == 1 ) {
5309 if (Tsig==icSigS15Fixed16ArrayType)
5310 sprintf(buf, "Value = %.4lf\n", icFtoD(m_Num[0]));
5311 else
5312 sprintf(buf, "Value = %.4lf\n", icUFtoD(m_Num[0]));
5313 sDescription += buf;
5314 }
5315 else {
5317
5318 if (Tsig==icSigS15Fixed16ArrayType && m_nSize==9) {
5319 sDescription += "Matrix Form:\n";
5320 icMatrixDump(sDescription, (icS15Fixed16Number*)m_Num);
5321
5322 sDescription += "\nArrayForm:\n";
5323 }
5324 sDescription.reserve(sDescription.size() + m_nSize*79);
5325
5326 for (i=0; i<m_nSize; i++) {
5327 if (Tsig==icSigS15Fixed16ArrayType)
5328 sprintf(buf, "Value[%u] = %8.4lf\n", i, icFtoD(m_Num[i]));
5329 else
5330 sprintf(buf, "Value[%u] = %8.4lf\n", i, icUFtoD(m_Num[i]));
5331 sDescription += buf;
5332 }
5333 }
5334}
char icChar
Definition IccDefs.h:109
icFloatNumber icUFtoD(icU16Fixed16Number num)
Definition IccUtil.cpp:580
void icMatrixDump(std::string &sDump, icS15Fixed16Number *pMatrix)
Definition IccUtil.cpp:988
icFloatNumber icFtoD(icS15Fixed16Number num)
Definition IccUtil.cpp:559
unsigned int icUInt32Number
@ icSigS15Fixed16ArrayType
icInt32Number icS15Fixed16Number
Fixed numbers.

References icFtoD(), icMatrixDump(), icSigS15Fixed16ArrayType, and icUFtoD().

+ Here is the call graph for this function:

◆ GetClassName()

template<class T , icTagTypeSignature Tsig>
const icChar * CIccTagFixedNum< T, Tsig >::GetClassName ( ) const
virtual

Name: CIccTagFixedNum::GetClassName.

Purpose: Returns the tag type class name

Reimplemented from CIccTag.

Reimplemented in CIccTagXmlFixedNum< T, Tsig >.

Definition at line 5205 of file IccTagBasic.cpp.

5206{
5207 if (Tsig==icSigS15Fixed16ArrayType)
5208 return "CIccTagS15Fixed16";
5209 else
5210 return "CIccTagU16Fixed16";
5211}

References icSigS15Fixed16ArrayType.

◆ GetNumValues()

template<class T , icTagTypeSignature Tsig>
virtual icUInt32Number CIccTagFixedNum< T, Tsig >::GetNumValues ( ) const
inlinevirtual

Implements CIccTagNumArray.

Definition at line 924 of file IccTagBasic.h.

924{ return GetSize(); }
icUInt32Number GetSize() const
Returns the size of the data array.

◆ GetSize()

template<class T , icTagTypeSignature Tsig>
icUInt32Number CIccTagFixedNum< T, Tsig >::GetSize ( ) const
inline

Returns the size of the data array.

Definition at line 918 of file IccTagBasic.h.

918{ return m_nSize; }

◆ GetType()

template<class T , icTagTypeSignature Tsig>
virtual icTagTypeSignature CIccTagFixedNum< T, Tsig >::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 907 of file IccTagBasic.h.

907{ return Tsig; }

◆ GetValues()

template<class T , icTagTypeSignature Tsig>
bool CIccTagFixedNum< T, Tsig >::GetValues ( icFloatNumber * DstVector,
icUInt32Number nStart = 0,
icUInt32Number nVectorSize = 1 ) const
virtual

Name: CIccTagFixedNum::GetValues.

Purpose: Gets values from the num array tag as floating point numbers

Args: nSize - number of data entries, bZeroNew - flag to zero newly formed values

Implements CIccTagNumArray.

Definition at line 5380 of file IccTagBasic.cpp.

5381{
5382 if (nVectorSize+nStart >m_nSize)
5383 return false;
5384
5386
5387 switch (Tsig) {
5389 for (i=0; i<m_nSize; i++) {
5390 DstVector[i] = (icFloatNumber)icFtoD(m_Num[i+nStart]);
5391 }
5392 break;
5394 for (i=0; i<m_nSize; i++) {
5395 DstVector[i] = (icFloatNumber)icUFtoD(m_Num[i+nStart]);
5396 }
5397 break;
5398 default:
5399 return false;
5400 }
5401 return true;
5402}
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
@ icSigU16Fixed16ArrayType

References icFtoD(), icSigS15Fixed16ArrayType, icSigU16Fixed16ArrayType, and icUFtoD().

+ Here is the call graph for this function:

◆ Interpolate()

template<class T , icTagTypeSignature Tsig>
bool CIccTagFixedNum< T, Tsig >::Interpolate ( icFloatNumber * DstVector,
icFloatNumber pos,
icUInt32Number nVectorSize = 1,
icFloatNumber * zeroVals = NULL ) const
virtual

Name: CIccTagFixedNum::Interpolate.

Purpose: Gets values from the num array tag as floating point numbers

Args: nSize - number of data entries, bZeroNew - flag to zero newly formed values

Implements CIccTagNumArray.

Definition at line 5417 of file IccTagBasic.cpp.

5419{
5420 icUInt32Number nVector = m_nSize / nVectorSize;
5421
5422 if (!nVector)
5423 return false;
5424
5425 if (zeroVals)
5426 nVector ++;
5427 else if (nVector<=1)
5428 return false;
5429
5430 if (pos<0.0)
5431 pos=0.0;
5432 if (pos>1.0)
5433 pos=1.0;
5434
5435 icFloatNumber fpos = (icFloatNumber)(nVector-1) * pos;
5436 icUInt32Number iPos = (icUInt32Number)fpos;
5437 icFloatNumber x = fpos - iPos;
5438
5439 if (iPos == nVector-1) {
5440 iPos--;
5441 x = (icFloatNumber)1.0;
5442 }
5443
5444 T *lo, *hi;
5445
5446 if (zeroVals) {
5447 if (!iPos) {
5448 lo = NULL;
5449 hi = m_Num;
5450 }
5451 else {
5452 lo = &m_Num[(iPos-1)*nVectorSize];
5453 hi = &lo[nVectorSize];
5454 }
5455 }
5456 else {
5457 lo = &m_Num[iPos*nVectorSize];
5458 hi = &lo[nVectorSize];
5459 }
5460
5462
5463 switch (Tsig) {
5465 if (!lo) {
5466 for (i=0; i<m_nSize; i++) {
5467 DstVector[i] = (icFloatNumber)(zeroVals[i]*(1.0f-x) + icFtoD(hi[i])*x);
5468 }
5469 }
5470 else {
5471 for (i=0; i<m_nSize; i++) {
5472 DstVector[i] = (icFloatNumber)(icFtoD(lo[i])*(1.0-x) + icFtoD(hi[i])*x);
5473 }
5474 }
5475 break;
5477 if (!lo) {
5478 for (i=0; i<m_nSize; i++) {
5479 DstVector[i] = (icFloatNumber)(zeroVals[i]*(1.0-x) + icUFtoD(hi[i])*x);
5480 }
5481 }
5482 else {
5483 for (i=0; i<m_nSize; i++) {
5484 DstVector[i] = (icFloatNumber)(icUFtoD(lo[i])*(1.0-x) + icUFtoD(hi[i])*x);
5485 }
5486 }
5487 break;
5488 default:
5489 return false;
5490 }
5491 return true;
5492}

References icFtoD(), icSigS15Fixed16ArrayType, icSigU16Fixed16ArrayType, and icUFtoD().

+ Here is the call graph for this function:

◆ IsArrayType()

template<class T , icTagTypeSignature Tsig>
virtual bool CIccTagFixedNum< T, Tsig >::IsArrayType ( )
inlinevirtual

Reimplemented from CIccTag.

Definition at line 905 of file IccTagBasic.h.

905{ return m_nSize > 1; }

◆ IsMatrixArray()

template<class T , icTagTypeSignature Tsig>
virtual bool CIccTagFixedNum< T, Tsig >::IsMatrixArray ( ) const
inlinevirtual

Implements CIccTagNumArray.

Definition at line 930 of file IccTagBasic.h.

930{ return false; }

◆ IsNumArrayType()

template<class T , icTagTypeSignature Tsig>
virtual bool CIccTagFixedNum< T, Tsig >::IsNumArrayType ( ) const
inlinevirtual

Reimplemented from CIccTag.

Definition at line 921 of file IccTagBasic.h.

921{ return true; }

◆ NewCopy()

template<class T , icTagTypeSignature Tsig>
virtual CIccTag * CIccTagFixedNum< T, Tsig >::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 CIccTag.

Definition at line 902 of file IccTagBasic.h.

902{ return new CIccTagFixedNum<T, Tsig>(*this); }
CIccTagFixedNum(int nSize=1)
Name: CIccTagFixedNum::CIccTagFixedNum.

◆ operator=()

template<class T , icTagTypeSignature Tsig>
CIccTagFixedNum< T, Tsig > & CIccTagFixedNum< T, Tsig >::operator= ( const CIccTagFixedNum< T, Tsig > & ITFN)

Name: CIccTagFixedNum::operator=.

Purpose: Copy Operator

Args: ITFN = The CIccTagFixedNum object to be copied

Definition at line 5164 of file IccTagBasic.cpp.

5165{
5166 if (&ITFN == this)
5167 return *this;
5168
5169 m_nSize = ITFN.m_nSize;
5170
5171 if (m_Num)
5172 free(m_Num);
5173 m_Num = (T*)calloc(m_nSize, sizeof(T));
5174 memcpy(m_Num, ITFN.m_Num, m_nSize*sizeof(T));
5175
5176 return *this;
5177}

References CIccTagFixedNum< T, Tsig >::m_nSize, and CIccTagFixedNum< T, Tsig >::m_Num.

◆ operator[]()

template<class T , icTagTypeSignature Tsig>
T & CIccTagFixedNum< T, Tsig >::operator[] ( icUInt32Number index)
inline

Definition at line 915 of file IccTagBasic.h.

915{return m_Num[index];}

◆ Read()

template<class T , icTagTypeSignature Tsig>
bool CIccTagFixedNum< T, Tsig >::Read ( icUInt32Number size,
CIccIO * pIO )
virtual

Name: CIccTagFixedNum::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 5229 of file IccTagBasic.cpp.

5230{
5232
5233 if (sizeof(icTagTypeSignature) +
5234 sizeof(icUInt32Number) +
5235 sizeof(T) > size)
5236 return false;
5237
5238 if (!pIO) {
5239 return false;
5240 }
5241
5242 if (!pIO->Read32(&sig))
5243 return false;
5244
5245 if (!pIO->Read32(&m_nReserved))
5246 return false;
5247
5248 icUInt32Number nSize=((size-2*sizeof(icUInt32Number)) / sizeof(T));
5249
5250 if (!SetSize(nSize))
5251 return false;
5252
5253 if (pIO->Read32(m_Num, nSize) != (icInt32Number)nSize )
5254 return false;
5255
5256 return true;
5257}
icArraySignature sig
icTagTypeSignature
icInt32Number Read32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:143
bool SetSize(icUInt32Number nSize, bool bZeroNew=true)
Name: CIccTagFixedNum::SetSize.
icUInt32Number m_nReserved
long icInt32Number

References CIccIO::Read32(), and sig.

+ Here is the call graph for this function:

◆ SetSize()

template<class T , icTagTypeSignature Tsig>
bool CIccTagFixedNum< T, Tsig >::SetSize ( icUInt32Number nSize,
bool bZeroNew = true )

Name: CIccTagFixedNum::SetSize.

Purpose: Sets the size of the data array.

Args: nSize - number of data entries, bZeroNew - flag to zero newly formed values

Definition at line 5348 of file IccTagBasic.cpp.

5349{
5350 if (nSize==m_nSize)
5351 return true;
5352
5353 m_Num = (T*)icRealloc(m_Num, nSize*sizeof(T));
5354
5355 if (!m_Num) {
5356 m_nSize = 0;
5357 return false;
5358 }
5359
5360 if (bZeroNew && m_nSize < nSize) {
5361 memset(&m_Num[m_nSize], 0, (nSize-m_nSize)*sizeof(T));
5362 }
5363 m_nSize = nSize;
5364
5365 return true;
5366}
void * icRealloc(void *ptr, size_t size)
Name: icRealloc.
Definition IccUtil.cpp:111

References icRealloc().

+ Here is the call graph for this function:

◆ ValuePos()

template<class T , icTagTypeSignature Tsig>
bool CIccTagFixedNum< T, Tsig >::ValuePos ( icFloatNumber & DstPos,
icFloatNumber val,
bool & bNoZero ) const
virtual

Name: CIccTagFixedNum::ValuePos.

Purpose: Gets position of a value int the num array tag

Args: DstPos - position of val in array val - value to look for in array. bNoZero - flag indicating whether first entry is zero

Implements CIccTagNumArray.

Definition at line 5507 of file IccTagBasic.cpp.

5508{
5509 if(val<0.0)
5510 return false;
5511
5512 icFloatNumber nv = 0.0;
5513 icFloatNumber lv = 0.0;
5514 switch (Tsig) {
5516 lv = icFtoD(m_Num[0]);
5517 break;
5519 lv = icUFtoD(m_Num[0]);
5520 break;
5521 default:
5522 return false;
5523 }
5524 bNoZero = (lv!=0.0);
5525
5526 if (val<lv) {
5527 DstPos = val/lv - 1.0f;
5528 return true;
5529 }
5530
5532 for (i=1; i<m_nSize; i++, lv=nv) {
5533 switch (Tsig) {
5535 nv = icFtoD(m_Num[i]);
5536 break;
5538 nv = icUFtoD(m_Num[i]);
5539 break;
5540 default:
5541 return false;
5542 }
5543 if (val<=nv) {
5544 DstPos = (val-lv)/(nv-lv) + i - 1.0f;
5545 return true;
5546 }
5547 }
5548
5549 return false;
5550}

References icFtoD(), icSigS15Fixed16ArrayType, icSigU16Fixed16ArrayType, and icUFtoD().

+ Here is the call graph for this function:

◆ Write()

template<class T , icTagTypeSignature Tsig>
bool CIccTagFixedNum< T, Tsig >::Write ( CIccIO * pIO)
virtual

Name: CIccTagFixedNum::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 5274 of file IccTagBasic.cpp.

5275{
5277
5278 if (!pIO)
5279 return false;
5280
5281 if (!pIO->Write32(&sig))
5282 return false;
5283
5284 if (!pIO->Write32(&m_nReserved))
5285 return false;
5286
5287 if (pIO->Write32(m_Num, m_nSize) != (icInt32Number)m_nSize)
5288 return false;
5289
5290 return true;
5291}
icInt32Number Write32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:152
virtual icTagTypeSignature GetType() const
Function: GetType()

References sig, and CIccIO::Write32().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_nSize

template<class T , icTagTypeSignature Tsig>
icUInt32Number CIccTagFixedNum< T, Tsig >::m_nSize
protected

◆ m_Num

template<class T , icTagTypeSignature Tsig>
T* CIccTagFixedNum< T, Tsig >::m_Num
protected

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