clang -cc1 -cc1 -triple x86_64-apple-macosx14.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name IccArrayBasic.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=osx -analyzer-checker=security.insecureAPI.decodeValueOfObjCType -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -mframe-pointer=all -ffp-contract=on -fno-rounding-math -funwind-tables=2 -target-sdk-version=14.0 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu generic -debugger-tuning=lldb -target-linker-version 1015.7 -fprofile-instrument=clang -fcoverage-mapping -fcoverage-compilation-dir=/Users/xss/DemoIccMAX-hoyt-master/build/IccProfLib -resource-dir /usr/local/Cellar/llvm/17.0.3/lib/clang/17 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -D IccProfLib2_EXPORTS -I /Users/xss/DemoIccMAX-hoyt-master/build/Cmake/../../IccProfLib -I /Developer/Headers/FlatCarbon -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/System/Library/Frameworks -internal-isystem /usr/local/Cellar/llvm/17.0.3/bin/../include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/include -internal-isystem /usr/local/Cellar/llvm/17.0.3/lib/clang/17/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include -std=gnu++17 -fdeprecated-macro -fdebug-compilation-dir=/Users/xss/DemoIccMAX-hoyt-master/build/IccProfLib -ferror-limit 19 -fsanitize=address -fsanitize-system-ignorelist=/usr/local/Cellar/llvm/17.0.3/lib/clang/17/share/asan_ignorelist.txt -fno-sanitize-memory-param-retval -fsanitize-address-use-after-scope -fsanitize-address-globals-dead-stripping -fno-assume-sane-operator-new -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fmax-type-align=16 -analyzer-output=html -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/l9/sd9kj1px4yq2wc5_lkwhlt6w0000gn/T/scan-build-2023-10-28-102616-57860-1 -x c++ /Users/xss/DemoIccMAX-hoyt-master/IccProfLib/IccArrayBasic.cpp
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | #ifdef WIN32 |
| 72 | #pragma warning( disable: 4786) //disable warning in <list.h> |
| 73 | #include <windows.h> |
| 74 | #endif |
| 75 | #include <stdio.h> |
| 76 | #include <math.h> |
| 77 | #include <string.h> |
| 78 | #include <stdlib.h> |
| 79 | #include "IccArrayBasic.h" |
| 80 | #include "IccStructBasic.h" |
| 81 | #include "IccUtil.h" |
| 82 | #include "IccArrayFactory.h" |
| 83 | |
| 84 | #ifndef __min |
| 85 | #include <algorithm> |
| 86 | using std::min; |
| 87 | #define __min min |
| 88 | #endif |
| 89 | |
| 90 | #ifdef USEREFICCMAXNAMESPACE |
| 91 | namespace refIccMAX { |
| 92 | #endif |
| 93 | |
| 94 | |
| 95 | CIccArrayUnknown::CIccArrayUnknown(CIccTagArray *pTagArray, icArraySignature sigArray) |
| 96 | { |
| 97 | m_pTag = pTagArray; |
| 98 | m_sig = sigArray; |
| 99 | } |
| 100 | |
| 101 | |
| 102 | CIccArrayUnknown::~CIccArrayUnknown() |
| 103 | { |
| 104 | |
| 105 | } |
| 106 | |
| 107 | |
| 108 | IIccArray* CIccArrayUnknown::NewCopy(CIccTagArray *pTagArray) const |
| 109 | { |
| 110 | CIccArrayUnknown *rv = new CIccArrayUnknown(pTagArray); |
| 111 | |
| 112 | return rv; |
| 113 | } |
| 114 | |
| 115 | |
| 116 | bool CIccArrayUnknown::Describe(std::string &sDescription) const |
| 117 | { |
| 118 | return false; |
| 119 | } |
| 120 | |
| 121 | |
| 122 | icValidateStatus CIccArrayUnknown::Validate(std::string sigPath, std::string &sReport, const CIccProfile* pProfile) const |
| 123 | { |
| 124 | icValidateStatus rv = icValidateOK; |
| 125 | |
| 126 | if (m_pTag) { |
| 127 | icUInt32Number i; |
| 128 | |
| 129 | sReport += "Unknown tag array type!\n"; |
| 130 | for (i=0; i<m_pTag->GetSize(); i++) { |
| 131 | CIccTag *pTag = m_pTag->GetIndex(i); |
| 132 | if (!pTag) { |
| 133 | rv = icMaxStatus(rv, icValidateWarning); |
| 134 | char buf[80]; |
| 135 | sprintf(buf, "Tag at index %d is NULL\r\n", i); |
| 136 | sReport += buf; |
| 137 | } |
| 138 | else { |
| 139 | rv = icMaxStatus(rv, pTag->Validate(sigPath+icGetSigPath(pTag->GetType()), sReport, pProfile)); |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | else { |
| 144 | sReport += "Array Handler not connected to CIccTagArray object!"; |
| 145 | |
| 146 | rv = icValidateWarning; |
| 147 | } |
| 148 | |
| 149 | return rv; |
| 150 | } |
| 151 | |
| 152 | |
| 153 | CIccArrayColorantInfo::CIccArrayColorantInfo(CIccTagArray *pTagArray) |
| 154 | { |
| 155 | m_pTag = pTagArray; |
| 156 | m_sig = icSigColorantInfoArray; |
| 157 | } |
| 158 | |
| 159 | |
| 160 | CIccArrayColorantInfo::~CIccArrayColorantInfo() |
| 161 | { |
| 162 | |
| 163 | } |
| 164 | |
| 165 | |
| 166 | IIccArray* CIccArrayColorantInfo::NewCopy(CIccTagArray *pTagArray) const |
| 167 | { |
| 168 | CIccArrayColorantInfo *rv = new CIccArrayColorantInfo(pTagArray); |
| 169 | |
| 170 | return rv; |
| 171 | } |
| 172 | |
| 173 | |
| 174 | bool CIccArrayColorantInfo::Describe(std::string &sDescription) const |
| 175 | { |
| 176 | return false; |
| 177 | } |
| 178 | |
| 179 | |
| 180 | icValidateStatus CIccArrayColorantInfo::Validate(std::string sigPath, std::string &sReport, const CIccProfile* pProfile) const |
| 181 | { |
| 182 | icValidateStatus rv = icValidateOK; |
| 183 | |
| 184 | if (m_pTag) { |
| 185 | icUInt32Number i; |
| 186 | |
| 187 | for (i = 0; i < m_pTag->GetSize(); i++) { |
| 188 | CIccTag *pTag = m_pTag->GetIndex(i); |
| 189 | if (!pTag) { |
| 190 | rv = icMaxStatus(rv, icValidateWarning); |
| 191 | char buf[80]; |
| 192 | sprintf(buf, "Tag at index %d is NULL\r\n", i); |
| 193 | sReport += buf; |
| 194 | } |
| 195 | else { |
| 196 | if (pTag->GetTagStructType() != icSigColorantInfoStruct) { |
| 197 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 198 | char buf[80]; |
| 199 | sprintf(buf, "Tag at index %d is not a colorantInfoStruct\r\n", i); |
| 200 | sReport += buf; |
| 201 | } |
| 202 | rv = icMaxStatus(rv, pTag->Validate(sigPath + icGetSigPath(pTag->GetType()), sReport, pProfile)); |
| 203 | } |
| 204 | } |
| 205 | } |
| 206 | else { |
| 207 | sReport += "Array Handler not connected to CIccTagArray object!"; |
| 208 | |
| 209 | rv = icValidateWarning; |
| 210 | } |
| 211 | |
| 212 | return rv; |
| 213 | } |
| 214 | |
| 215 | |
| 216 | CIccArrayNamedColor::CIccArrayNamedColor(CIccTagArray *pTagArray) |
| 217 | { |
| 218 | m_pTag = pTagArray; |
| 219 | m_sig = icSigNamedColorArray; |
| 220 | |
| 221 | m_list = new icNamedColorStructList; |
| 222 | |
| 223 | m_nDeviceSamples = 0; |
| 224 | m_nPcsSamples = 0; |
| 225 | m_nSpectralSamples = 0; |
| 226 | } |
| 227 | |
| 228 | |
| 229 | CIccArrayNamedColor::~CIccArrayNamedColor() |
| 230 | { |
| 231 | delete m_list; |
| 232 | } |
| 233 | |
| 234 | |
| 235 | IIccArray* CIccArrayNamedColor::NewCopy(CIccTagArray *pTagArray) const |
| 236 | { |
| 237 | CIccArrayNamedColor *rv = new CIccArrayNamedColor(pTagArray); |
| 238 | |
| 239 | if (rv) { |
| 240 | rv->m_csPcs = m_csPcs; |
| 241 | rv->m_csDevice = m_csDevice; |
| 242 | rv->m_csSpectralPcs = m_csSpectralPcs; |
| 243 | rv->m_spectralRange = m_spectralRange; |
| 244 | rv->m_biSpectralRange = m_biSpectralRange; |
| 245 | } |
| 246 | |
| 247 | return rv; |
| 248 | } |
| 249 | |
| 250 | |
| 251 | bool CIccArrayNamedColor::Describe(std::string &sDescription) const |
| 252 | { |
| 253 | return false; |
| 254 | } |
| 255 | |
| 256 | |
| 257 | void CIccArrayNamedColor::SetColorSpaces(icColorSpaceSignature csPcs, icColorSpaceSignature csDevice, |
| 258 | icSpectralColorSignature csSpectralPcs, |
| 259 | const icSpectralRange *pSpectralRange , |
| 260 | const icSpectralRange *pBiSpectralRange ) |
| 261 | { |
| 262 | m_csPcs = csPcs; |
| 263 | m_csDevice = csDevice; |
| 264 | m_csSpectralPcs = csSpectralPcs; |
| 265 | if (pSpectralRange) |
| 266 | m_spectralRange = *pSpectralRange; |
| 267 | else |
| 268 | memset(&m_spectralRange, 0, sizeof(m_spectralRange)); |
| 269 | |
| 270 | if (pBiSpectralRange) |
| 271 | m_biSpectralRange = *pBiSpectralRange; |
| 272 | else |
| 273 | memset(&m_biSpectralRange, 0, sizeof(m_biSpectralRange)); |
| 274 | |
| 275 | m_nDeviceSamples = icGetSpaceSamples(m_csDevice); |
| 276 | m_nPcsSamples = icGetSpaceSamples(m_csPcs); |
| 277 | m_nSpectralSamples = icGetSpaceSamples((icColorSpaceSignature)m_csSpectralPcs); |
| 278 | } |
| 279 | |
| 280 | bool CIccArrayNamedColor::Begin() |
| 281 | { |
| 282 | m_pZeroTint = (CIccStructNamedColor*)icGetTagStructHandlerOfType(m_pTag->GetIndex(0), icSigTintZeroStruct); |
| 283 | |
| 284 | m_list->clear(); |
| 285 | |
| 286 | int i, n=m_pTag->GetSize(); |
| 287 | for (i=1; i<n; i++) { |
| 288 | CIccStructNamedColor *pNamedColor = (CIccStructNamedColor*)icGetTagStructHandlerOfType(m_pTag->GetIndex(i), icSigNamedColorStruct); |
| 289 | if (pNamedColor) { |
| 290 | std::string name = pNamedColor->getName(); |
| 291 | if (!name.empty()) |
| 292 | (*m_list)[name] = pNamedColor; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | return true; |
| 297 | } |
| 298 | |
| 299 | CIccStructNamedColor* CIccArrayNamedColor::FindColor(const icChar *szColor) const |
| 300 | { |
| 301 | std::string name(szColor); |
| 302 | |
| 303 | icNamedColorStructList::const_iterator i; |
| 304 | i=m_list->find(name); |
| 305 | if (i!=m_list->end()) |
| 306 | return i->second; |
| 307 | |
| 308 | return NULL; |
| 309 | } |
| 310 | |
| 311 | CIccStructNamedColor* CIccArrayNamedColor::FindDeviceColor(const icFloatNumber *pDevColor) const |
| 312 | { |
| 313 | icFloatNumber *temp = new icFloatNumber[m_nDeviceSamples]; |
| 314 | |
| 315 | if (!temp) |
| 316 | return NULL; |
| 317 | |
| 318 | icUInt32Number i, j, n=m_pTag->GetSize(); |
| 319 | for (i=1; i<n; i++) { |
| 320 | CIccStructNamedColor *pNamedColor = (CIccStructNamedColor*)icGetTagStructHandlerOfType(m_pTag->GetIndex(i), icSigNamedColorStruct); |
| 321 | if (pNamedColor) { |
| 322 | CIccTag *pTag = pNamedColor->GetElem(icSigNmclDeviceDataMbr); |
| 323 | if (pTag && pTag->IsNumArrayType()) { |
| 324 | CIccTagNumArray *v = (CIccTagNumArray*)pTag; |
| 325 | icUInt32Number n = v->GetNumValues()/m_nDeviceSamples; |
| 326 | if (n) { |
| 327 | v->GetValues(temp, (n-1)*m_nDeviceSamples, m_nDeviceSamples); |
| 328 | |
| 329 | for (j=0; j<m_nDeviceSamples; j++) { |
| 330 | if (temp[j]!=pDevColor[j]) |
| 331 | break; |
| 332 | } |
| 333 | if (n==m_nDeviceSamples) { |
| 334 | delete [] temp; |
| 335 | return pNamedColor; |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | return NULL; |
| 342 | } |
| 343 | |
| 344 | CIccStructNamedColor* CIccArrayNamedColor::FindPcsColor(const icFloatNumber *pPCS, icFloatNumber dMinDE) const |
| 345 | { |
| 346 | icFloatNumber dCalcDE, dLeastDE=dMinDE; |
| 347 | icFloatNumber pLabIn[3], pLab[3]; |
| 348 | CIccStructNamedColor* leastDEindex = NULL; |
| 349 | |
| 350 | if (m_csPcs != icSigLabData) { |
| 351 | icXYZtoLab(pLabIn,pPCS); |
| 352 | } |
| 353 | else { |
| 354 | memcpy(pLabIn, pPCS, 3*sizeof(icFloatNumber)); |
| 355 | } |
| 356 | |
| 357 | icUInt32Number i, n=m_pTag->GetSize(); |
| 358 | for (i=1; i<n; i++) { |
| 359 | CIccStructNamedColor *pNamedColor = (CIccStructNamedColor*)icGetTagStructHandlerOfType(m_pTag->GetIndex(i), icSigNamedColorStruct); |
| 360 | if (pNamedColor) { |
| 361 | CIccTag *pTag = pNamedColor->GetElem(icSigNmclDeviceDataMbr); |
| 362 | if (pTag && pTag->IsNumArrayType()) { |
| 363 | CIccTagNumArray *v = (CIccTagNumArray*)pTag; |
| 364 | icUInt32Number n = v->GetNumValues()/m_nDeviceSamples; |
| 365 | if (n) { |
| 366 | v->GetValues(pLab, (n-1)*m_nDeviceSamples, 3); |
| 367 | |
| 368 | dCalcDE = icDeltaE(pLabIn, pLab); |
| 369 | |
| 370 | if (dCalcDE<dMinDE && dCalcDE<dLeastDE) { |
| 371 | dLeastDE = dCalcDE; |
| 372 | leastDEindex = pNamedColor; |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | return leastDEindex; |
| 380 | } |
| 381 | |
| 382 | CIccStructNamedColor* CIccArrayNamedColor::FindSpectralColor(const icFloatNumber *pSpec, icFloatNumber dMinRMS) const |
| 383 | { |
| 384 | icFloatNumber dCalcRMS, dLeastRMS=dMinRMS; |
| 385 | CIccStructNamedColor* leastRMSindex = NULL; |
| 386 | |
| 387 | icFloatNumber *temp = new icFloatNumber[m_nSpectralSamples]; |
| |
| 388 | |
| 389 | if (!temp) |
| |
| 390 | return NULL; |
| 391 | |
| 392 | icUInt32Number i, n=m_pTag->GetSize(); |
| 393 | for (i=1; i<n; i++) { |
| |
| 4 | | Loop condition is false. Execution continues on line 414 | |
|
| 394 | CIccStructNamedColor *pNamedColor = (CIccStructNamedColor*)icGetTagStructHandlerOfType(m_pTag->GetIndex(i), icSigNamedColorStruct); |
| 395 | if (pNamedColor) { |
| 396 | CIccTag *pTag = pNamedColor->GetElem(icSigNmclDeviceDataMbr); |
| 397 | if (pTag && pTag->IsNumArrayType()) { |
| 398 | CIccTagNumArray *v = (CIccTagNumArray*)pTag; |
| 399 | icUInt32Number n = v->GetNumValues()/m_nDeviceSamples; |
| 400 | if (n) { |
| 401 | v->GetValues(temp, (n-1)*m_nSpectralSamples, m_nSpectralSamples); |
| 402 | |
| 403 | dCalcRMS = icRmsDif(pSpec, temp, m_nSpectralSamples); |
| 404 | |
| 405 | if (dCalcRMS<dMinRMS && dCalcRMS<dLeastRMS) { |
| 406 | dLeastRMS = dCalcRMS; |
| 407 | leastRMSindex = pNamedColor; |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | return leastRMSindex; |
| 5 | | Potential leak of memory pointed to by 'temp' |
|
| 415 | } |
| 416 | |
| 417 | bool CIccArrayNamedColor::GetDeviceTint(icFloatNumber *dstColor, |
| 418 | const CIccStructNamedColor *pColor, |
| 419 | icFloatNumber tint, |
| 420 | icNamedColorlMemberSignature sig) const |
| 421 | { |
| 422 | CIccTagNumArray *pZero; |
| 423 | |
| 424 | if (m_pZeroTint) |
| 425 | pZero = m_pZeroTint->GetNumArray(sig); |
| 426 | else |
| 427 | pZero = NULL; |
| 428 | |
| 429 | if (!pColor) |
| 430 | return false; |
| 431 | |
| 432 | return pColor->GetTint(dstColor, tint, pZero, sig, m_nDeviceSamples); |
| 433 | } |
| 434 | |
| 435 | |
| 436 | bool CIccArrayNamedColor::GetPcsTint(icFloatNumber *dstColor, |
| 437 | const CIccStructNamedColor *pColor, |
| 438 | icFloatNumber tint, |
| 439 | icNamedColorlMemberSignature sig) const |
| 440 | { |
| 441 | CIccTagNumArray *pZero; |
| 442 | |
| 443 | if (m_pZeroTint) |
| 444 | pZero = m_pZeroTint->GetNumArray(sig); |
| 445 | else |
| 446 | pZero = NULL; |
| 447 | |
| 448 | if (!pColor) |
| 449 | return false; |
| 450 | |
| 451 | return pColor->GetTint(dstColor, tint, pZero, sig, m_nPcsSamples); |
| 452 | } |
| 453 | |
| 454 | bool CIccArrayNamedColor::GetSpectralTint(icFloatNumber *dstColor, |
| 455 | const CIccStructNamedColor *pColor, |
| 456 | icFloatNumber tint, |
| 457 | icNamedColorlMemberSignature sig) const |
| 458 | { |
| 459 | CIccTagNumArray *pZero; |
| 460 | |
| 461 | if (m_pZeroTint) |
| 462 | pZero = m_pZeroTint->GetNumArray(sig); |
| 463 | else |
| 464 | pZero = NULL; |
| 465 | |
| 466 | if (!pColor) |
| 467 | return false; |
| 468 | |
| 469 | return pColor->GetTint(dstColor, tint, pZero, sig, m_nSpectralSamples); |
| 470 | } |
| 471 | |
| 472 | |
| 473 | icValidateStatus CIccArrayNamedColor::Validate(std::string sigPath, std::string &sReport, const CIccProfile* pProfile) const |
| 474 | { |
| 475 | icValidateStatus rv = icValidateOK; |
| 476 | |
| 477 | if (m_pTag) { |
| 478 | icUInt32Number i, n = m_pTag->GetSize(); |
| 479 | CIccTag *pSubTag; |
| 480 | int nBad = 0; |
| 481 | |
| 482 | if (n<1) { |
| 483 | sReport += "Named Color array must have at least 1 entry\r\n"; |
| 484 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 485 | } |
| 486 | |
| 487 | for (i=0; i<n; i++) { |
| 488 | pSubTag = m_pTag->GetIndex(i); |
| 489 | if (pSubTag) { |
| 490 | icStructSignature sig = pSubTag->GetTagStructType(); |
| 491 | if (!((i && sig==icSigNamedColorStruct) || (!i && sig==icSigTintZeroStruct))) { |
| 492 | nBad++; |
| 493 | } |
| 494 | else { |
| 495 | CIccTagStruct *pTag = (CIccTagStruct*)pSubTag; |
| 496 | CIccStructNamedColor *pColor = (CIccStructNamedColor*)pTag->GetStructHandler(); |
| 497 | |
| 498 | if (pColor) { |
| 499 | CIccTagNumArray *pArray, *pTint; |
| 500 | char str[256]; |
| 501 | |
| 502 | pTint = pColor->GetNumArray(icSigNmclTintMbr); |
| 503 | |
| 504 | pArray = pColor->GetNumArray(icSigNmclDeviceDataMbr); |
| 505 | if (pArray && m_nDeviceSamples) { |
| 506 | icUInt32Number n = pArray->GetNumValues()/m_nDeviceSamples; |
| 507 | |
| 508 | if (n<1) { |
| 509 | sprintf(str, "Insufficient device samples in NamedColor[%d]\r\n", i); |
| 510 | sReport += str; |
| 511 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 512 | } |
| 513 | else if (pArray->GetNumValues() != n*m_nDeviceSamples) { |
| 514 | sprintf(str, "Number of Device samples isn't an even multiple of Device samples in NamedColor[%d]!\r\n", i); |
| 515 | sReport += str; |
| 516 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 517 | } |
| 518 | if (pTint && pTint->GetNumValues()!=n) { |
| 519 | sprintf(str, "Number of device samples doesn't match tint values in NamedColor[%d]\r\n", i); |
| 520 | sReport += str; |
| 521 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | pArray = pColor->GetNumArray(icSigNmclPcsDataMbr); |
| 526 | if (pArray && m_nPcsSamples) { |
| 527 | icUInt32Number n = pArray->GetNumValues()/m_nPcsSamples; |
| 528 | |
| 529 | if (n<1) { |
| 530 | sprintf(str, "Insufficient PCS samples in NamedColor[%d]\r\n", i); |
| 531 | sReport += str; |
| 532 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 533 | } |
| 534 | else if (pArray->GetNumValues() != n*m_nPcsSamples) { |
| 535 | sprintf(str, "Number of PCS samples isn't an even multiple of PCS samples in NamedColor[%d]!\r\n", i); |
| 536 | sReport += str; |
| 537 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 538 | } |
| 539 | if (pTint && pTint->GetNumValues()!=n) { |
| 540 | sprintf(str, "Number of PCS samples doesn't match tint values in NamedColor[%d]\r\n", i); |
| 541 | sReport += str; |
| 542 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | pArray = pColor->GetNumArray(icSigNmclSpectralDataMbr); |
| 547 | if (pArray) { |
| 548 | if (pArray->IsMatrixArray()) { |
| 549 | CIccTagSparseMatrixArray *pArrayTag = (CIccTagSparseMatrixArray *) pArray; |
| 550 | |
| 551 | if (pArrayTag->GetChannelsPerMatrix()!= m_nSpectralSamples) { |
| 552 | sprintf(str, "Incompatible SpectralPcs samples in NamedColor[%d]\r\n", i); |
| 553 | sReport += str; |
| 554 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 555 | } |
| 556 | } |
| 557 | else if (m_nSpectralSamples) { |
| 558 | icUInt32Number n = pArray->GetNumValues()/m_nSpectralSamples; |
| 559 | |
| 560 | if (n<1) { |
| 561 | sprintf(str, "Insufficient SpectralPcs samples in NamedColor[%d]\r\n", i); |
| 562 | sReport += str; |
| 563 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 564 | } |
| 565 | else if (pArray->GetNumValues() != n*m_nSpectralSamples) { |
| 566 | sprintf(str, "Number of spectral samples isn't an even multiple of spectral PCS samples in Namedcolor[%d]!\r\n", i); |
| 567 | sReport += str; |
| 568 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 569 | } |
| 570 | if (pTint && pTint->GetNumValues()!=n) { |
| 571 | sprintf(str, "Number of SpectralPCS samples doesn't match tint values in NamedColor[%d]\r\n", i); |
| 572 | sReport += str; |
| 573 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 574 | } |
| 575 | } |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | } |
| 580 | rv = icMaxStatus(rv, pSubTag->Validate(sigPath, sReport, pProfile)); |
| 581 | } |
| 582 | else { |
| 583 | nBad++; |
| 584 | } |
| 585 | } |
| 586 | if (nBad) { |
| 587 | sReport += "Named Color array has invalid tag struct entries!\r\n"; |
| 588 | rv = icMaxStatus(rv, icValidateCriticalError); |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | return rv; |
| 593 | } |
| 594 | |
| 595 | |
| 596 | #ifdef USEREFICCMAXNAMESPACE |
| 597 | } |
| 598 | #endif |