IccMAX 2.1.27
Color Profile Tools
Loading...
Searching...
No Matches
IccMpeXml.cpp File Reference
#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.

Data Structures

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

References CIccCLUT::CIccCLUT(), CIccXmlArrayType< T, Tsig >::GetBuf(), CIccCLUT::GetData(), CIccIO::GetLength(), CIccCLUT::GetOutputChannels(), CIccXmlArrayType< T, Tsig >::GetSize(), icConvert16Bit, icConvert8Bit, icConvertFloat, icConvertVariable, IccOpenFileIO(), icXmlAttrValue(), icXmlAttrValue(), icXmlFindAttr(), icXmlFindNode(), CIccCLUT::Init(), 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(), CIccMpeXmlExtCLUT::ParseXml(), CIccMpeXmlEmissionCLUT::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)
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
Definition icProfileHeader.h:318
#define icMaxFloat32Number
Definition icProfileHeader.h:317

Referenced by CIccSegmentedCurveXml::ParseXml().

+ Here is the caller graph for this function:

◆ icSegPos()

static char * icSegPos ( char *  buf,
icFloatNumber  pos 
)
static
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
Definition IccDefs.h:106

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
2060{
2061 char line[256];
2062 icFloatNumber xyz[3];
2063
2064 xml += blanks + "<ColorAppearanceParams>\n";
2065
2066 pCam->GetParameter_WhitePoint(&xyz[0]);
2067 sprintf(line, " <XYZNumber X=\"" icXmlFloatFmt "\" Y=\"" icXmlFloatFmt "\" Z=\"" icXmlFloatFmt "\"/>", xyz[0], xyz[1], xyz[2]);
2068
2069 xml += blanks + " <WhitePoint>\n";
2070 xml += blanks + line;
2071 xml += blanks + " </WhitePoint>\n";
2072
2073 sprintf(line, " <Luminance>" icXmlFloatFmt "</Luminance>\n", pCam->GetParameter_La());
2074 xml += blanks + line;
2075
2076 sprintf(line, " <BackgroundLuminance>" icXmlFloatFmt "</BackgroundLuminance>\n", pCam->GetParameter_Yb());
2077 xml += blanks + line;
2078
2079 sprintf(line, " <ImpactSurround>" icXmlFloatFmt "</ImpactSurround>\n", pCam->GetParameter_C());
2080 xml += blanks + line;
2081
2082 sprintf(line, " <ChromaticInductionFactor>" icXmlFloatFmt "</ChromaticInductionFactor>\n", pCam->GetParameter_Nc());
2083 xml += blanks + line;
2084
2085 sprintf(line, " <AdaptationFactor>" icXmlFloatFmt "</AdaptationFactor>\n", pCam->GetParameter_F());
2086 xml += blanks + line;
2087
2088 xml += "</ColorAppearanceParams>\n";
2089
2090 return true;
2091}
#define icXmlFloatFmt
Definition IccXmlConfig.h:75
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(), and CIccCamConverter::GetParameter_Yb().

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
2094{
2095 xmlNode *pChild = icXmlFindNode(pNode, "WhitePoint");
2096 if (!pChild) {
2097 parseStr += "Unable to find CAM Whitepoint\n";
2098 return false;
2099 }
2100
2101 xmlNode *xyzNode = icXmlFindNode(pChild->children, "XYZNumber");
2102
2103 if (!xyzNode) {
2104 parseStr += "Unable to find valid CAM WhitePoint XYZ\n";
2105 return false;
2106 }
2107
2108 xmlAttr *x = icXmlFindAttr(xyzNode, "X");
2109 xmlAttr *y = icXmlFindAttr(xyzNode, "Y");
2110 xmlAttr *z = icXmlFindAttr(xyzNode, "Z");
2111
2112 icFloatNumber xyz[3];
2113 if (x && y && z) {
2114 xyz[0] = (icFloatNumber)atof(icXmlAttrValue(x));
2115 xyz[1] = (icFloatNumber)atof(icXmlAttrValue(y));
2116 xyz[2] = (icFloatNumber)atof(icXmlAttrValue(z));
2117 }
2118 else {
2119 parseStr += "Invalid CAM WhitePoint XYZNumber\n";
2120 return false;
2121 }
2122 pCam->SetParameter_WhitePoint(&xyz[0]);
2123
2124 pChild = icXmlFindNode(pNode, "Luminance");
2125 if (!pChild || !pChild->children || !pChild->children->content) {
2126 parseStr += "Invalid CAM Luminance\n";
2127 return false;
2128 }
2129 pCam->SetParameter_La((icFloatNumber)atof((const char*)pChild->children->content));
2130
2131 pChild = icXmlFindNode(pNode, "BackgroundLuminance");
2132 if (!pChild || !pChild->children || !pChild->children->content) {
2133 parseStr += "Invalid CAM Luminance\n";
2134 return false;
2135 }
2136 pCam->SetParameter_Yb((icFloatNumber)atof((const char*)pChild->children->content));
2137
2138 pChild = icXmlFindNode(pNode, "ImpactSurround");
2139 if (!pChild || !pChild->children || !pChild->children->content) {
2140 parseStr += "Invalid CAM ImpactSurround\n";
2141 return false;
2142 }
2143 pCam->SetParameter_C((icFloatNumber)atof((const char*)pChild->children->content));
2144
2145 pChild = icXmlFindNode(pNode, "ChromaticInductionFactor");
2146 if (!pChild || !pChild->children || !pChild->children->content) {
2147 parseStr += "Invalid CAM ChromaticInductionFactor\n";
2148 return false;
2149 }
2150 pCam->SetParameter_Nc((icFloatNumber)atof((const char*)pChild->children->content));
2151
2152 pChild = icXmlFindNode(pNode, "AdaptationFactor");
2153 if (!pChild || !pChild->children || !pChild->children->content) {
2154 parseStr += "Invalid CAM AdaptationFactor\n";
2155 return false;
2156 }
2157 pCam->SetParameter_F((icFloatNumber)atof((const char*)pChild->children->content));
2158
2159 return true;
2160}
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
1088{
1089 icCurveSetCurvePtr rv = NULL;
1090
1091 if (!pNode)
1092 return rv;
1093
1094 if (!strcmp((const char*)pNode->name, "SegmentedCurve")) {
1096
1097 if (pCurve->ParseXml(pNode, parseStr)) {
1098 rv = pCurve;
1099 }
1100 else
1101 delete pCurve;
1102 }
1103 else if (!strcmp((const char*)pNode->name, "SingleSampledCurve")) {
1105
1106 if (pCurve->ParseXml(pNode, parseStr)) {
1107 rv = pCurve;
1108 }
1109 else
1110 delete pCurve;
1111 }
1112 else if (!strcmp((const char*)pNode->name, "SampledCalculatorCurve")) {
1114
1115 if (pCurve->ParseXml(pNode, parseStr)) {
1116 rv = pCurve;
1117 }
1118 else
1119 delete pCurve;
1120 }
1121
1122 return rv;
1123}
Definition IccMpeBasic.h:215
Definition IccMpeXml.cpp:509
bool ParseXml(xmlNode *pNode, std::string &parseStr)
Definition IccMpeXml.cpp:554
Definition IccMpeXml.cpp:603
bool ParseXml(xmlNode *pNode, std::string &parseStr)
Definition IccMpeXml.cpp:636
Definition IccMpeXml.h:102
bool ParseXml(xmlNode *pNode, std::string &parseStr)
Definition IccMpeXml.cpp:986

References CIccSampledCalculatorCurveXml::CIccSampledCalculatorCurveXml(), CIccSinglSampledeCurveXml::CIccSinglSampledeCurveXml(), CIccSampledCalculatorCurveXml::ParseXml(), CIccSinglSampledeCurveXml::ParseXml(), and CIccSegmentedCurveXml::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
1025{
1026 if (pCurve->GetType() == icSigSingleSampledCurve) {
1028
1029 if (!(m_ptr->ToXml(xml, blanks + " ")))
1030 return false;
1031 }
1032 else if (pCurve->GetType() == icSigSegmentedCurve) {
1034
1035 if (!(m_ptr->ToXml(xml, blanks + " ")))
1036 return false;
1037 }
1038 else if (pCurve->GetType() == icSigSampledCalculatorCurve) {
1040
1041 if (!(m_ptr->ToXml(xml, blanks + " ")))
1042 return false;
1043 }
1044 else
1045 return false;
1046
1047 return true;
1048}
@ icSigSegmentedCurve
Definition icProfileHeader.h:1057
@ icSigSampledCalculatorCurve
Definition icProfileHeader.h:1059
@ icSigSingleSampledCurve
Definition icProfileHeader.h:1058
virtual icCurveElemSignature GetType() const =0
bool ToXml(std::string &xml, std::string blanks)
Definition IccMpeXml.cpp:517
bool ToXml(std::string &xml, std::string blanks)
Definition IccMpeXml.cpp:611
bool ToXml(std::string &xml, std::string blanks)
Definition IccMpeXml.cpp:964

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

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

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