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 IccCAM.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/IccCAM.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 | |
72 | #include "IccCAM.h" |
73 | #include "IccUtil.h" |
74 | #include <cmath> |
75 | #include <cstring> |
76 | #include <string> |
77 | |
78 | |
79 | |
80 | void |
81 | CIccCamConverter::Multiply_vect_by_mx (const icFloatNumber *in, |
82 | icFloatNumber *out, |
83 | icFloatNumber m[3][3]) |
84 | { |
85 | out[0] = m[0][0] * in[0] + m[0][1] * in[1] + m[0][2] * in[2]; |
86 | out[1] = m[1][0] * in[0] + m[1][1] * in[1] + m[1][2] * in[2]; |
87 | out[2] = m[2][0] * in[0] + m[2][1] * in[1] + m[2][2] * in[2]; |
88 | } |
89 | |
90 | |
91 | |
92 | void |
93 | CIccCamConverter::ReferenceConditions (icFloatNumber *rgb, |
94 | icFloatNumber *rgbC) |
95 | { |
96 | rgbC[0] = (icFloatNumber)((m_D * m_WhitePoint[1] / m_rgbWhite[0] + 1.0 - m_D) * rgb[0]); |
97 | rgbC[1] = (icFloatNumber)((m_D * m_WhitePoint[1] / m_rgbWhite[1] + 1.0 - m_D) * rgb[1]); |
98 | rgbC[2] = (icFloatNumber)((m_D * m_WhitePoint[1] / m_rgbWhite[2] + 1.0 - m_D) * rgb[2]); |
99 | } |
100 | |
101 | |
102 | |
103 | void |
104 | CIccCamConverter::ReferenceConditionsInv (icFloatNumber *rgbC, |
105 | icFloatNumber *rgb) |
106 | { |
107 | rgb[0] = (icFloatNumber)(rgbC[0] / (m_D * m_WhitePoint[1] / m_rgbWhite[0] + 1.0 - m_D)); |
108 | rgb[1] = (icFloatNumber)(rgbC[1] / (m_D * m_WhitePoint[1] / m_rgbWhite[1] + 1.0 - m_D)); |
109 | rgb[2] = (icFloatNumber)(rgbC[2] / (m_D * m_WhitePoint[1] / m_rgbWhite[2] + 1.0 - m_D)); |
110 | } |
111 | |
112 | |
113 | |
114 | icFloatNumber |
115 | CIccCamConverter::F_Function (icFloatNumber x) |
116 | { |
117 | icFloatNumber y; |
118 | y = (icFloatNumber) (400.0 * pow ((double)x, 0.42) / (27.13 + pow ((double)x, 0.42))); |
119 | return y; |
120 | } |
121 | |
122 | |
123 | |
124 | icFloatNumber |
125 | CIccCamConverter::H_Function (icFloatNumber x) |
126 | { |
127 | icFloatNumber y; |
128 | |
129 | y = (icFloatNumber) (400.0 * pow ((double)x, (double)m_exp) / (27.13 + pow ((double)x, (double)m_exp))); |
130 | |
131 | return y; |
132 | } |
133 | |
134 | |
135 | |
136 | icFloatNumber |
137 | CIccCamConverter::H_FunctionInv (icFloatNumber y) |
138 | { |
139 | icFloatNumber x; |
140 | |
141 | x = (icFloatNumber) (pow (27.13*y / (400.0-y), 1.0/m_exp)); |
142 | |
143 | return x; |
144 | } |
145 | |
146 | |
147 | |
148 | icFloatNumber |
149 | CIccCamConverter::Hyperbolic (icFloatNumber x) |
150 | { |
151 | icFloatNumber y; |
152 | |
153 | if (x < 0) |
| |
| |
154 | { |
155 | if (-x <= m_x0) |
| 7 | | The right operand of '<=' is a garbage value |
|
156 | { |
157 | y = m_cc * x; |
158 | } |
159 | else |
160 | { |
161 | y = - ((1 + m_alfa) * H_Function (-x) / H_Function (m_Fl) - m_alfa) * F_Function (m_Fl); |
162 | } |
163 | } |
164 | else |
165 | { |
166 | if (x <= m_x0) |
167 | { |
168 | y = m_cc * x; |
169 | } |
170 | else |
171 | { |
172 | y = ((1 + m_alfa) * H_Function (x) / H_Function (m_Fl) - m_alfa) * F_Function (m_Fl); |
173 | } |
174 | } |
175 | |
176 | return y; |
177 | } |
178 | |
179 | |
180 | |
181 | icFloatNumber |
182 | CIccCamConverter::HyperbolicInv (icFloatNumber y) |
183 | { |
184 | icFloatNumber x, h_y; |
185 | |
186 | if (y < 0) |
187 | { |
188 | if (-y <= (m_cc * m_x0)) |
189 | { |
190 | x = y / m_cc; |
191 | } |
192 | else |
193 | { |
194 | h_y = (- y / F_Function (m_Fl) + m_alfa) / (1 + m_alfa) * H_Function (m_Fl); |
195 | x = - H_FunctionInv (h_y); |
196 | } |
197 | } |
198 | else |
199 | { |
200 | if (y <= (m_cc * m_x0)) |
201 | { |
202 | x = y / m_cc; |
203 | } |
204 | else |
205 | { |
206 | h_y = (y / F_Function (m_Fl) + m_alfa) / (1 + m_alfa) * H_Function (m_Fl); |
207 | x = H_FunctionInv (h_y); |
208 | } |
209 | } |
210 | |
211 | return x; |
212 | } |
213 | |
214 | |
215 | |
216 | icFloatNumber |
217 | CIccCamConverter::IccCam_e (icFloatNumber hue) |
218 | { |
219 | int i, j; |
220 | icFloatNumber offset; |
221 | double hdef[4] = {20.14, 90.00, 164.25, 237.53}; |
222 | double edef[4] = {0.8, 0.7, 1.0, 1.2}; |
223 | |
224 | for (i = 0; i < 4; i++) |
225 | if (hue < hdef[i]) |
226 | break; |
227 | |
228 | j = i - 1; |
229 | if (i == 0) |
230 | j = 3; |
231 | else if (i == 4) |
232 | i = 0; |
233 | |
234 | if (i == 0) |
235 | { |
236 | offset = 360.0; |
237 | |
238 | if (hue <= hdef[0]) |
239 | hue += 360.0; |
240 | } |
241 | else |
242 | offset = 0; |
243 | |
244 | return (icFloatNumber)(edef[j] + (edef[i] - edef[j]) * (hue - hdef[j]) / (offset + hdef[i] - hdef[j])); |
245 | } |
246 | |
247 | |
248 | |
249 | void |
250 | CIccCamConverter::CalcCoefficients () |
251 | { |
252 | icFloatNumber k, La5, rgbC[3], rgbP[3]; |
253 | |
254 | double epow = pow (2.7182818, (-((double)m_La + 42.0)/92.0) ); |
255 | m_D = (icFloatNumber) (m_F *(1.0 - (epow/ 3.6)) ); |
256 | |
257 | k = 1.0f / (5.0f * m_La + 1.0f); |
258 | k = (icFloatNumber)(pow ((double)k, 4.0)); |
259 | La5 = 5.0f * m_La; |
260 | m_Fl = (icFloatNumber)(0.2 * k * La5 + 0.1 * (1 - k) * (1 - k) * pow ((double)La5, 0.333333)); |
261 | |
262 | m_n = m_Yb / m_WhitePoint[1]; |
263 | |
264 | m_factor = (icFloatNumber) pow (1.64 - pow (0.29, (double) m_n), 0.73); |
265 | |
266 | m_Nbb = (icFloatNumber)(0.725 / pow ((double)(m_n), 0.2)); |
267 | |
268 | m_z = (icFloatNumber)(1.48 + sqrt (m_n)); |
269 | |
270 | Multiply_vect_by_mx (m_WhitePoint, m_rgbWhite, m_mFor); |
271 | |
272 | ReferenceConditions (m_rgbWhite, rgbC); |
273 | |
274 | |
275 | rgbP[0] = rgbC[0]; |
276 | rgbP[1] = rgbC[1]; |
277 | rgbP[2] = rgbC[2]; |
278 | |
279 | rgbP[0] = Hyperbolic (m_Fl * rgbP[0] / 100) + 0.1f; |
| 4 | | Calling 'CIccCamConverter::Hyperbolic' | |
|
280 | rgbP[1] = Hyperbolic (m_Fl * rgbP[1] / 100) + 0.1f; |
281 | rgbP[2] = Hyperbolic (m_Fl * rgbP[2] / 100) + 0.1f; |
282 | m_AWhite = (icFloatNumber)((2.0 * rgbP[0] + rgbP[1] + rgbP[2] / 20.0 - 0.305) * m_Nbb); |
283 | |
284 | |
285 | |
286 | m_x0 = (icFloatNumber) (m_Fl * 4.00 / 255.0); |
287 | m_cc = ((1 + m_alfa) * H_Function (m_x0) / H_Function (m_Fl) - m_alfa) * F_Function (m_Fl) / m_x0; |
288 | } |
289 | |
290 | |
291 | void CIccCamConverter::ab2chDeg(icFloatNumber a, icFloatNumber b, icFloatNumber &c, icFloatNumber &h) |
292 | { |
293 | c = sqrt(a*a + b*b); |
294 | h = (icFloatNumber)(atan2(b, a) * 180.0 / icPiNum); |
295 | while (h<0.0) |
296 | h+=360.0; |
297 | } |
298 | |
299 | |
300 | |
301 | |
302 | CIccCamConverter::CIccCamConverter () |
303 | { |
304 | |
305 | |
306 | |
307 | m_La = (icFloatNumber) 500.0; |
308 | m_Yb = (icFloatNumber) 20.0; |
309 | |
310 | m_WhitePoint[0] = icD50XYZ[0]; |
311 | m_WhitePoint[1] = icD50XYZ[1]; |
312 | m_WhitePoint[2] = icD50XYZ[2]; |
313 | |
314 | |
315 | m_c = (icFloatNumber) 0.69; |
316 | m_Nc = (icFloatNumber) 1.00; |
317 | m_F = (icFloatNumber) 1.00; |
318 | |
319 | |
320 | m_mFor[0][0] = 0.38970f; m_mFor[0][1] = 0.68898f; m_mFor[0][2] = -0.07868f; |
321 | m_mFor[1][0] = -0.22981f; m_mFor[1][1] = 1.18340f; m_mFor[1][2] = 0.04641f; |
322 | m_mFor[2][0] = 0.00000f; m_mFor[2][1] = 0.00000f; m_mFor[2][2] = 1.00000f; |
323 | |
324 | m_mInv[0][0] = 1.910197f; m_mInv[0][1] = -1.1121240f; m_mInv[0][2] = 0.201908f; |
325 | m_mInv[1][0] = 0.370950f; m_mInv[1][1] = 0.6290540f; m_mInv[1][2] = 0.000008f; |
326 | m_mInv[2][0] = 0.000000f; m_mInv[2][1] = 0.0000000f; m_mInv[2][2] = 1.000000f; |
327 | |
328 | |
329 | |
330 | |
331 | |
332 | |
333 | |
334 | |
335 | |
336 | |
337 | |
338 | |
339 | |
340 | |
341 | m_alfa = 0.2307f; |
342 | m_exp = 0.3169f; |
343 | |
344 | CalcCoefficients (); |
| 3 | | Calling 'CIccCamConverter::CalcCoefficients' | |
|
345 | } |
346 | |
347 | |
348 | |
349 | CIccCamConverter::~CIccCamConverter () |
350 | { |
351 | } |
352 | |
353 | |
354 | CIccCamConverter* CIccCamConverter::NewCopy() const |
355 | { |
356 | CIccCamConverter *rv = new CIccCamConverter(); |
| 1 | Uninitialized value stored to field 'm_x0' | |
|
| 2 | | Calling default constructor for 'CIccCamConverter' | |
|
357 | *rv = *this; |
358 | return rv; |
359 | } |
360 | |
361 | |
362 | |
363 | void |
364 | CIccCamConverter::SetParameter_WhitePoint (icFloatNumber* whitePoint) |
365 | { |
366 | m_WhitePoint[0] = whitePoint[0]; |
367 | m_WhitePoint[1] = whitePoint[1]; |
368 | m_WhitePoint[2] = whitePoint[2]; |
369 | CalcCoefficients (); |
370 | } |
371 | |
372 | |
373 | |
374 | void |
375 | CIccCamConverter::SetParameter_La (icFloatNumber La) |
376 | { |
377 | m_La = La; |
378 | CalcCoefficients (); |
379 | } |
380 | |
381 | |
382 | |
383 | void |
384 | CIccCamConverter::SetParameter_Yb (icFloatNumber Yb) |
385 | { |
386 | m_Yb = Yb; |
387 | CalcCoefficients (); |
388 | } |
389 | |
390 | |
391 | |
392 | void |
393 | CIccCamConverter::SetParameter_C (icFloatNumber c) |
394 | { |
395 | m_c = c; |
396 | CalcCoefficients (); |
397 | } |
398 | |
399 | |
400 | |
401 | void |
402 | CIccCamConverter::SetParameter_Nc (icFloatNumber Nc) |
403 | { |
404 | m_Nc = Nc; |
405 | CalcCoefficients (); |
406 | } |
407 | |
408 | |
409 | |
410 | void |
411 | CIccCamConverter::SetParameter_F (icFloatNumber F) |
412 | { |
413 | m_F = F; |
414 | CalcCoefficients (); |
415 | } |
416 | |
417 | |
418 | |
419 | void |
420 | CIccCamConverter::GetParameter_WhitePoint (icFloatNumber* whitePoint) |
421 | { |
422 | whitePoint[0] = m_WhitePoint[0]; |
423 | whitePoint[1] = m_WhitePoint[1]; |
424 | whitePoint[2] = m_WhitePoint[2]; |
425 | } |
426 | |
427 | |
428 | |
429 | icFloatNumber |
430 | CIccCamConverter::GetParameter_La () |
431 | { |
432 | return m_La; |
433 | } |
434 | |
435 | |
436 | |
437 | icFloatNumber |
438 | CIccCamConverter::GetParameter_Yb () |
439 | { |
440 | return m_Yb; |
441 | } |
442 | |
443 | |
444 | |
445 | icFloatNumber |
446 | CIccCamConverter::GetParameter_C () |
447 | { |
448 | return m_c; |
449 | } |
450 | |
451 | |
452 | |
453 | icFloatNumber |
454 | CIccCamConverter::GetParameter_Nc () |
455 | { |
456 | return m_Nc; |
457 | } |
458 | |
459 | |
460 | |
461 | icFloatNumber |
462 | CIccCamConverter::GetParameter_F () |
463 | { |
464 | return m_F; |
465 | } |
466 | |
467 | |
468 | |
469 | void |
470 | CIccCamConverter::XYZToJab (const icFloatNumber* xyz, |
471 | icFloatNumber* jab, |
472 | int nbr) |
473 | { |
474 | int k; |
475 | icFloatNumber rgb[3], rgbC[3], rgbP[3]; |
476 | icFloatNumber la, lb, lc, lchroma, lh, lhr, A, J, et, t, C, ac, bc; |
477 | const icFloatNumber* h_xyz; |
478 | icFloatNumber* h_jab; |
479 | |
480 | h_xyz = xyz; |
481 | h_jab = jab; |
482 | |
483 | for (k=0;k<nbr;k++) |
484 | { |
485 | Multiply_vect_by_mx (h_xyz, rgb, m_mFor); |
486 | |
487 | |
488 | if (rgb[0] < 0) rgb[0] = 0.0f; |
489 | if (rgb[1] < 0) rgb[1] = 0.0f; |
490 | if (rgb[2] < 0) rgb[2] = 0.0f; |
491 | |
492 | ReferenceConditions (rgb, rgbC); |
493 | |
494 | rgbP[0] = Hyperbolic (m_Fl * rgbC[0] / 100) + 0.1f; |
495 | rgbP[1] = Hyperbolic (m_Fl * rgbC[1] / 100) + 0.1f; |
496 | rgbP[2] = Hyperbolic (m_Fl * rgbC[2] / 100) + 0.1f; |
497 | |
498 | la = (icFloatNumber)(rgbP[0] - 12.0 * rgbP[1] / 11.0 + rgbP[2] / 11.0); |
499 | lb = (icFloatNumber)((rgbP[0] + rgbP[1] - 2.0 * rgbP[2] ) / 9.0); |
500 | lchroma = (icFloatNumber)(sqrt (la * la + lb * lb)); |
501 | |
502 | ab2chDeg (la, lb, lc, lh); |
503 | lhr = lh * (icFloatNumber)icPiNum / 180.0f; |
504 | |
505 | A = (icFloatNumber)((2.0 * rgbP[0] + rgbP[1] + rgbP[2] / 20.0 - 0.305) * m_Nbb); |
506 | |
507 | J = (icFloatNumber)(100.0 * pow (A / m_AWhite, m_c * m_z)); |
508 | |
509 | et = (icFloatNumber)((cos(lhr + 2.0) + 3.8) / 4.0); |
510 | t = (icFloatNumber)(50.0 * lchroma * 100 * et * 10.0/13.0 * m_Nc * m_Nbb / (rgbP[0]+rgbP[1]+21.0/20.0*rgbP[2])); |
511 | C = (icFloatNumber)(pow((double)t, 0.9) * sqrt ((double)(J/100.0)) * m_factor); |
512 | |
513 | ac = (icFloatNumber)(C * cos(lhr)); |
514 | bc = (icFloatNumber)(C * sin(lhr)); |
515 | |
516 | h_jab[0] = J; |
517 | h_jab[1] = ac; |
518 | h_jab[2] = bc; |
519 | |
520 | h_xyz += 3; |
521 | h_jab += 3; |
522 | } |
523 | } |
524 | |
525 | |
526 | |
527 | void |
528 | CIccCamConverter::JabToXYZ (const icFloatNumber* jab, |
529 | icFloatNumber* xyz, |
530 | int nbr) |
531 | { |
532 | int i; |
533 | icFloatNumber rgb[3], rgbP[3], rgbC[3]; |
534 | icFloatNumber lc, lh, lhr, et, p1, p2, p4, p5, p3, numerator; |
535 | icFloatNumber value, a, b, cotan, tanValue; |
536 | double exp = 1.0 / 0.9; |
537 | double A, ratio, C, t; |
538 | const icFloatNumber* h_jab; |
539 | icFloatNumber* h_xyz; |
540 | |
541 | h_jab = jab; |
542 | h_xyz = xyz; |
543 | |
544 | for (i=0;i<nbr;i++) |
545 | { |
546 | if (h_jab[0] < 1.0e-5) |
547 | { |
548 | rgbP[0] = 0.1f; |
549 | rgbP[1] = 0.1f; |
550 | rgbP[2] = 0.1f; |
551 | } |
552 | else |
553 | { |
554 | C = sqrt (h_jab[1] * h_jab[1] + h_jab[2] * h_jab[2]); |
555 | |
556 | ratio = C / (sqrt (h_jab[0]/100.0) * m_factor); |
557 | t = pow (ratio, exp); |
558 | A = m_AWhite * pow (h_jab[0]/100.0, 1.0/(m_c*m_z)); |
559 | |
560 | p2 = (icFloatNumber) ((A / m_Nbb + 0.305f) * 460.0 / 1403.0); |
561 | |
562 | if (t < 1.0e-5) |
563 | { |
564 | rgbP[0] = p2; |
565 | rgbP[1] = p2; |
566 | rgbP[2] = p2; |
567 | } |
568 | else |
569 | { |
570 | ab2chDeg (h_jab[1], h_jab[2], lc, lh); |
571 | lhr = lh * (icFloatNumber)icPiNum / 180.0f; |
572 | |
573 | et = (icFloatNumber)((cos ((double)lhr + 2.0) + 3.8) / 4.0); |
574 | |
575 | p1 = (icFloatNumber)((50000.0f / 13.0f) * m_Nc * m_Nbb * et / t); |
576 | p3 = 21.0f / 20.0f; |
577 | |
578 | numerator = p2 * (2.0f + p3); |
579 | |
580 | if ((lh <= 45) || (lh >= 315) || ((lh > 135) && (lh < 225))) |
581 | { |
582 | tanValue = (icFloatNumber)(tan ((double)lhr)); |
583 | |
584 | if ((lh > 90) && (lh < 270)) |
585 | value = (icFloatNumber)(- pow (1 + pow ((double)tanValue, 2.0), 0.5)); |
586 | else |
587 | value = (icFloatNumber)(pow (1 + pow ((double)tanValue, 2.0), 0.5)); |
588 | |
589 | p5 = (icFloatNumber)(p1 * value); |
590 | |
591 | a = (icFloatNumber)(numerator / (p5 + (2.0f+p3)*(220.0f/1403.0f) - (27.0f/1403.0f - p3*(6300.0f/1403.0f)) * tanValue)); |
592 | b = a * tanValue; |
593 | } |
594 | else |
595 | { |
596 | if (fabs (lh - 90) < 1.0e-5) |
597 | cotan = 0.0f; |
598 | else if (fabs (lh - 270) < 1.0e-5) |
599 | cotan = 0.0f; |
600 | else |
601 | cotan = (icFloatNumber)(1 / tan ((double)lhr)); |
602 | |
603 | if (lh > 180) |
604 | value = (icFloatNumber)(- pow (1 + pow ((double)cotan , 2.0), 0.5)); |
605 | else |
606 | value = (icFloatNumber)(pow (1 + pow ((double)cotan, 2.0), 0.5)); |
607 | |
608 | p4 = (icFloatNumber)(p1 * value); |
609 | |
610 | b = (icFloatNumber)(numerator / (p4 + (2.0f+p3)*(220.0f/1403.0f) * cotan - 27.0f/1403.0f + p3*(6300.0f/1403.0f))); |
611 | a = b * cotan; |
612 | } |
613 | |
614 | rgbP[0] = (icFloatNumber)(p2 + ( 451.0 * a + 288.0 * b) / 1403.0); |
615 | rgbP[1] = (icFloatNumber)(p2 + (-891.0 * a - 261.0 * b) / 1403.0); |
616 | rgbP[2] = (icFloatNumber)(p2 + (-220.0 * a - 6300.0 * b) / 1403.0); |
617 | } |
618 | } |
619 | |
620 | if (rgbP[0] < 0) rgbP[0] = 0.0f; |
621 | if (rgbP[1] < 0) rgbP[1] = 0.0f; |
622 | if (rgbP[2] < 0) rgbP[2] = 0.0f; |
623 | |
624 | rgbC[0] = 100 * HyperbolicInv (rgbP[0] - 0.1f) / m_Fl; |
625 | rgbC[1] = 100 * HyperbolicInv (rgbP[1] - 0.1f) / m_Fl; |
626 | rgbC[2] = 100 * HyperbolicInv (rgbP[2] - 0.1f) / m_Fl; |
627 | |
628 | ReferenceConditionsInv (rgbC, rgb); |
629 | Multiply_vect_by_mx (rgb, h_xyz, m_mInv); |
630 | |
631 | h_jab += 3; |
632 | h_xyz += 3; |
633 | } |
634 | } |
635 | |
636 | CIccCamConverter& CIccCamConverter::operator=(const CIccCamConverter &camcon) |
637 | { |
638 | memcpy(&m_WhitePoint, &camcon.m_WhitePoint, sizeof(m_WhitePoint)); |
639 | m_La=camcon.m_La; |
640 | m_Yb=camcon.m_Yb; |
641 | m_c=camcon.m_c; |
642 | m_Nc=camcon.m_Nc; |
643 | m_F=camcon.m_F; |
644 | memcpy(&m_mFor, &camcon.m_mFor, sizeof(m_mFor)); |
645 | memcpy(&m_mInv, &camcon.m_mInv, sizeof(m_mInv)); |
646 | m_factor=camcon.m_factor; |
647 | |
648 | |
649 | |
650 | |
651 | |
652 | |
653 | memcpy(m_rgbWhite, camcon.m_rgbWhite, sizeof(m_rgbWhite)); |
654 | m_D=camcon.m_D; |
655 | m_Fl=camcon.m_Fl; |
656 | m_n=camcon.m_n; |
657 | m_Nbb=camcon.m_Nbb; |
658 | m_z=camcon.m_z; |
659 | m_AWhite=camcon.m_AWhite; |
660 | |
661 | |
662 | m_x0=camcon.m_x0; |
663 | m_cc=camcon.m_cc; |
664 | m_alfa=camcon.m_alfa; |
665 | m_exp=camcon.m_exp; |
666 | |
667 | return *this; |
668 | } |
669 | |
670 | |