Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccMpeXml.cpp File Reference

File: IccMpeXml.cpp. More...

#include "IccTagXml.h"
#include "IccMpeXml.h"
#include "IccUtilXml.h"
#include "IccIoXml.h"
#include "IccCAM.h"
#include <cstring>
+ Include dependency graph for IccMpeXml.cpp:

Go to the source code of this file.

Classes

class  CIccFormulaCurveSegmentXml
 
class  CIccSampledCalculatorCurveXml
 
class  CIccSampledCurveSegmentXml
 
class  CIccSinglSampledeCurveXml
 

Functions

CIccCLUTicCLutFromXml (xmlNode *pNode, int nIn, int nOut, icConvertType nType, std::string &parseStr)
 
icFloatNumber icGetSegPos (const char *str)
 
static char * icSegPos (char *buf, icFloatNumber pos)
 
static bool icXmlDumpColorAppearanceParams (std::string &xml, std::string blanks, CIccCamConverter *pCam)
 
static bool icXmlParseColorAppearanceParams (xmlNode *pNode, std::string &parseStr, CIccCamConverter *pCam)
 
static icCurveSetCurvePtr ParseXmlCurve (xmlNode *pNode, std::string parseStr)
 
static bool ToXmlCurve (std::string &xml, std::string blanks, icCurveSetCurvePtr pCurve)
 

Detailed Description

File: IccMpeXml.cpp.

Contains: Implementation of MultiProcessElementType Element XML conversion functionality

Version: V1

Copyright: (c) see ICC Software License

Definition in file IccMpeXml.cpp.

Function Documentation

◆ icCLutFromXml()

CIccCLUT * icCLutFromXml ( xmlNode * pNode,
int nIn,
int nOut,
icConvertType nType,
std::string & parseStr )
extern

Definition at line 3315 of file IccTagXml.cpp.

3316{
3317 CIccCLUT *pCLUT = NULL;
3318
3319 int nPrecision = 2;
3320 if (nType == icConvert8Bit)
3321 nPrecision = 1;
3322
3323 icUInt8Number nInput = (icUInt8Number)nIn;
3324 icUInt16Number nOutput = (icUInt16Number)nOut;
3325
3326 pCLUT = new CIccCLUT(nInput, nOutput, nPrecision);
3327
3328 if (!pCLUT){
3329 parseStr += "Error in creating CLUT Table. Check values of Precision, InputChannel, or OutputChannels.\n";
3330 return NULL;
3331 }
3332
3333 xmlNode *grid = icXmlFindNode(pNode->children, "GridPoints");
3334 if (grid) {
3335 CIccUInt8Array points;
3336
3337 if (points.ParseArray(grid->children)) {
3338 if (!pCLUT->Init(points.GetBuf())) {
3339 parseStr += "Error in setting the size of GridPoints. Check values of GridPoints, InputChannel, or OutputChannels.\n";
3340 delete pCLUT;
3341 return NULL;
3342 }
3343 }
3344 else {
3345 parseStr += "Error parsing GridPoints.\n";
3346 delete pCLUT;
3347 return NULL;
3348 }
3349 }
3350 else {
3351 icUInt8Number nGridGranularity;
3352
3353 xmlAttr *gridGranularity = icXmlFindAttr(pNode, "GridGranularity");
3354
3355 if (gridGranularity) {
3356 nGridGranularity = (icUInt8Number)atoi(icXmlAttrValue(gridGranularity));
3357 }
3358 else {
3359 delete pCLUT;
3360 return NULL;
3361 }
3362 if (!pCLUT->Init(nGridGranularity)) {
3363 parseStr += "Error in setting the size of GridGranularity. Check values of GridGranularity, InputChannel, or OutputChannels.\n";
3364 delete pCLUT;
3365 return NULL;
3366 }
3367 }
3368
3369 xmlNode *table = icXmlFindNode(pNode->children, "TableData");
3370
3371 if (table) {
3372 if (nType == icConvertVariable) {
3373 const char *precision = icXmlAttrValue(table, "Precision");
3374 if (precision && atoi(precision) == 1) {
3375 nType = icConvert8Bit;
3376 pCLUT->SetPrecision(1);
3377 }
3378 else {
3379 nType = icConvert16Bit;
3380 pCLUT->SetPrecision(2);
3381 }
3382 }
3383
3384 const char *filename = icXmlAttrValue(table, "Filename");
3385 if (!filename || !filename[0]) {
3386 filename = icXmlAttrValue(table, "File");
3387 }
3388
3389 if (filename[0]) {
3390 CIccIO *file = IccOpenFileIO(filename, "rb");
3391
3392 if (!file) {
3393 // added error message
3394 parseStr += "Error! - File '";
3395 parseStr += filename;
3396 parseStr +="' not found.\n";
3397 delete pCLUT;
3398 return NULL;
3399 }
3400
3401 const char *format = icXmlAttrValue(table, "Format");
3402
3403 if (!strcmp(format, "text")) {
3404 icUInt32Number num = file->GetLength();
3405 char *buf = (char *)malloc(num);
3406
3407 if (!buf) {
3408 perror("Memory Error");
3409 parseStr += "'";
3410 parseStr += filename;
3411 parseStr += "' may not be a valid text file.\n";
3412 delete file;
3413 delete pCLUT;
3414 return NULL;
3415 }
3416
3417 //Allow for different encoding in text file than implied by the table type
3418 const char *encoding = icXmlAttrValue(table, "FileEncoding");
3419
3420 if (!strcmp(encoding, "int8"))
3421 nType = icConvert8Bit;
3422 else if (!strcmp(encoding, "int16"))
3423 nType = icConvert16Bit;
3424 else if (!strcmp(encoding, "float"))
3425 nType = icConvertFloat;
3426 else if (encoding[0]) {
3427 parseStr+= "Unknown encoding \"";
3428 parseStr+= encoding;
3429 parseStr+= "\" - using default encoding\n";
3430 }
3431
3432 if (file->Read8(buf, num)!=num) {
3433 perror("Read-File Error");
3434 parseStr += "'";
3435 parseStr += filename;
3436 parseStr += "' may not be a valid text file.\n";
3437 free(buf);
3438 delete file;
3439 delete pCLUT;
3440 return NULL;
3441 }
3442
3443 if (nType == icConvert8Bit) {
3444 CIccUInt8Array data;
3445
3446 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
3447 parseStr += "File '";
3448 parseStr += filename;
3449 parseStr += "' is not a valid text file.\n";
3450 free(buf);
3451 delete file;
3452 delete pCLUT;
3453 return NULL;
3454 }
3455
3456 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3457 parseStr += "Error! - Number of entries in file '";
3458 parseStr += filename;
3459 parseStr += "'is not equal to the size of the CLUT Table.\n";
3460 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3461 parseStr += " b. File may not be a valid text file.\n";
3462 free(buf);
3463 delete file;
3464 delete pCLUT;
3465 return NULL;
3466 }
3467 icUInt8Number *src = data.GetBuf();
3468 icFloatNumber *dst = pCLUT->GetData(0);
3469
3471 for (i=0; i<data.GetSize(); i++) {
3472 *dst++ = (icFloatNumber)(*src++) / 255.0f;
3473 }
3474 }
3475 else if (nType == icConvert16Bit) {
3476 CIccUInt16Array data;
3477
3478 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
3479 parseStr += "File '";
3480 parseStr += filename;
3481 parseStr += "' is not a valid text file.\n";
3482 free(buf);
3483 delete file;
3484 delete pCLUT;
3485 return NULL;
3486 }
3487
3488 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3489 parseStr += "Error! - Number of entries in file '";
3490 parseStr += filename;
3491 parseStr += "'is not equal to the size of the CLUT Table.\n";
3492 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3493 parseStr += " b. File may not be a valid text file.\n";
3494 free(buf);
3495 delete file;
3496 delete pCLUT;
3497 return NULL;
3498 }
3499 icUInt16Number *src = data.GetBuf();
3500 icFloatNumber *dst = pCLUT->GetData(0);
3501
3503 for (i=0; i<data.GetSize(); i++) {
3504 *dst++ = (icFloatNumber)(*src++) / 65535.0f;
3505 }
3506 }
3507 else if (nType == icConvertFloat) {
3508 CIccFloatArray data;
3509
3510 if (!data.ParseTextArrayNum(buf, num, parseStr)) {
3511 parseStr += "File '";
3512 parseStr += filename;
3513 parseStr += "' is not a valid text file.\n";
3514 free(buf);
3515 delete file;
3516 delete pCLUT;
3517 return NULL;
3518 }
3519
3520 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3521 parseStr += "Error! - Number of entries in file '";
3522 parseStr += filename;
3523 parseStr += "'is not equal to the size of the CLUT Table.\n";
3524 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3525 parseStr += " b. File may not be a valid text file.\n";
3526 free(buf);
3527 delete file;
3528 delete pCLUT;
3529 return NULL;
3530 }
3531 icFloatNumber *src = data.GetBuf();
3532 icFloatNumber *dst = pCLUT->GetData(0);
3533
3535 for (i=0; i<data.GetSize(); i++) {
3536 *dst++ = *src++;
3537 }
3538 }
3539 else {
3540 parseStr += "Error! Unknown text data type.\n";
3541 free(buf);
3542 delete file;
3543 delete pCLUT;
3544 return NULL;
3545 }
3546 free(buf);
3547 }
3548 else if (!strcmp(format, "binary")) {
3549 const char *order = icXmlAttrValue(table, "Endian");
3550 bool little_endian = !strcmp(order, "little");
3551
3552 if (nType==icConvertVariable) {
3553 //Allow encoding to be defined
3554 const char *encoding = icXmlAttrValue(table, "FileEncoding");
3555
3556 if (!strcmp(encoding, "int8"))
3557 nType = icConvert8Bit;
3558 else if (!strcmp(encoding, "int16"))
3559 nType = icConvert16Bit;
3560 else if (!strcmp(encoding, "float"))
3561 nType = icConvertFloat;
3562 else if (encoding[0]) {
3563 parseStr+= "Unknown encoding \"";
3564 parseStr+= encoding;
3565 parseStr+= "\" - using int16.\n";
3566 nType = icConvert16Bit;
3567 }
3568 else {
3569 parseStr+= "CLUT TableData Encoding type not specified.\n";
3570 }
3571 }
3572
3573 if (nType == icConvert8Bit){
3574 icUInt32Number num = file->GetLength();
3575 icUInt8Number value;
3576 // if number of entries in file is not equal to size of CLUT table, flag as error
3577 if (num!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3578 parseStr += "Error! - Number of entries in file '";
3579 parseStr += filename;
3580 parseStr += "'is not equal to the size of the CLUT Table.\n";
3581 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3582 parseStr += " b. File may not be a valid binary file.\n";
3583 delete file;
3584 delete pCLUT;
3585 return NULL;
3586 }
3587 icFloatNumber *dst = pCLUT->GetData(0);
3589 for (i=0; i<num; i++) {
3590 if (!file->Read8(&value)) {
3591 perror("Read-File Error");
3592 parseStr += "'";
3593 parseStr += filename;
3594 parseStr += "' may not be a valid binary file.\n";
3595 delete file;
3596 delete pCLUT;
3597 return NULL;
3598 }
3599 *dst++ = (icFloatNumber)value / 255.0f;
3600 }
3601 }
3602 else if (nType == icConvert16Bit){
3603 icUInt32Number num = file->GetLength() / sizeof(icUInt16Number);
3604 icUInt16Number value;
3605 icUInt8Number *ptr = (icUInt8Number*)&value;
3606
3607 if (num<pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3608 parseStr += "Error! - Number of entries in file '";
3609 parseStr += filename;
3610 parseStr += "'is not equal to the size of the CLUT Table.\n";
3611 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3612 parseStr += " b. File may not be a valid binary file.\n";
3613 delete file;
3614 delete pCLUT;
3615 return NULL;
3616 }
3617 icFloatNumber *dst = pCLUT->GetData(0);
3618
3620 for (i=0; i<num; i++) {
3621 if (!file->Read16(&value)) { //this assumes data is big endian
3622 perror("Read-File Error");
3623 parseStr += "'";
3624 parseStr += filename;
3625 parseStr += "' may not be a valid binary file.\n";
3626 delete file;
3627 delete pCLUT;
3628 return NULL;
3629 }
3630#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
3631 if (little_endian) {
3632#else
3633 if (!little_endian) {
3634#endif
3635 icUInt8Number t = ptr[0];
3636 ptr[0] = ptr[1];
3637 ptr[1] = t;
3638 }
3639 *dst++ = (icFloatNumber)value / 65535.0f;
3640 }
3641 }
3642 else if (nType == icConvertFloat){
3643 icUInt32Number num = file->GetLength()/sizeof(icFloat32Number);
3644 icFloat32Number value;
3645 icUInt8Number *ptr = (icUInt8Number*)&value;
3646
3647 if (num<pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3648 parseStr += "Error! - Number of entries in file '";
3649 parseStr += filename;
3650 parseStr += "'is not equal to the size of the CLUT Table.\n";
3651 parseStr += " a. Check values of GridGranularity/GridPoints, InputChannel, or OutputChannels.\n";
3652 parseStr += " b. File may not be a valid binary file.\n";
3653 delete file;
3654 delete pCLUT;
3655 return NULL;
3656 }
3657 icFloatNumber *dst = pCLUT->GetData(0);
3658
3660 for (i=0; i<num; i++) {
3661 if (!file->ReadFloat32Float(&value)) { //this assumes data is big endian
3662 perror("Read-File Error");
3663 parseStr += "'";
3664 parseStr += filename;
3665 parseStr += "' may not be a valid binary file.\n";
3666 delete file;
3667 delete pCLUT;
3668 return NULL;
3669 }
3670#ifdef ICC_BYTE_ORDER_LITTLE_ENDIAN
3671 if (little_endian) {
3672#else
3673 if (!little_endian) {
3674#endif
3675 icUInt8Number tmp;
3676 tmp = ptr[0]; ptr[0] = ptr[3]; ptr[3] = tmp;
3677 tmp = ptr[1]; ptr[1] = ptr[2]; ptr[2] = tmp;
3678 }
3679 *dst++ = value;
3680 }
3681 }
3682 else {
3683 parseStr += "Error! Unknown binary data type.\n";
3684 delete file;
3685 delete pCLUT;
3686 return NULL;
3687 }
3688
3689 }
3690 else {
3691 parseStr += "Error! Unknown Format type.\n";
3692 delete pCLUT;
3693 return NULL;
3694 }
3695
3696 delete file;
3697 }
3698 else { // no file
3699 if (nType == icConvert8Bit) {
3700 CIccUInt8Array data;
3701
3702 if (!data.ParseArray(table->children)) {
3703 parseStr += "Error! - unable to parse data in CLUT.\n";
3704 delete pCLUT;
3705 return NULL;
3706 }
3707
3708 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3709 parseStr += "Error! - Number of entries is not equal to the size of the CLUT Table.\n";
3710 delete pCLUT;
3711 return NULL;
3712 }
3713 icUInt8Number *src = data.GetBuf();
3714 icFloatNumber *dst = pCLUT->GetData(0);
3715
3717 for (i=0; i<data.GetSize(); i++) {
3718 *dst++ = (icFloatNumber)(*src++) / 255.0f;
3719 }
3720 }
3721 else if (nType == icConvert16Bit || nType==icConvertVariable) {
3722 CIccUInt16Array data;
3723
3724 if (!data.ParseArray(table->children)) {
3725 parseStr += "Error! - unable to parse data in CLUT.\n";
3726 delete pCLUT;
3727 return NULL;
3728 }
3729
3730 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3731 parseStr += "Error! - Number of entries is not equal to the size of the CLUT Table.\n";
3732 delete pCLUT;
3733 return NULL;
3734 }
3735 icUInt16Number *src = data.GetBuf();
3736 icFloatNumber *dst = pCLUT->GetData(0);
3737
3739 for (i=0; i<data.GetSize(); i++) {
3740 *dst++ = (icFloatNumber)(*src++) / 65535.0f;
3741 }
3742 }
3743 else if (nType == icConvertFloat){
3744 CIccFloatArray data;
3745
3746 if (!data.ParseArray(table->children)) {
3747 parseStr += "Error! - unable to parse data in CLUT.\n";
3748 delete pCLUT;
3749 return NULL;
3750 }
3751
3752 if (data.GetSize()!=pCLUT->NumPoints()*pCLUT->GetOutputChannels()) {
3753 parseStr += "Error! - Number of entries is not equal to the size of the CLUT Table.\n";
3754 delete pCLUT;
3755 return NULL;
3756 }
3757 icFloatNumber *src = data.GetBuf();
3758 icFloatNumber *dst = pCLUT->GetData(0);
3759
3761 for (i=0; i<data.GetSize(); i++) {
3762 *dst++ = *src++;
3763 }
3764 }
3765 else {
3766 parseStr += "Error! Unknown table data type.";
3767 delete pCLUT;
3768 return NULL;
3769 }
3770 }
3771 }
3772 else {
3773 parseStr += "Error! Cannot find table data.";
3774 delete pCLUT;
3775 return NULL;
3776 }
3777
3778 return pCLUT;
3779}
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
xmlAttr * icXmlFindAttr(xmlNode *pNode, const char *szAttrName)
xmlNode * icXmlFindNode(xmlNode *pNode, const char *szNodeName)
const char * icXmlAttrValue(xmlAttr *attr, const char *szDefault)
@ icConvert8Bit
@ icConvertFloat
@ icConvert16Bit
@ icConvertVariable
unsigned int icUInt32Number
Class: CIccCLUT.
Definition IccTagLut.h:326
icUInt16Number GetOutputChannels() const
Definition IccTagLut.h:357
icUInt32Number NumPoints() const
Definition IccTagLut.h:348
void SetPrecision(icUInt8Number nPrecision)
Definition IccTagLut.h:382
icFloatNumber * GetData(int index)
Definition IccTagLut.h:347
bool Init(icUInt8Number nGridPoints, icUInt32Number nMaxSize=0, icUInt8Number nBytesPerPoint=4)
Name: CIccCLUT::Init.
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
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

References CIccXmlArrayType< T, Tsig >::GetBuf(), CIccCLUT::GetData(), CIccIO::GetLength(), CIccCLUT::GetOutputChannels(), CIccXmlArrayType< T, Tsig >::GetSize(), icConvert16Bit, icConvert8Bit, icConvertFloat, icConvertVariable, IccOpenFileIO(), icXmlAttrValue(), icXmlFindAttr(), icXmlFindNode(), CIccCLUT::Init(), CIccCLUT::NumPoints(), CIccXmlArrayType< T, Tsig >::ParseArray(), CIccXmlArrayType< T, Tsig >::ParseTextArrayNum(), CIccIO::Read16(), CIccIO::Read8(), CIccIO::ReadFloat32Float(), and CIccCLUT::SetPrecision().

Referenced by icMBBFromXml(), CIccMpeXmlCLUT::ParseXml(), CIccMpeXmlEmissionCLUT::ParseXml(), CIccMpeXmlExtCLUT::ParseXml(), and CIccMpeXmlReflectanceCLUT::ParseXml().

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

◆ icGetSegPos()

icFloatNumber icGetSegPos ( const char * str)

Definition at line 148 of file IccMpeXml.cpp.

149{
150 if (!strncmp(str, "-inf", 4)) {
151 return icMinFloat32Number;
152 }
153 if (!strncmp(str, "+inf", 4)) {
154 return icMaxFloat32Number;
155 }
156
157 return (icFloatNumber)atof(str);
158}
#define icMinFloat32Number
#define icMaxFloat32Number
Useful macros for defining Curve Segment breakpoints.

References icMaxFloat32Number, and icMinFloat32Number.

Referenced by CIccSegmentedCurveXml::ParseXml().

+ Here is the caller graph for this function:

◆ icSegPos()

static char * icSegPos ( char * buf,
icFloatNumber pos )
static

Definition at line 136 of file IccMpeXml.cpp.

137{
138 if (pos==icMinFloat32Number)
139 strcpy(buf, "-infinity");
140 else if (pos==icMaxFloat32Number)
141 strcpy(buf, "+infinity");
142 else
143 sprintf(buf, "%.8" ICFLOATSFX, pos);
144
145 return buf;
146}
#define ICFLOATSFX
String formating macros need to match precision of icFloatNumber If precision is double change the "f...
Definition IccDefs.h:105

References ICFLOATSFX, icMaxFloat32Number, and icMinFloat32Number.

Referenced by CIccFormulaCurveSegmentXml::ToXml(), and CIccSampledCurveSegmentXml::ToXml().

+ Here is the caller graph for this function:

◆ icXmlDumpColorAppearanceParams()

static bool icXmlDumpColorAppearanceParams ( std::string & xml,
std::string blanks,
CIccCamConverter * pCam )
static

Definition at line 2054 of file IccMpeXml.cpp.

2055{
2056 char line[256];
2057 icFloatNumber xyz[3];
2058
2059 xml += blanks + "<ColorAppearanceParams>\n";
2060
2061 pCam->GetParameter_WhitePoint(&xyz[0]);
2062 sprintf(line, " <XYZNumber X=\"" icXmlFloatFmt "\" Y=\"" icXmlFloatFmt "\" Z=\"" icXmlFloatFmt "\"/>", xyz[0], xyz[1], xyz[2]);
2063
2064 xml += blanks + " <WhitePoint>\n";
2065 xml += blanks + line;
2066 xml += blanks + " </WhitePoint>\n";
2067
2068 sprintf(line, " <Luminance>" icXmlFloatFmt "</Luminance>\n", pCam->GetParameter_La());
2069 xml += blanks + line;
2070
2071 sprintf(line, " <BackgroundLuminance>" icXmlFloatFmt "</BackgroundLuminance>\n", pCam->GetParameter_Yb());
2072 xml += blanks + line;
2073
2074 sprintf(line, " <ImpactSurround>" icXmlFloatFmt "</ImpactSurround>\n", pCam->GetParameter_C());
2075 xml += blanks + line;
2076
2077 sprintf(line, " <ChromaticInductionFactor>" icXmlFloatFmt "</ChromaticInductionFactor>\n", pCam->GetParameter_Nc());
2078 xml += blanks + line;
2079
2080 sprintf(line, " <AdaptationFactor>" icXmlFloatFmt "</AdaptationFactor>\n", pCam->GetParameter_F());
2081 xml += blanks + line;
2082
2083 xml += "</ColorAppearanceParams>\n";
2084
2085 return true;
2086}
#define icXmlFloatFmt
void GetParameter_WhitePoint(icFloatNumber *whitePoint)
Definition IccCAM.cpp:420
icFloatNumber GetParameter_C()
Definition IccCAM.cpp:446
icFloatNumber GetParameter_Nc()
Definition IccCAM.cpp:454
icFloatNumber GetParameter_Yb()
Definition IccCAM.cpp:438
icFloatNumber GetParameter_F()
Definition IccCAM.cpp:462
icFloatNumber GetParameter_La()
Definition IccCAM.cpp:430

References CIccCamConverter::GetParameter_C(), CIccCamConverter::GetParameter_F(), CIccCamConverter::GetParameter_La(), CIccCamConverter::GetParameter_Nc(), CIccCamConverter::GetParameter_WhitePoint(), CIccCamConverter::GetParameter_Yb(), and icXmlFloatFmt.

Referenced by CIccMpeXmlJabToXYZ::ToXml(), and CIccMpeXmlXYZToJab::ToXml().

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

◆ icXmlParseColorAppearanceParams()

static bool icXmlParseColorAppearanceParams ( xmlNode * pNode,
std::string & parseStr,
CIccCamConverter * pCam )
static

Definition at line 2088 of file IccMpeXml.cpp.

2089{
2090 xmlNode *pChild = icXmlFindNode(pNode, "WhitePoint");
2091 if (!pChild) {
2092 parseStr += "Unable to find CAM Whitepoint\n";
2093 return false;
2094 }
2095
2096 xmlNode *xyzNode = icXmlFindNode(pChild->children, "XYZNumber");
2097
2098 if (!xyzNode) {
2099 parseStr += "Unable to find valid CAM WhitePoint XYZ\n";
2100 return false;
2101 }
2102
2103 xmlAttr *x = icXmlFindAttr(xyzNode, "X");
2104 xmlAttr *y = icXmlFindAttr(xyzNode, "Y");
2105 xmlAttr *z = icXmlFindAttr(xyzNode, "Z");
2106
2107 icFloatNumber xyz[3];
2108 if (x && y && z) {
2109 xyz[0] = (icFloatNumber)atof(icXmlAttrValue(x));
2110 xyz[1] = (icFloatNumber)atof(icXmlAttrValue(y));
2111 xyz[2] = (icFloatNumber)atof(icXmlAttrValue(z));
2112 }
2113 else {
2114 parseStr += "Invalid CAM WhitePoint XYZNumber\n";
2115 return false;
2116 }
2117 pCam->SetParameter_WhitePoint(&xyz[0]);
2118
2119 pChild = icXmlFindNode(pNode, "Luminance");
2120 if (!pChild || !pChild->children || !pChild->children->content) {
2121 parseStr += "Invalid CAM Luminance\n";
2122 return false;
2123 }
2124 pCam->SetParameter_La((icFloatNumber)atof((const char*)pChild->children->content));
2125
2126 pChild = icXmlFindNode(pNode, "BackgroundLuminance");
2127 if (!pChild || !pChild->children || !pChild->children->content) {
2128 parseStr += "Invalid CAM Luminance\n";
2129 return false;
2130 }
2131 pCam->SetParameter_Yb((icFloatNumber)atof((const char*)pChild->children->content));
2132
2133 pChild = icXmlFindNode(pNode, "ImpactSurround");
2134 if (!pChild || !pChild->children || !pChild->children->content) {
2135 parseStr += "Invalid CAM ImpactSurround\n";
2136 return false;
2137 }
2138 pCam->SetParameter_C((icFloatNumber)atof((const char*)pChild->children->content));
2139
2140 pChild = icXmlFindNode(pNode, "ChromaticInductionFactor");
2141 if (!pChild || !pChild->children || !pChild->children->content) {
2142 parseStr += "Invalid CAM ChromaticInductionFactor\n";
2143 return false;
2144 }
2145 pCam->SetParameter_Nc((icFloatNumber)atof((const char*)pChild->children->content));
2146
2147 pChild = icXmlFindNode(pNode, "AdaptationFactor");
2148 if (!pChild || !pChild->children || !pChild->children->content) {
2149 parseStr += "Invalid CAM AdaptationFactor\n";
2150 return false;
2151 }
2152 pCam->SetParameter_F((icFloatNumber)atof((const char*)pChild->children->content));
2153
2154 return true;
2155}
void SetParameter_Nc(icFloatNumber Nc)
Definition IccCAM.cpp:402
void SetParameter_La(icFloatNumber La)
Definition IccCAM.cpp:375
void SetParameter_F(icFloatNumber F)
Definition IccCAM.cpp:411
void SetParameter_C(icFloatNumber c)
Definition IccCAM.cpp:393
void SetParameter_Yb(icFloatNumber YB)
Definition IccCAM.cpp:384
void SetParameter_WhitePoint(icFloatNumber *whitePoint)
Definition IccCAM.cpp:364

References icXmlAttrValue(), icXmlFindAttr(), icXmlFindNode(), CIccCamConverter::SetParameter_C(), CIccCamConverter::SetParameter_F(), CIccCamConverter::SetParameter_La(), CIccCamConverter::SetParameter_Nc(), CIccCamConverter::SetParameter_WhitePoint(), and CIccCamConverter::SetParameter_Yb().

Referenced by CIccMpeXmlJabToXYZ::ParseXml(), and CIccMpeXmlXYZToJab::ParseXml().

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

◆ ParseXmlCurve()

static icCurveSetCurvePtr ParseXmlCurve ( xmlNode * pNode,
std::string parseStr )
static

Definition at line 1085 of file IccMpeXml.cpp.

1086{
1087 icCurveSetCurvePtr rv = NULL;
1088
1089 if (!strcmp((const char*)pNode->name, "SegmentedCurve")) {
1091
1092 if (pCurve->ParseXml(pNode, parseStr)) {
1093 rv = pCurve;
1094 }
1095 else
1096 delete pCurve;
1097 }
1098 else if (!strcmp((const char*)pNode->name, "SingleSampledCurve")) {
1100
1101 if (pCurve->ParseXml(pNode, parseStr)) {
1102 rv = pCurve;
1103 }
1104 else
1105 delete pCurve;
1106 }
1107 else if (!strcmp((const char*)pNode->name, "SampledCalculatorCurve")) {
1109
1110 if (pCurve->ParseXml(pNode, parseStr)) {
1111 rv = pCurve;
1112 }
1113 else
1114 delete pCurve;
1115 }
1116
1117 return rv;
1118}
Class: CIccCurveSetCurve.
bool ParseXml(xmlNode *pNode, std::string &parseStr)
bool ParseXml(xmlNode *pNode, std::string &parseStr)
bool ParseXml(xmlNode *pNode, std::string &parseStr)

References CIccSampledCalculatorCurveXml::ParseXml(), CIccSegmentedCurveXml::ParseXml(), and CIccSinglSampledeCurveXml::ParseXml().

Referenced by CIccMpeXmlCurveSet::ParseXml(), and CIccMpeXmlToneMap::ParseXml().

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

◆ ToXmlCurve()

static bool ToXmlCurve ( std::string & xml,
std::string blanks,
icCurveSetCurvePtr pCurve )
static

Definition at line 1022 of file IccMpeXml.cpp.

1023{
1024 if (pCurve->GetType() == icSigSingleSampledCurve) {
1026
1027 if (!(m_ptr->ToXml(xml, blanks + " ")))
1028 return false;
1029 }
1030 else if (pCurve->GetType() == icSigSegmentedCurve) {
1032
1033 if (!(m_ptr->ToXml(xml, blanks + " ")))
1034 return false;
1035 }
1036 else if (pCurve->GetType() == icSigSampledCalculatorCurve) {
1038
1039 if (!(m_ptr->ToXml(xml, blanks + " ")))
1040 return false;
1041 }
1042 else
1043 return false;
1044
1045 return true;
1046}
virtual icCurveElemSignature GetType() const =0
bool ToXml(std::string &xml, std::string blanks)
bool ToXml(std::string &xml, std::string blanks)
bool ToXml(std::string &xml, std::string blanks)
@ icSigSegmentedCurve
@ icSigSampledCalculatorCurve
@ icSigSingleSampledCurve

References CIccCurveSetCurve::GetType(), icSigSampledCalculatorCurve, icSigSegmentedCurve, icSigSingleSampledCurve, CIccSampledCalculatorCurveXml::ToXml(), CIccSegmentedCurveXml::ToXml(), and CIccSinglSampledeCurveXml::ToXml().

Referenced by CIccMpeXmlCurveSet::ToXml(), and CIccMpeXmlToneMap::ToXml().

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