Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CIccSampledCurveSegmentXml Class Reference
+ Inheritance diagram for CIccSampledCurveSegmentXml:
+ Collaboration diagram for CIccSampledCurveSegmentXml:

Public Member Functions

 CIccSampledCurveSegmentXml (icFloatNumber start, icFloatNumber end)
 
bool ParseXml (xmlNode *pNode, std::string &parseStr)
 
bool ToXml (std::string &xml, std::string blanks)
 
- Public Member Functions inherited from CIccSampledCurveSegment
virtual icFloatNumber Apply (icFloatNumber v) const
 Name: CIccSampledCurveSegment::Apply.
 
virtual bool Begin (CIccCurveSegment *pPrevSeg)
 Name: CIccSampledCurveSegment::Begin.
 
 CIccSampledCurveSegment (const CIccSampledCurveSegment &ITPC)
 Name: CIccSampledCurveSegment::CIccSampledCurveSegment.
 
 CIccSampledCurveSegment (icFloatNumber start, icFloatNumber end)
 Name: CIccSampledCurveSegment::CIccSampledCurveSegment.
 
virtual void Describe (std::string &sDescription, int nVerboseness)
 Name: CIccSampledCurveSegment::Describe.
 
virtual const icCharGetClassName () const
 
virtual icFloatNumberGetSamples ()
 
virtual icUInt32Number GetSize ()
 
virtual icCurveSegSignature GetType () const
 
virtual CIccCurveSegmentNewCopy () const
 
CIccSampledCurveSegmentoperator= (const CIccSampledCurveSegment &ParamCurveTag)
 Name: &CIccSampledCurveSegment::operator=.
 
virtual bool Read (icUInt32Number size, CIccIO *pIO)
 Name: CIccSampledCurveSegment::Read.
 
virtual bool SetSize (icUInt32Number nSize, bool bZeroAlloc=true)
 Name: CIccSampledCurveSegment::SetSize.
 
virtual icValidateStatus Validate (std::string sigPath, std::string &sReport, const CIccTagMultiProcessElement *pMPE=NULL, const CIccProfile *pProfile=NULL) const
 Name: CIccSampledCurveSegment::Validate.
 
virtual bool Write (CIccIO *pIO)
 Name: CIccSampledCurveSegment::Write.
 
virtual ~CIccSampledCurveSegment ()
 Name: CIccSampledCurveSegment::~CIccSampledCurveSegment.
 
- Public Member Functions inherited from CIccCurveSegment
icFloatNumber EndPoint ()
 
icFloatNumber StartPoint ()
 
virtual ~CIccCurveSegment ()
 

Additional Inherited Members

- Static Public Member Functions inherited from CIccCurveSegment
static CIccCurveSegmentCreate (icCurveSegSignature sig, icFloatNumber start, icFloatNumber end)
 Name: CIccCurveSegment::Create.
 
- Protected Attributes inherited from CIccSampledCurveSegment
icFloatNumber m_last
 
icUInt32Number m_nCount
 
icFloatNumberm_pSamples
 
icFloatNumber m_range
 
- Protected Attributes inherited from CIccCurveSegment
icFloatNumber m_endPoint
 
icUInt32Number m_nReserved
 
icFloatNumber m_startPoint
 

Detailed Description

Definition at line 258 of file IccMpeXml.cpp.

Constructor & Destructor Documentation

◆ CIccSampledCurveSegmentXml()

CIccSampledCurveSegmentXml::CIccSampledCurveSegmentXml ( icFloatNumber start,
icFloatNumber end )
inline

Definition at line 261 of file IccMpeXml.cpp.

261: CIccSampledCurveSegment(start, end) {}
CIccSampledCurveSegment(icFloatNumber start, icFloatNumber end)
Name: CIccSampledCurveSegment::CIccSampledCurveSegment.

Member Function Documentation

◆ ParseXml()

bool CIccSampledCurveSegmentXml::ParseXml ( xmlNode * pNode,
std::string & parseStr )

Definition at line 286 of file IccMpeXml.cpp.

287{
288 const char *filename = icXmlAttrValue(pNode, "Filename");
289
290 // file exists
291 if (filename[0]) {
292 CIccIO *file = IccOpenFileIO(filename, "rb");
293 if (!file){
294 parseStr += "Error! - File '";
295 parseStr += filename;
296 parseStr +="' not found.\n";
297 delete file;
298 return false;
299 }
300
301 const char *format = icXmlAttrValue(pNode, "Format");
302
303 // format is text
304 if (!strcmp(format, "text")) {
305 icUInt32Number num = file->GetLength();
306 char *buf = (char *) new char[num];
307
308 if (!buf) {
309 perror("Memory Error");
310 parseStr += "'";
311 parseStr += filename;
312 parseStr += "' may not be a valid text file.\n";
313 delete buf;
314 delete file;
315 return false;
316 }
317
318 if (file->Read8(buf, num) !=num) {
319 perror("Read-File Error");
320 parseStr += "'";
321 parseStr += filename;
322 parseStr += "' may not be a valid text file.\n";
323 delete buf;
324 delete file;
325 return false;
326 }
327
328 CIccFloatArray data;
329
330 //if (!data.ParseTextArray(buf)) {
331 if (!data.ParseTextArrayNum(buf, num, parseStr)){
332 parseStr += "File '";
333 parseStr += filename;
334 parseStr += "' is not a valid text file.\n";
335 SetSize(0);
336 delete buf;
337 delete file;
338 return false;
339 }
340
341 else {
342 SetSize(data.GetSize());
343 icFloatNumber *src = data.GetBuf();
345
347 for (i=0; i<data.GetSize(); i++) {
348 *dst = *src;
349 dst++;
350 src++;
351 }
352 }
353
354 delete buf;
355 delete file;
356 return true;
357
358 }
359 // format is binary
360 else if (!strcmp(format, "binary")) {
361 const char *order = icXmlAttrValue(pNode, "Endian");
362 bool little_endian = !strcmp(order, "little");
363
365 xmlAttr *attr = icXmlFindAttr(pNode, "StorageType");
366 if (attr) {
367 storageType = (icUInt16Number)atoi(icXmlAttrValue(attr));
368 }
369
370 if (storageType == icValueTypeUInt8){
371 icUInt32Number num = file->GetLength();
372 icUInt8Number value;
373
374 SetSize(num);
377 for (i=0; i<num; i++) {
378 if (!file->Read8(&value)) {
379 perror("Read-File Error");
380 parseStr += "'";
381 parseStr += filename;
382 parseStr += "' may not be a valid binary file.\n";
383 delete file;
384 return false;
385 }
386 *dst++ = (icFloatNumber)value / 255.0f;
387 }
388 delete file;
389 return true;
390 }
391 else if (storageType == icValueTypeUInt16){
392 icUInt32Number num = file->GetLength() / sizeof(icUInt16Number);
393 icUInt16Number value;
394 icUInt8Number *m_ptr = (icUInt8Number*)&value;
395
396 SetSize(num);
399 for (i=0; i<num; i++) {
400 if (!file->Read16(&value)) { //assumes data is big endian
401 perror("Read-File Error");
402 parseStr += "'";
403 parseStr += filename;
404 parseStr += "' may not be a valid binary file.\n";
405 delete file;
406 return false;
407 }
408#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
409 if (little_endian) {
410#else
411 if (!little_endian) {
412#endif
413 icUInt8Number t = m_ptr[0];
414 m_ptr[0] = m_ptr[1];
415 m_ptr[1] = t;
416 }
417 *dst++ = (icFloatNumber)value / 65535.0f;
418 }
419 delete file;
420 return true;
421 }
422 else if (storageType == icValueTypeFloat16){
423 icUInt32Number num = file->GetLength() / sizeof(icFloat16Number);
424 icFloat16Number value;
425 icUInt8Number *m_ptr = (icUInt8Number*)&value;
426
427 SetSize(num);
430 for (i=0; i<num; i++) {
431 if (!file->Read16(&value)) { //assumes data is big endian
432 perror("Read-File Error");
433 parseStr += "'";
434 parseStr += filename;
435 parseStr += "' may not be a valid binary file.\n";
436 delete file;
437 return false;
438 }
439#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
440 if (little_endian) {
441#else
442 if (!little_endian) {
443#endif
444 icUInt8Number t = m_ptr[0];
445 m_ptr[0] = m_ptr[1];
446 m_ptr[1] = t;
447 }
448 *dst++ = icF16toF(value);
449 }
450 delete file;
451 return true;
452 }
453 else if (storageType == icValueTypeFloat32) {
454 icUInt32Number num = file->GetLength()/sizeof(icFloat32Number);
455 icFloat32Number value;
456 icUInt8Number *m_ptr = (icUInt8Number*)&value;
457
458 SetSize(num);
460
462 for (i=0; i<num; i++) {
463 if (!file->ReadFloat32Float(&value)) { //assumes data is big endian
464 perror("Read-File Error");
465 parseStr += "'";
466 parseStr += filename;
467 parseStr += "' may not be a valid binary file.\n";
468 delete file;
469 return false;
470 }
471#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
472 if (little_endian) {
473#else
474 if (!little_endian) {
475#endif
476 icUInt8Number tmp;
477 tmp = m_ptr[0]; m_ptr[0] = m_ptr[3]; m_ptr[3] = tmp;
478 tmp = m_ptr[1]; m_ptr[1] = m_ptr[2]; m_ptr[2] = tmp;
479 }
480 *dst++ = value;
481 }
482 delete file;
483 return true;
484 }
485 else { //not 8bit/16bit/float
486 delete file;
487 return false;
488 }
489 }
490 }
491 else {
492 CIccFloatArray samples;
493
494 if (!samples.ParseArray(pNode->children)) {
495 return false;
496 }
497
498 if (!SetSize(samples.GetSize())) {
499 return false;
500 }
501
502 memcpy(m_pSamples, samples.GetBuf(), samples.GetSize() * sizeof(icFloatNumber));
503 }
504
505 return true;
506}
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
CIccIO * IccOpenFileIO(const icChar *szFilename, const char *szAttr)
Definition IccIoXml.cpp:100
icFloatNumber icF16toF(icFloat16Number num)
Definition IccUtil.cpp:629
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
unsigned int icUInt32Number
Type: Class.
Definition IccIO.h:97
icInt32Number ReadFloat32Float(void *pBufFloat, icInt32Number nNum=1)
Definition IccIO.cpp:302
virtual icInt32Number GetLength()
Definition IccIO.h:130
virtual icInt32Number Read8(void *pBuf8, icInt32Number nNum=1)
Definition IccIO.h:104
icInt32Number Read16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:114
icFloatNumber * m_pSamples
virtual bool SetSize(icUInt32Number nSize, bool bZeroAlloc=true)
Name: CIccSampledCurveSegment::SetSize.
static bool ParseArray(T *buf, icUInt32Number nBufSize, xmlNode *pNode)
bool ParseTextArrayNum(const char *szText, icUInt32Number num, std::string &parseStr)
icUInt32Number GetSize()
Definition IccUtilXml.h:166
unsigned char icUInt8Number
Number definitions.
float icFloat32Number
unsigned short icUInt16Number
icUInt16Number icFloat16Number
IEEE float storage numbers.
@ icValueTypeFloat16
@ icValueTypeUInt8
@ icValueTypeUInt16
@ icValueTypeFloat32

References CIccXmlArrayType< T, Tsig >::GetBuf(), CIccIO::GetLength(), CIccXmlArrayType< T, Tsig >::GetSize(), IccOpenFileIO(), icF16toF(), icValueTypeFloat16, icValueTypeFloat32, icValueTypeUInt16, icValueTypeUInt8, icXmlAttrValue(), icXmlFindAttr(), CIccXmlArrayType< T, Tsig >::ParseArray(), CIccXmlArrayType< T, Tsig >::ParseTextArrayNum(), CIccIO::Read16(), CIccIO::Read8(), and CIccIO::ReadFloat32Float().

Referenced by CIccSegmentedCurveXml::ParseXml().

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

◆ ToXml()

bool CIccSampledCurveSegmentXml::ToXml ( std::string & xml,
std::string blanks )

Definition at line 267 of file IccMpeXml.cpp.

268{
269 char buf[256];
270 char line[256];
271
272 sprintf(line, "<SampledSegment Start=\"%s\"", icSegPos(buf, m_startPoint));
273 xml += blanks + line;
274
275 sprintf(line, " End=\"%s\">\n",icSegPos(buf, m_endPoint));
276 xml += line;
277
279
280 xml += blanks + "</SampledSegment>\n";
281
282 return true;
283}
static char * icSegPos(char *buf, icFloatNumber pos)
@ icConvertFloat
icFloatNumber m_startPoint
icFloatNumber m_endPoint
icUInt32Number m_nCount
static bool DumpArray(std::string &xml, std::string blanks, T *buf, icUInt32Number nBufSize, icConvertType nType, icUInt8Number nColumns)

References CIccXmlArrayType< T, Tsig >::DumpArray(), icConvertFloat, and icSegPos().

+ Here is the call graph for this function:

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