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

Class: CIccTagSparseMatrixArray. More...

#include <IccTagBasic.h>

+ Inheritance diagram for CIccTagSparseMatrixArray:
+ Collaboration diagram for CIccTagSparseMatrixArray:

Public Member Functions

 CIccTagSparseMatrixArray (const CIccTagSparseMatrixArray &ITSMA)
 Name: CIccTagSparseMatrixArray::CIccTagSparseMatrixArray.
 
 CIccTagSparseMatrixArray (int nNumMatrices=1, int nChannelsPerMatrix=4)
 Name: CIccTagSparseMatrixArray::CIccTagSparseMatrixArray.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccTagSparseMatrixArray::Describe.
 
icUInt32Number GetBytesPerMatrix () const
 
icUInt32Number GetChannelsPerMatrix () const
 
virtual const icCharGetClassName () const
 
icSparseMatrixType GetMatrixType () const
 
icUInt32Number GetNumMatrices () const
 Returns the number of matrices in the array.
 
virtual icUInt32Number GetNumValues () const
 
bool GetSparseMatrix (CIccSparseMatrix &mtx, int nIndex, bool bInitFromData=true)
 Name: CIccTagSparseMatrixArray::GetValues.
 
virtual icTagTypeSignature GetType () const
 Function: GetType()
 
virtual bool GetValues (icFloatNumber *DstVector, icUInt32Number nStart=0, icUInt32Number nVectorSize=1) const
 
virtual bool Interpolate (icFloatNumber *DstVector, icFloatNumber val, icUInt32Number nVectorSize=1, icFloatNumber *zeroVals=NULL) const
 Name: CIccTagSparseMatrixArray::Interpolate.
 
virtual bool IsArrayType ()
 
virtual bool IsMatrixArray () const
 
virtual bool IsNumArrayType () const
 
virtual CIccTagNewCopy ()
 
CIccTagSparseMatrixArrayoperator= (const CIccTagSparseMatrixArray &ITSMA)
 Name: CIccTagSparseMatrixArray::operator=.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccTagSparseMatrixArray::Read.
 
bool Reset (icUInt32Number nNumMatrices, icUInt16Number nChannelsPerMatrix)
 Name: CIccTagSparseMatrixArray::Reset.
 
void SetMatrixType (icSparseMatrixType nType)
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccProfile *pProfile=NULL) const
 Name: CIccTagSparseMatrixArray::Validate.
 
virtual bool ValuePos (icFloatNumber &DstPos, icFloatNumber val, bool &bNoZero) const
 Name: CIccTagSparseMatrixArray::ValuePos.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccTagSparseMatrixArray::Write.
 
virtual ~CIccTagSparseMatrixArray ()
 Name: CIccTagSparseMatrixArray::~CIccTagSparseMatrixArray.
 
- 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 CIccTagNewCopy () const
 Function: NewCopy(sDescription) Each derived tag will implement it's own NewCopy() function.
 
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

bool m_bNonZeroPadding
 
icUInt16Number m_nChannelsPerMatrix
 
icSparseMatrixType m_nMatrixType
 
icUInt32Number m_nSize
 
icUInt8Numberm_RawData
 

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

Class: CIccTagSparseMatrixArray.

Purpose: A template class for arrays of Fixed point numbers

Derived Tags: CIccTagS15Fixed16 and CIccTagU16Fixed16

Definition at line 830 of file IccTagBasic.h.

Constructor & Destructor Documentation

◆ CIccTagSparseMatrixArray() [1/2]

CIccTagSparseMatrixArray::CIccTagSparseMatrixArray ( int nNumMatrices = 1,
int nChannelsPerMatrix = 4 )

Name: CIccTagSparseMatrixArray::CIccTagSparseMatrixArray.

Purpose: CIccTagSparseMatrixArray Constructor

Args: nSize = number of data entries

Definition at line 4398 of file IccTagBasic.cpp.

4399{
4400 m_nSize = nNumMatrices;
4401 m_nChannelsPerMatrix = nChannelsPerMatrix;
4403
4404 if (m_nSize <1)
4405 m_nSize = 1;
4406 if (nChannelsPerMatrix<4)
4408
4410
4411 m_bNonZeroPadding = false;
4412}
icUInt8Number * m_RawData
icUInt32Number GetBytesPerMatrix() const
icUInt16Number m_nChannelsPerMatrix
icSparseMatrixType m_nMatrixType
unsigned char icUInt8Number
Number definitions.
@ icSparseMatrixFloat32

References icSparseMatrixFloat32.

◆ CIccTagSparseMatrixArray() [2/2]

CIccTagSparseMatrixArray::CIccTagSparseMatrixArray ( const CIccTagSparseMatrixArray & ITSMA)

Name: CIccTagSparseMatrixArray::CIccTagSparseMatrixArray.

Purpose: Copy Constructor

Args: ITFN = The CIccTagFixedNum object to be copied

Definition at line 4425 of file IccTagBasic.cpp.

4426{
4427 m_nSize = ITSMA.m_nSize;
4430
4432 memcpy(m_RawData, ITSMA.m_RawData, m_nSize*GetBytesPerMatrix());
4433
4435}

References m_bNonZeroPadding, m_nChannelsPerMatrix, m_nMatrixType, m_nSize, and m_RawData.

◆ ~CIccTagSparseMatrixArray()

CIccTagSparseMatrixArray::~CIccTagSparseMatrixArray ( )
virtual

Name: CIccTagSparseMatrixArray::~CIccTagSparseMatrixArray.

Purpose: Destructor

Definition at line 4476 of file IccTagBasic.cpp.

4477{
4478 if (m_RawData)
4479 free(m_RawData);
4480}

Member Function Documentation

◆ Describe()

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

Name: CIccTagSparseMatrixArray::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 4773 of file IccTagBasic.cpp.

4774{
4775 icChar buf[128];
4776
4777 sDescription += "Begin_SparseMatrix_Array\n";
4778 sprintf(buf, "OutputChannels = %d\n", m_nChannelsPerMatrix);
4779 sDescription += buf;
4780 sprintf(buf, "MatrixType = %d\n", m_nMatrixType);
4781 sDescription += buf;
4782
4783 int i, r, c;
4784 icUInt32Number nBytesPerMatrix = m_nChannelsPerMatrix * sizeof(icFloatNumber);
4785 for (i=0; i<(int)m_nSize; i++) {
4786 CIccSparseMatrix mtx(&m_RawData[i*nBytesPerMatrix], nBytesPerMatrix, icSparseMatrixFloatNum, true);
4787
4788 sprintf(buf, "\nBegin_Matrix_%d\n", i);
4789 sDescription += buf;
4790
4791 icUInt16Number *start = mtx.GetRowStart();
4792 icUInt16Number *cols = mtx.GetColumnsForRow(0);
4793 for (r=0; r<mtx.Rows(); r++) {
4794 icUInt16Number rs = start[r];
4795 icUInt16Number re = start[r+1];
4796 sprintf(buf, "Row%d:", r);
4797 sDescription += buf;
4798
4799 for (c=rs; c<re; c++) {
4800 sprintf(buf, " (%d, %.4lf)", cols[c], mtx.GetData()->get(c));
4801 sDescription += buf;
4802 }
4803 }
4804
4805 sprintf(buf, "End_Matrix_%d\n", i);
4806 sDescription += buf;
4807 }
4808 sDescription += "\nEnd_SparseMatrix_Array\n";
4809
4810}
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
char icChar
Definition IccDefs.h:109
unsigned int icUInt32Number
unsigned short icUInt16Number
#define icSparseMatrixFloatNum
Convenience Enum Definition - Not defined in ICC specification.

References IIccSparseMatrixEntry::get(), CIccSparseMatrix::GetColumnsForRow(), CIccSparseMatrix::GetData(), CIccSparseMatrix::GetRowStart(), icSparseMatrixFloatNum, and CIccSparseMatrix::Rows().

+ Here is the call graph for this function:

◆ GetBytesPerMatrix()

icUInt32Number CIccTagSparseMatrixArray::GetBytesPerMatrix ( ) const
inline

Definition at line 852 of file IccTagBasic.h.

852{ return m_nChannelsPerMatrix*sizeof(icFloatNumber); }

◆ GetChannelsPerMatrix()

icUInt32Number CIccTagSparseMatrixArray::GetChannelsPerMatrix ( ) const
inline

Definition at line 851 of file IccTagBasic.h.

851{ return m_nChannelsPerMatrix; }

Referenced by CIccArrayNamedColor::Validate().

+ Here is the caller graph for this function:

◆ GetClassName()

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

Reimplemented from CIccTag.

Reimplemented in CIccTagXmlSparseMatrixArray.

Definition at line 842 of file IccTagBasic.h.

842{ return "CIccTagChromaticity"; }

◆ GetMatrixType()

icSparseMatrixType CIccTagSparseMatrixArray::GetMatrixType ( ) const
inline

Definition at line 857 of file IccTagBasic.h.

857{ return m_nMatrixType; }

◆ GetNumMatrices()

icUInt32Number CIccTagSparseMatrixArray::GetNumMatrices ( ) const
inline

Returns the number of matrices in the array.

Definition at line 850 of file IccTagBasic.h.

850{ return m_nSize; }

◆ GetNumValues()

virtual icUInt32Number CIccTagSparseMatrixArray::GetNumValues ( ) const
inlinevirtual

Implements CIccTagNumArray.

Definition at line 866 of file IccTagBasic.h.

866{ return GetNumMatrices(); }
icUInt32Number GetNumMatrices() const
Returns the number of matrices in the array.

◆ GetSparseMatrix()

bool CIccTagSparseMatrixArray::GetSparseMatrix ( CIccSparseMatrix & mtx,
int nIndex,
bool bInitFromData = true )

Name: CIccTagSparseMatrixArray::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

Definition at line 4995 of file IccTagBasic.cpp.

4996{
4997 if (nIndex<0 || nIndex>(int)m_nSize) {
4998 mtx.Reset(NULL, 0, icSparseMatrixFloatNum, false);
4999 return false;
5000 }
5001
5002 icUInt32Number nBytesPerMatrix = GetBytesPerMatrix();
5003
5004 mtx.Reset(m_RawData+nIndex*GetBytesPerMatrix(), nBytesPerMatrix, icSparseMatrixFloatNum, bInitFromData);
5005
5006 return true;
5007}
void Reset(void *pMatrix, icUInt32Number nSize, icSparseMatrixType nType, bool bInitFromData=true)

References icSparseMatrixFloatNum, and CIccSparseMatrix::Reset().

+ Here is the call graph for this function:

◆ GetType()

virtual icTagTypeSignature CIccTagSparseMatrixArray::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 841 of file IccTagBasic.h.

@ icSigSparseMatrixArrayType

References icSigSparseMatrixArrayType.

◆ GetValues()

bool CIccTagSparseMatrixArray::GetValues ( icFloatNumber * DstVector,
icUInt32Number nStart = 0,
icUInt32Number nVectorSize = 1 ) const
virtual

Implements CIccTagNumArray.

Definition at line 5009 of file IccTagBasic.cpp.

5010{
5011 icUInt32Number nBytesPerMatrix = GetBytesPerMatrix();
5012 if (nVectorSize!=nBytesPerMatrix)
5013 return false;
5014 if (nStart % nBytesPerMatrix != 0)
5015 return false;
5016
5017 if (nStart / nBytesPerMatrix > m_nSize)
5018 return false;
5019
5020 memcpy(DstVector, m_RawData+nStart, nVectorSize);
5021 return true;
5022}

◆ Interpolate()

bool CIccTagSparseMatrixArray::Interpolate ( icFloatNumber * DstVector,
icFloatNumber pos,
icUInt32Number nVectorSize = 1,
icFloatNumber * zeroVals = NULL ) const
virtual

Name: CIccTagSparseMatrixArray::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 5036 of file IccTagBasic.cpp.

5038{
5039 icUInt32Number nMatrix = m_nSize;
5040
5041 if (!nMatrix || nVectorSize != GetBytesPerMatrix())
5042 return false;
5043
5044 if (zeroVals)
5045 nMatrix ++;
5046 else if (nMatrix<=1)
5047 return false;
5048
5049 if (pos<0.0)
5050 pos=0.0;
5051 if (pos>1.0)
5052 pos=1.0;
5053
5054 icFloatNumber fpos = (icFloatNumber)(nMatrix-1) * pos;
5055 icUInt32Number iPos = (icUInt32Number)fpos;
5056 icFloatNumber x = fpos - iPos;
5057
5058 if (iPos == nMatrix-1) {
5059 iPos--;
5060 x = (icFloatNumber)1.0;
5061 }
5062
5063 icUInt8Number *lo, *hi;
5064
5065 if (zeroVals) {
5066 if (!iPos) {
5067 lo = (icUInt8Number*)zeroVals;
5068 hi = m_RawData;
5069 }
5070 else {
5071 lo = &m_RawData[(iPos-1)*nVectorSize];
5072 hi = &lo[nVectorSize];
5073 }
5074 }
5075 else {
5076 lo = &m_RawData[iPos*nVectorSize];
5077 hi = &lo[nVectorSize];
5078 }
5079
5080 CIccSparseMatrix mlo(lo, nVectorSize, icSparseMatrixFloatNum, true);
5081 CIccSparseMatrix mhi(hi, nVectorSize, icSparseMatrixFloatNum, true);
5082 CIccSparseMatrix dst((icUInt8Number*)DstVector, nVectorSize, icSparseMatrixFloatNum, false);
5083
5084 if (mlo.Rows()!=mhi.Rows() || mlo.Cols()!=mhi.Cols())
5085 return false;
5086
5087 if (!dst.Interp(1.0f-x, mlo, x, mhi))
5088 return false;
5089
5090 return true;
5091}

References CIccSparseMatrix::Cols(), icSparseMatrixFloatNum, CIccSparseMatrix::Interp(), and CIccSparseMatrix::Rows().

+ Here is the call graph for this function:

◆ IsArrayType()

virtual bool CIccTagSparseMatrixArray::IsArrayType ( )
inlinevirtual

Reimplemented from CIccTag.

Definition at line 839 of file IccTagBasic.h.

839{ return m_nSize > 1; }

◆ IsMatrixArray()

virtual bool CIccTagSparseMatrixArray::IsMatrixArray ( ) const
inlinevirtual

Implements CIccTagNumArray.

Definition at line 874 of file IccTagBasic.h.

874{ return true; }

◆ IsNumArrayType()

virtual bool CIccTagSparseMatrixArray::IsNumArrayType ( ) const
inlinevirtual

Reimplemented from CIccTag.

Definition at line 863 of file IccTagBasic.h.

863{ return true; }

◆ NewCopy()

virtual CIccTag * CIccTagSparseMatrixArray::NewCopy ( )
inlinevirtual

Definition at line 836 of file IccTagBasic.h.

836{ return new CIccTagSparseMatrixArray(*this); }
CIccTagSparseMatrixArray(int nNumMatrices=1, int nChannelsPerMatrix=4)
Name: CIccTagSparseMatrixArray::CIccTagSparseMatrixArray.

◆ operator=()

CIccTagSparseMatrixArray & CIccTagSparseMatrixArray::operator= ( const CIccTagSparseMatrixArray & ITSMA)

Name: CIccTagSparseMatrixArray::operator=.

Purpose: Copy Operator

Args: ITFN = The CIccTagSparseMatrixArray object to be copied

Definition at line 4448 of file IccTagBasic.cpp.

4449{
4450 if (&ITSMA == this)
4451 return *this;
4452
4453 m_nSize = ITSMA.m_nSize;
4455
4456 if (m_RawData)
4457 free(m_RawData);
4459 memcpy(m_RawData, ITSMA.m_RawData, m_nSize*GetBytesPerMatrix());
4460
4462
4463 return *this;
4464}

References m_bNonZeroPadding, m_nChannelsPerMatrix, m_nSize, and m_RawData.

◆ Read()

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

Name: CIccTagSparseMatrixArray::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 4497 of file IccTagBasic.cpp.

4498{
4500 icUInt16Number nChannels;
4501 icUInt16Number nMatrixType;
4502 icUInt32Number nBytesPerMatrix;
4503 icUInt32Number nNumMatrices;
4504
4505 icUInt32Number nHdrSize = sizeof(icTagTypeSignature) +
4506 sizeof(icUInt32Number) +
4507 2*sizeof(icUInt16Number) +
4508 sizeof(icUInt32Number);
4509
4510 if (nHdrSize +sizeof(icUInt16Number) > size)
4511 return false;
4512
4513 if (!pIO) {
4514 return false;
4515 }
4516
4517 if (!pIO->Read32(&sig) ||
4518 !pIO->Read32(&m_nReserved) ||
4519 !pIO->Read16(&nChannels) ||
4520 !pIO->Read16(&nMatrixType) ||
4521 !pIO->Read32(&nNumMatrices))
4522 return false;
4523
4524 m_nMatrixType = (icSparseMatrixType)nMatrixType;
4525
4526 icUInt32Number nSizeLeft = size - nHdrSize;
4527
4528 Reset(nNumMatrices, nChannels);
4529 nBytesPerMatrix = GetBytesPerMatrix();
4530
4531 if (m_nSize) {
4532 icUInt32Number pos;
4533 icUInt16Number nRows;
4534
4535 int i, j;
4536 icUInt32Number n, nAligned;
4537 CIccSparseMatrix mtx;
4538
4539 m_bNonZeroPadding = false;
4540
4541 pos = nHdrSize;
4542 for (i=0; i<(int)m_nSize; i++) {
4543 icUInt8Number *pMatrix = m_RawData + i*nBytesPerMatrix;
4544
4545 n=2*sizeof(icUInt16Number);
4546
4547 if (nSizeLeft<n)
4548 return false;
4549 if (pIO->Read16(pMatrix, 2)!=2) {
4550 return false;
4551 }
4552
4553 nSizeLeft -= n;
4554 pos += n;
4555
4556 nRows = *((icUInt16Number*)pMatrix);
4557
4558 n=(nRows+1)*sizeof(icUInt16Number);
4559
4560 if (nSizeLeft<n)
4561 return false;
4562 if (pIO->Read16(pMatrix+2*sizeof(icUInt16Number), nRows+1)!=nRows+1) {
4563 return false;
4564 }
4565
4566 nSizeLeft -= n;
4567 pos += n;
4568 mtx.Reset(pMatrix, nBytesPerMatrix, icSparseMatrixFloatNum, true);
4569
4570 if (mtx.GetNumEntries()>mtx.MaxEntries(nChannels*sizeof(icFloatNumber), mtx.Rows(), sizeof(icFloatNumber)))
4571 return false;
4572
4573 n=mtx.GetNumEntries()*sizeof(icUInt16Number);
4574
4575 if (nSizeLeft<n)
4576 return false;
4577
4578 if (pIO->Read16(mtx.GetColumnsForRow(0), mtx.GetNumEntries())!=mtx.GetNumEntries())
4579 return false;
4580
4581 nSizeLeft -= n;
4582 pos += n;
4583
4584 nAligned = ((pos+3)/4)*4;
4585 if (nAligned != pos) {
4586 n = nAligned - pos;
4587 if (nSizeLeft < n)
4588 return false;
4589
4590 char zbuf[3] = { 0 };
4591 if (pIO->Read8(&zbuf[0], n)!=n)
4592 return false;
4593 for (j=0; j<(int)n; j++) {
4594 if (zbuf[j])
4595 m_bNonZeroPadding = true;
4596 }
4597
4598 nSizeLeft -= n;
4599 pos += n;
4600 }
4601
4602 switch(m_nMatrixType) {
4604 n=mtx.GetNumEntries()*sizeof(icUInt8Number);
4605 if (nSizeLeft<n)
4606 return false;
4607
4608 if (pIO->ReadUInt8Float(mtx.GetData()->getPtr(0), mtx.GetNumEntries())!=mtx.GetNumEntries())
4609 return false;
4610
4611 break;
4612
4614 n=mtx.GetNumEntries()*sizeof(icUInt16Number);
4615 if (nSizeLeft<n)
4616 return false;
4617
4618 if (pIO->ReadUInt16Float(mtx.GetData()->getPtr(0), mtx.GetNumEntries())!=mtx.GetNumEntries())
4619 return false;
4620
4621 break;
4622
4624 n=mtx.GetNumEntries()*sizeof(icFloat16Number);
4625 if (nSizeLeft<n)
4626 return false;
4627
4628 if (pIO->ReadFloat16Float(mtx.GetData()->getPtr(0), mtx.GetNumEntries())!=mtx.GetNumEntries())
4629 return false;
4630
4631 break;
4632
4634 n=mtx.GetNumEntries()*sizeof(icFloat32Number);
4635 if (nSizeLeft<n)
4636 return false;
4637
4638 if (pIO->ReadFloat32Float(mtx.GetData()->getPtr(0), mtx.GetNumEntries())!=mtx.GetNumEntries())
4639 return false;
4640
4641 break;
4642
4643 default:
4644 return false;
4645 }
4646 nSizeLeft -= n;
4647 pos += n;
4648
4649 nAligned = ((pos+3)/4)*4;
4650 if (nAligned != pos) {
4651 n = nAligned - pos;
4652 if (nSizeLeft < n)
4653 return false;
4654
4655 icUInt8Number zbuf[3] = { 0 };
4656 if (pIO->Read8(&zbuf[0], n)!=n)
4657 return false;
4658 for (j=0; j<(int)n; j++) {
4659 if (zbuf[j])
4660 m_bNonZeroPadding = true;
4661 }
4662
4663 nSizeLeft -= n;
4664 pos += n;
4665 }
4666 }
4667 if (nSizeLeft) {
4668 icUInt8Number b;
4669 for (i=0; i<(int)nSizeLeft; i++) {
4670 if (!pIO->Read8(&b))
4671 return false;
4672 if (b)
4673 m_bNonZeroPadding = true;
4674 }
4675 }
4676 }
4677
4678 return true;
4679}
icArraySignature sig
icTagTypeSignature
icInt32Number ReadFloat16Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:269
icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:302
virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:104
icInt32Number Read16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:114
icInt32Number ReadUInt8Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:203
icInt32Number ReadUInt16Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:236
icInt32Number Read32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:143
icUInt16Number * GetColumnsForRow(icUInt16Number nRow=0) const
static icUInt32Number MaxEntries(icUInt32Number nMemSize, icUInt16Number nRows, icUInt8Number nTypeSize)
IIccSparseMatrixEntry * GetData() const
icUInt16Number Rows() const
icUInt16Number GetNumEntries() const
icUInt32Number m_nReserved
bool Reset(icUInt32Number nNumMatrices, icUInt16Number nChannelsPerMatrix)
Name: CIccTagSparseMatrixArray::Reset.
virtual icUInt8Number * getPtr(int index=0) const =0
float icFloat32Number
icSparseMatrixType
@ icSparseMatrixUInt16
@ icSparseMatrixFloat16
@ icSparseMatrixUInt8
icUInt16Number icFloat16Number
IEEE float storage numbers.

References CIccSparseMatrix::GetColumnsForRow(), CIccSparseMatrix::GetData(), CIccSparseMatrix::GetNumEntries(), IIccSparseMatrixEntry::getPtr(), icSparseMatrixFloat16, icSparseMatrixFloat32, icSparseMatrixFloatNum, icSparseMatrixUInt16, icSparseMatrixUInt8, CIccSparseMatrix::MaxEntries(), CIccIO::Read16(), CIccIO::Read32(), CIccIO::Read8(), CIccIO::ReadFloat16Float(), CIccIO::ReadFloat32Float(), CIccIO::ReadUInt16Float(), CIccIO::ReadUInt8Float(), CIccSparseMatrix::Reset(), CIccSparseMatrix::Rows(), and sig.

+ Here is the call graph for this function:

◆ Reset()

bool CIccTagSparseMatrixArray::Reset ( icUInt32Number nNumMatrices,
icUInt16Number nChannelsPerMatrix )

Name: CIccTagSparseMatrixArray::Reset.

Purpose: Sets the size of the data array erasing all previous values

Args: nNumMatrices - number of matrices numChannelsPerMatrix - Equivalent number of output channels that determines the fixed block size for each matrix

Definition at line 4962 of file IccTagBasic.cpp.

4963{
4964 if (nNumMatrices==m_nSize && nChannelsPerMatrix==m_nChannelsPerMatrix)
4965 return true;
4966
4967 m_nSize = nNumMatrices;
4968 m_nChannelsPerMatrix = nChannelsPerMatrix;
4969
4971
4973
4974 if (!m_RawData) {
4975 m_nSize = 0;
4976 return false;
4977 }
4978
4979 memset(m_RawData, 0, nSize);
4980 return true;
4981}
void * icRealloc(void *ptr, size_t size)
Name: icRealloc.
Definition IccUtil.cpp:111

References icRealloc().

+ Here is the call graph for this function:

◆ SetMatrixType()

void CIccTagSparseMatrixArray::SetMatrixType ( icSparseMatrixType nType)
inline

Definition at line 858 of file IccTagBasic.h.

858{ m_nMatrixType = nType; }

◆ Validate()

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

Name: CIccTagSparseMatrixArray::Validate.

Purpose: Validates tag data

Args: sigPath - signature path of tag in profile to validate sReport - string to put validation report results profile - pointer to profile that contains the tag

Reimplemented from CIccTag.

Definition at line 4824 of file IccTagBasic.cpp.

4825{
4827 CIccInfo Info;
4828 std::string sSigPathName = Info.GetSigPathName(sigPath);
4829
4830 switch(m_nMatrixType) {
4835 break;
4836 default:
4837 sReport += icMsgValidateCriticalError;
4838 sReport += sSigPathName;
4839 sReport += " - Invalid Sparse Matrix Type.\n";
4841
4842 }
4843
4844 bool bCheckPCS=false;
4845
4846 icSignature sig1 = icGetFirstSigPathSig(sigPath);
4847 icSignature sig2 = icGetSecondSigPathSig(sigPath);
4848
4849 if (sig1==icSigSpectralWhitePointTag) {
4850 bCheckPCS = true;
4851 }
4852
4853 if (bCheckPCS && pProfile) {
4854 if (!icIsSameColorSpaceType(pProfile->m_Header.spectralPCS, icSigSparseMatrixReflectanceData)) {
4855 sReport += icMsgValidateCriticalError;
4856 sReport += sSigPathName;
4857 sReport += " - SparseMatrix data incompatible with spectral PCS.\n";
4859 }
4860 else if (icGetSpaceSamples((icColorSpaceSignature)pProfile->m_Header.spectralPCS)!=m_nChannelsPerMatrix) {
4861 sReport += icMsgValidateCriticalError;
4862 sReport += sSigPathName;
4863 sReport += " - SparseMatrix Output channels doesn't match spectral PCS channels.\n";
4865 }
4866 }
4867
4868 if (m_bNonZeroPadding) {
4869 sReport += icMsgValidateNonCompliant;
4870 sReport += sSigPathName;
4871 sReport += " - Non zero padding in matrices used.\n";
4873 }
4874
4875 if (!m_nSize) {
4876 sReport += icMsgValidateWarning;
4877 sReport += sSigPathName;
4878 sReport += " - No Matrices Defined.\n";
4880 return rv;
4881 }
4882
4883 if (!m_RawData) {
4884 sReport += icMsgValidateCriticalError;
4885 sReport += sSigPathName;
4886 sReport += " - Data dont defined for matrices\n";
4888 return rv;
4889 }
4890
4891 icUInt16Number nRows, nCols;
4892 CIccSparseMatrix mtx;
4893 int i;
4894
4895 icUInt16Number nBytesPerMatrix = m_nChannelsPerMatrix * sizeof(icFloatNumber);
4896
4897 mtx.Reset(m_RawData, nBytesPerMatrix, icSparseMatrixFloatNum, true);
4898 nRows = mtx.Rows();
4899 nCols = mtx.Cols();
4900 icUInt32Number nMaxElements = CIccSparseMatrix::MaxEntries(nBytesPerMatrix, nRows, sizeof(icFloatNumber));
4901 char buf[128];
4902 icUInt8Number *temp = new icUInt8Number[nBytesPerMatrix];
4903
4904 for (i=0; i<(int)m_nSize; i++) {
4905 mtx.Reset(m_RawData+i*nBytesPerMatrix, nBytesPerMatrix, icSparseMatrixFloatNum, true);
4906 if (mtx.Rows() != nRows || mtx.Cols() != nCols) {
4907 sReport += icMsgValidateCriticalError;
4908 sReport += sSigPathName;
4909 sprintf(buf, " - Matrix[%d] doesn't have matching rows and columns.\n", i);
4910 sReport += buf;
4912 }
4913
4914 if (mtx.GetNumEntries()>nMaxElements) {
4915 sReport += icMsgValidateCriticalError;
4916 sReport += sSigPathName;
4917 sprintf(buf, " - Matrix[%d] entries exceeds number supported by Output channels.\n", i);
4918 sReport += buf;
4920 }
4921
4922 if (!mtx.IsValid()) {
4923 sReport += icMsgValidateCriticalError;
4924 sReport += sSigPathName;
4925 sprintf(buf, " - Matrix[%d] has an invalid matrix structure.\n", i);
4926 sReport += buf;
4928 }
4929
4930 if (i<(int)(m_nSize-1)) {
4931 CIccSparseMatrix umtx(temp, nBytesPerMatrix, icSparseMatrixFloatNum, false);
4932 CIccSparseMatrix mtx2(m_RawData+(i+1)*nBytesPerMatrix, nBytesPerMatrix, icSparseMatrixFloatNum, true);
4933
4934 umtx.Init(nRows, nCols);
4935 if (!umtx.Union(mtx, mtx2)) {
4936 sReport += icMsgValidateCriticalError;
4937 sReport += sSigPathName;
4938 sprintf(buf, " - Interpolation from Matrix[%d] exceeds number of supported Output channels.\n", i);
4939 sReport += buf;
4941 }
4942 }
4943 }
4944 delete [] temp;
4945
4946 return rv;
4947}
icValidateStatus
Definition IccDefs.h:118
@ icValidateOK
Definition IccDefs.h:119
@ icValidateWarning
Definition IccDefs.h:120
@ icValidateCriticalError
Definition IccDefs.h:122
@ icValidateNonCompliant
Definition IccDefs.h:121
icValidateStatus icMaxStatus(icValidateStatus s1, icValidateStatus s2)
Name: icMaxStatus.
Definition IccUtil.cpp:244
const char * icMsgValidateWarning
Definition IccUtil.cpp:90
icUInt32Number icGetSpaceSamples(icColorSpaceSignature sig)
Definition IccUtil.cpp:1303
icSignature icGetSecondSigPathSig(std::string sigPath)
Definition IccUtil.cpp:1238
const char * icMsgValidateNonCompliant
Definition IccUtil.cpp:91
const char * icMsgValidateCriticalError
Definition IccUtil.cpp:92
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
icUInt16Number Cols() const
#define icIsSameColorSpaceType(sig, type)
icColorSpaceSignature
Color Space Signatures.
icUInt32Number icSignature
@ icSigSparseMatrixReflectanceData
@ icSigSpectralWhitePointTag

References CIccSparseMatrix::Cols(), CIccSparseMatrix::GetNumEntries(), CIccInfo::GetSigPathName(), icGetFirstSigPathSig(), icGetSecondSigPathSig(), icGetSpaceSamples(), icIsSameColorSpaceType, icMaxStatus(), icMsgValidateCriticalError, icMsgValidateNonCompliant, icMsgValidateWarning, icSigSparseMatrixReflectanceData, icSigSpectralWhitePointTag, icSparseMatrixFloat16, icSparseMatrixFloat32, icSparseMatrixFloatNum, icSparseMatrixUInt16, icSparseMatrixUInt8, icValidateCriticalError, icValidateNonCompliant, icValidateOK, icValidateWarning, CIccSparseMatrix::Init(), CIccSparseMatrix::IsValid(), CIccSparseMatrix::MaxEntries(), CIccSparseMatrix::Reset(), CIccSparseMatrix::Rows(), and CIccSparseMatrix::Union().

+ Here is the call graph for this function:

◆ ValuePos()

bool CIccTagSparseMatrixArray::ValuePos ( icFloatNumber & DstPos,
icFloatNumber val,
bool & bNoZero ) const
virtual

Name: CIccTagSparseMatrixArray::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 5106 of file IccTagBasic.cpp.

5107{
5108 //ValuePos not supported for Sparse Matrices
5109 return false;
5110}

◆ Write()

bool CIccTagSparseMatrixArray::Write ( CIccIO * pIO)
virtual

Name: CIccTagSparseMatrixArray::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 4695 of file IccTagBasic.cpp.

4696{
4699
4700 if (!pIO)
4701 return false;
4702
4703 if (!pIO->Write32(&sig) ||
4704 !pIO->Write32(&m_nReserved) ||
4705 !pIO->Write16(&m_nChannelsPerMatrix) ||
4706 !pIO->Write16(&nTemp) ||
4707 !pIO->Write32(&m_nSize))
4708 return false;
4709
4710 icUInt32Number nBytesPerMatrix = m_nChannelsPerMatrix * sizeof(icFloatNumber);
4711 CIccSparseMatrix mtx;
4712 icUInt16Number nRows;
4713 int i, n;
4714
4715 for (i=0; i<(int)m_nSize; i++) {
4716 icUInt8Number *pMatrix = m_RawData + i*nBytesPerMatrix;
4717 mtx.Reset(pMatrix, nBytesPerMatrix, icSparseMatrixFloatNum, true);
4718 nRows = mtx.Rows();
4719
4720 n=(nRows+3)*sizeof(icUInt16Number);
4721
4722 if (pIO->Write16(pMatrix, nRows+3)!=nRows+3 ||
4723 pIO->Write16(mtx.GetColumnsForRow(0), mtx.GetNumEntries())!=mtx.GetNumEntries()) {
4724 return false;
4725 }
4726
4727 if (!pIO->Align32())
4728 return false;
4729
4730 switch(m_nMatrixType) {
4732 if (pIO->WriteUInt8Float(mtx.GetData()->getPtr(), mtx.GetNumEntries())!=mtx.GetNumEntries()) {
4733 return false;
4734 }
4735 break;
4737 if (pIO->WriteUInt16Float(mtx.GetData()->getPtr(), mtx.GetNumEntries())!=mtx.GetNumEntries()) {
4738 return false;
4739 }
4740 break;
4742 if (pIO->WriteFloat16Float(mtx.GetData()->getPtr(), mtx.GetNumEntries())!=mtx.GetNumEntries()) {
4743 return false;
4744 }
4745 break;
4747 if (pIO->WriteFloat32Float(mtx.GetData()->getPtr(), mtx.GetNumEntries())!=mtx.GetNumEntries()) {
4748 return false;
4749 }
4750 break;
4751 default:
4752 return false;
4753 }
4754
4755 if (!pIO->Align32())
4756 return false;
4757
4758 }
4759
4760 return true;
4761}
icInt32Number Write16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:122
icInt32Number WriteFloat16Float(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:285
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 WriteFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:321
icInt32Number WriteUInt8Float(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:219
icInt32Number WriteUInt16Float(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:252
virtual icTagTypeSignature GetType() const
Function: GetType()

References CIccIO::Align32(), icSparseMatrixFloat16, icSparseMatrixFloat32, icSparseMatrixFloatNum, icSparseMatrixUInt16, icSparseMatrixUInt8, CIccSparseMatrix::Reset(), sig, CIccIO::Write16(), CIccIO::Write32(), CIccIO::WriteFloat16Float(), CIccIO::WriteFloat32Float(), CIccIO::WriteUInt16Float(), and CIccIO::WriteUInt8Float().

+ Here is the call graph for this function:

Member Data Documentation

◆ m_bNonZeroPadding

bool CIccTagSparseMatrixArray::m_bNonZeroPadding
protected

Definition at line 882 of file IccTagBasic.h.

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

◆ m_nChannelsPerMatrix

icUInt16Number CIccTagSparseMatrixArray::m_nChannelsPerMatrix
protected

Definition at line 880 of file IccTagBasic.h.

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

◆ m_nMatrixType

icSparseMatrixType CIccTagSparseMatrixArray::m_nMatrixType
protected

Definition at line 877 of file IccTagBasic.h.

Referenced by CIccTagSparseMatrixArray().

◆ m_nSize

icUInt32Number CIccTagSparseMatrixArray::m_nSize
protected

Definition at line 879 of file IccTagBasic.h.

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

◆ m_RawData

icUInt8Number* CIccTagSparseMatrixArray::m_RawData
protected

Definition at line 878 of file IccTagBasic.h.

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


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