Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccUtil.cpp
Go to the documentation of this file.
1/*
2 File: IccUtil.cpp
3
4 Contains: Implementation of utility classes/functions
5
6 Version: V1
7
8 Copyright: � see ICC Software License
9*/
10
11/*
12 * The ICC Software License, Version 0.2
13 *
14 *
15 * Copyright (c) 2003-2012 The International Color Consortium. All rights
16 * reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 *
22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 *
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in
27 * the documentation and/or other materials provided with the
28 * distribution.
29 *
30 * 3. In the absence of prior written permission, the names "ICC" and "The
31 * International Color Consortium" must not be used to imply that the
32 * ICC organization endorses or promotes products derived from this
33 * software.
34 *
35 *
36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39 * DISCLAIMED. IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
40 * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This software consists of voluntary contributions made by many
51 * individuals on behalf of the The International Color Consortium.
52 *
53 *
54 * Membership in the ICC is encouraged when this software is used for
55 * commercial purposes.
56 *
57 *
58 * For more information on The International Color Consortium, please
59 * see <http://www.color.org/>.
60 *
61 *
62 */
63
64//////////////////////////////////////////////////////////////////////
65// HISTORY:
66//
67// -Initial implementation by Max Derhak 5-15-2003
68//
69//////////////////////////////////////////////////////////////////////
70
71#include "IccIO.h"
72#include "IccUtil.h"
73#include "IccTagFactory.h"
74#include "IccStructFactory.h"
75#include "IccArrayFactory.h"
76#include "IccMpeFactory.h"
77#include <stdlib.h>
78#include <memory.h>
79#include <ctype.h>
80#include <math.h>
81#include <string.h>
82#include <time.h>
83
84#define PI 3.1415926535897932384626433832795
85
86#ifdef USEREFICCMAXNAMESPACE
87namespace refIccMAX {
88#endif
89
90ICCPROFLIB_API const char *icMsgValidateWarning = "Warning! - ";
91ICCPROFLIB_API const char *icMsgValidateNonCompliant = "NonCompliant! - ";
93ICCPROFLIB_API const char* icMsgValidateInformation = "Information - ";
94
95
96/**
97 ******************************************************************************
98* Name: icRealloc
99*
100* Purpose: realloc memory allocated by malloc or calloc freeing old memory on
101* failure.
102*
103* Args:
104* ptr - memory block to realloc
105* size - new size of memory block
106*
107* Return:
108* pointer to reallocated memory block or NULL on failure. Old memory is
109* released on error.
110******************************************************************************
111*/void* icRealloc(void *ptr, size_t size)
112{
113 void *nptr;
114
115 if (ptr)
116 nptr = realloc(ptr, size);
117 else
118 nptr = malloc(size);
119
120 if (!nptr && ptr)
121 free(ptr);
122
123 return nptr;
124}
125
126
127/**
128******************************************************************************
129* Name: icIsNear
130*
131* Purpose: Checks if two numbers are close to each other in value
132*
133* Args:
134* v1 - first value
135* v2 - second value
136* range -
137*
138* Return:
139* true if v1 is near v2 within range
140******************************************************************************
141*/
142bool icIsNear(icFloatNumber v1, icFloatNumber v2, icFloatNumber nearRange /* = 1.0e-8 */)
143{
144 return fabs(v1 - v2) <= nearRange;
145}
146
147
148/**
149******************************************************************************
150* Name: icValidTagPos
151*
152* Purpose: Checks if pos is valid for data within a tag
153*
154* Args:
155* pos - first value
156* nTagHeaderSize - size of tag header
157* nTagSize - total size of tag data
158*
159* Return:
160* true pos is valid
161******************************************************************************
162*/
163bool icValidTagPos(const icPositionNumber& pos, icUInt32Number nTagHeaderSize, icUInt32Number nTagSize, bool bAllowEmpty)
164{
165 if (bAllowEmpty && !pos.size || !pos.offset)
166 return true;
167
168 if (pos.offset < nTagHeaderSize)
169 return false;
170 if ((icUInt64Number)pos.offset + pos.size > (icUInt64Number)nTagSize)
171 return false;
172
173 if (!pos.size && !bAllowEmpty)
174 return false;
175
176 return true;
177}
178
179
180/**
181******************************************************************************
182* Name: icValidOverlap
183*
184* Purpose: Checks if pos overlap is acceptable
185*
186* Args:
187* pos1 - first positionNumber
188* pos2 - second positionNumber
189* bAllowSame - allow to positions to cover the same area
190*
191* Return:
192* true if v1 is near v2 within range
193******************************************************************************
194*/
195bool icValidOverlap(const icPositionNumber& pos1, const icPositionNumber &pos2, bool bAllowSame)
196{
197 if ((icUInt64Number)pos1.offset + pos1.size <= (icUInt64Number)pos2.offset ||
198 (icUInt64Number)pos1.offset >= (icUInt64Number)pos2.offset + pos2.size)
199 return true;
200
201 if (bAllowSame && pos1.offset == pos2.offset || pos1.size == pos2.size)
202 return true;
203
204 return false;
205}
206
207
208
209/**
210 ******************************************************************************
211* Name: icRoundOffset
212*
213* Purpose: Adds offset to floating point value for purposes of rounding
214* by casting to and integer based value
215*
216* Args:
217* v - value to offset
218*
219* Return:
220* v with offset added - suitable for casting to some form of integer
221******************************************************************************
222*/
223double icRoundOffset(double v)
224{
225 if (v < 0.0)
226 return v - 0.5;
227 else
228 return v + 0.5;
229}
230
231
232/**
233 ******************************************************************************
234 * Name: icMaxStatus
235 *
236 * Purpose: return worst status
237 *
238 * Args:
239 * s1, s2
240 *
241 * Return:
242 ******************************************************************************
243 */
245{
246 if (s1>s2)
247 return s1;
248 return s2;
249}
250
252{
253 if (digit>='0' && digit<='9')
254 return digit-'0';
255 if (digit>='A' && digit<='F')
256 return digit-'A'+10;
257/* if (digit>='a' && digit<='f')
258 return digit-'a'+10;*/
259 return -1;
260}
261
263{
264 icChar szSig[5] = {0};
265 szSig[0] = (icChar)(sig>>24);
266 szSig[1] = (icChar)(sig>>16);
267 szSig[2] = (icChar)(sig>>8);
268 szSig[3] = (icChar)(sig);
269 szSig[4] = '\0';
270
271 int d0 = icHexDigit(szSig[0]);
272
273 if (szSig[0]=='n' && szSig[1]=='c')
274 return true;
275 else if (!strcmp(szSig+1, "CLR")) {
276 icInt32Number d0 = icHexDigit(szSig[0]);
277 if (d0>=1)
278 return true;
279 }
280 else if (!strcmp(szSig+2, "CL")) {
281 icInt32Number d0 = icHexDigit(szSig[0]);
282 icInt32Number d1 = icHexDigit(szSig[1]);
283
284 if (d0>=0 && d1>=0) {
285 icInt32Number n = (d0<<4) + d1;
286
287 if (n>0xf)
288 return true;
289 }
290 }
291
292 return false;
293}
294
296 int nIndex, int nColors, const icChar *szUnknown)
297{
298 icChar szSig[5] = {0};
299 int i;
300
301 if (csSig!=icSigUnknownData) {
302 szSig[0] = (icChar)(csSig>>24);
303 szSig[1] = (icChar)(csSig>>16);
304 szSig[2] = (icChar)(csSig>>8);
305 szSig[3] = (icChar)(csSig);
306 szSig[4] = '\0';
307
308 for (i=3; i>0; i--) {
309 if (szSig[i]==' ')
310 szSig[i]='\0';
311 }
312 if (nColors==1) {
313 strcpy(szName, szSig);
314 }
315 else if ((size_t)nColors == strlen(szSig)) {
316 sprintf(szName, "%s_%c", szSig, szSig[nIndex]);
317 }
318 else {
319 sprintf(szName, "%s_%d", szSig, nIndex+1);
320 }
321 }
322 else if (nColors==1) {
323 strcpy(szName, szUnknown);
324 }
325 else {
326 sprintf(szName, "%s_%d", szUnknown, nIndex+1);
327 }
328}
329
330void icColorValue(icChar *szValue, icFloatNumber nValue,
331 icColorSpaceSignature csSig, int nIndex,
332 bool bUseLegacy)
333{
334 if (csSig==icSigLabData) {
335 if (!bUseLegacy) {
336 if (!nIndex || nIndex>2)
337 sprintf(szValue, "%7.3lf", nValue * 100.0);
338 else
339 sprintf(szValue, "%8.3lf", nValue * 255.0 - 128.0);
340 }
341 else {
342 if (!nIndex || nIndex>2)
343 sprintf(szValue, "%7.3lf", nValue * 100.0 * 65535.0 / 65280.0);
344 else
345 sprintf(szValue, "%8.3lf", nValue * 255.0 * 65535.0 / 65280.0 - 128.0);
346 }
347 }
348 else if (csSig==icSigUnknownData) {
349 sprintf(szValue, "%8.5lf", nValue);
350 }
351 else {
352 sprintf(szValue, "%7.3lf", nValue * 100.0);
353 }
354}
355
357{
359
360 return (icUInt32Number)(F*10000.0f + 0.5) == (icUInt32Number)(D*10000.0f + 0.5);
361}
362
364{
365 return icIsS15Fixed16NumberNear(xyz.X, 0.9642f) &&
366 icIsS15Fixed16NumberNear(xyz.Y, 1.0000f) &&
367 icIsS15Fixed16NumberNear(xyz.Z, 0.8249f);
368}
369
370/**
371**************************************************************************
372* Name: icMatrixInvert3x3
373*
374* Purpose:
375* Inversion of a 3x3 matrix using the Adjoint Cofactor and the determinant of
376* the 3x3 matrix.
377*
378* Note: Matrix index positions:
379* 0 1 2
380* 3 4 5
381* 6 7 8
382*
383* Args:
384* M = matrix to invert.
385*
386* Return:
387* true = matrix is invertible and stored back into M, false = matrix is not
388* invertible.
389**************************************************************************
390*/
392{
393 const icFloatNumber epsilon = 1e-8f;
394
395 icFloatNumber m48 = M[4]*M[8];
396 icFloatNumber m75 = M[7]*M[5];
397 icFloatNumber m38 = M[3]*M[8];
398 icFloatNumber m65 = M[6]*M[5];
399 icFloatNumber m37 = M[3]*M[7];
400 icFloatNumber m64 = M[6]*M[4];
401
402 icFloatNumber det = M[0]*(m48 - m75) -
403 M[1]*(m38 - m65) +
404 M[2]*(m37 - m64);
405
406 if (det>-epsilon && det<epsilon)
407 return false;
408
409 icFloatNumber Co[9] = {0};
410
411 Co[0] = +(m48 - m75);
412 Co[1] = -(m38 - m65);
413 Co[2] = +(m37 - m64);
414
415 Co[3] = -(M[1]*M[8] - M[7]*M[2]);
416 Co[4] = +(M[0]*M[8] - M[6]*M[2]);
417 Co[5] = -(M[0]*M[7] - M[6]*M[1]);
418
419 Co[6] = +(M[1]*M[5] - M[4]*M[2]);
420 Co[7] = -(M[0]*M[5] - M[3]*M[2]);
421 Co[8] = +(M[0]*M[4] - M[3]*M[1]);
422
423 M[0] = Co[0] / det;
424 M[1] = Co[3] / det;
425 M[2] = Co[6] / det;
426
427 M[3] = Co[1] / det;
428 M[4] = Co[4] / det;
429 M[5] = Co[7] / det;
430
431 M[6] = Co[2] / det;
432 M[7] = Co[5] / det;
433 M[8] = Co[8] / det;
434
435 return true;
436}
437
438/**
439**************************************************************************
440* Name: icMatrixMultiply3x3
441*
442* Purpose:
443* Multiply two 3x3 matricies resulting in a 3x3 matrix.
444*
445* Note: Matrix index positions:
446* 0 1 2
447* 3 4 5
448* 6 7 8
449*
450* Args:
451* result = matrix to recieve result.
452* l = left matrix to multiply (matrix multiplication is order dependent)
453* r = right matrix to multiply (matrix multiplicaiton is order dependent)
454*
455**************************************************************************
456*/
458 const icFloatNumber* l,
459 const icFloatNumber* r)
460{
461 const unsigned int e11 = 0;
462 const unsigned int e12 = 1;
463 const unsigned int e13 = 2;
464 const unsigned int e21 = 3;
465 const unsigned int e22 = 4;
466 const unsigned int e23 = 5;
467 const unsigned int e31 = 6;
468 const unsigned int e32 = 7;
469 const unsigned int e33 = 8;
470 result[e11] = l[e11] * r[e11] + l[e12] * r[e21] + l[e13] * r[e31];
471 result[e12] = l[e11] * r[e12] + l[e12] * r[e22] + l[e13] * r[e32];
472 result[e13] = l[e11] * r[e13] + l[e12] * r[e23] + l[e13] * r[e33];
473 result[e21] = l[e21] * r[e11] + l[e22] * r[e21] + l[e23] * r[e31];
474 result[e22] = l[e21] * r[e12] + l[e22] * r[e22] + l[e23] * r[e32];
475 result[e23] = l[e21] * r[e13] + l[e22] * r[e23] + l[e23] * r[e33];
476 result[e31] = l[e31] * r[e11] + l[e32] * r[e21] + l[e33] * r[e31];
477 result[e32] = l[e31] * r[e12] + l[e32] * r[e22] + l[e33] * r[e32];
478 result[e33] = l[e31] * r[e13] + l[e32] * r[e23] + l[e33] * r[e33];
479}
480
481/**
482**************************************************************************
483* Name: icVectorApplyMatrix3x3
484*
485* Purpose:
486* Applies a 3x3 matrix to a 3 element column vector.
487*
488* Note: Matrix index positions:
489* 0 1 2
490* 3 4 5
491* 6 7 8
492*
493* Note: result = m x v
494*
495* Args:
496* result = vector to receive result.
497* m = matrix to multiply
498* v = vector to apply matrix to
499*
500**************************************************************************
501*/
503 const icFloatNumber* m,
504 const icFloatNumber* v)
505{
506 const unsigned int e11 = 0;
507 const unsigned int e12 = 1;
508 const unsigned int e13 = 2;
509 const unsigned int e21 = 3;
510 const unsigned int e22 = 4;
511 const unsigned int e23 = 5;
512 const unsigned int e31 = 6;
513 const unsigned int e32 = 7;
514 const unsigned int e33 = 8;
515 result[0] = m[e11] * v[0] + m[e12] * v[1] + m[e13] * v[2];
516 result[1] = m[e21] * v[0] + m[e22] * v[1] + m[e23] * v[2];
517 result[2] = m[e31] * v[0] + m[e32] * v[1] + m[e33] * v[2];
518}
519
520
522{
523 return x*x;
524}
525
526
528{
529 return (icFloatNumber)sqrt(icSq(lab1[0]-lab2[0]) + icSq(lab1[1]-lab2[1]) + icSq(lab1[2]-lab2[2]));
530}
531
533{
534 icFloatNumber sum=0;
536 for (i=0; i<nSample; i++) {
537 sum += icSq(v1[i] - v2[i]);
538 }
539 if (nSample)
540 sum /= nSample;
541
542 return (icFloatNumber)sqrt(sum);
543}
544
546{
548
549 if (num<-32768.0)
550 num = -32768.0;
551 else if (num>32767.0)
552 num = 32767.0;
553
554 rv = (icS15Fixed16Number)icRoundOffset((double)num*65536.0);
555
556 return rv;
557}
558
560{
561 icFloatNumber rv = (icFloatNumber)((double)num / 65536.0);
562
563 return rv;
564}
565
567{
569
570 if (num<0)
571 num = 0;
572 else if (num>65535.0)
573 num = 65535.0;
574
575 rv = (icU16Fixed16Number)icRoundOffset((double)num*65536.0);
576
577 return rv;
578}
579
581{
582 icFloatNumber rv = (icFloatNumber)((double)num / 65536.0);
583
584 return rv;
585}
586
588{
590
591 if (num<0)
592 num = 0;
593 else if (num>65535.0/32768.0)
594 num = 65535.0/32768.0;
595
596 rv = (icU1Fixed15Number)icRoundOffset(num*32768.0);
597
598 return rv;
599}
600
602{
603 icFloatNumber rv = (icFloatNumber)((icFloatNumber)num / 32768.0);
604
605 return rv;
606}
607
609{
611
612 if (num<0)
613 num = 0;
614 else if (num>255.0)
615 num = 255.0;
616
617 rv = (icU8Fixed8Number)icRoundOffset(num*256.0);
618
619 return rv;
620}
621
623{
624 icFloatNumber rv = (icFloatNumber)((icFloatNumber)num / 256.0);
625
626 return rv;
627}
628
630{
631 icUInt16Number numsgn, numexp, nummnt;
632 icUInt32Number rv, rvsgn, rvexp, rvmnt;
633 icInt32Number tmpexp;
634 icFloatNumber * rvfp, rvf;
635 int exp;
636
637 if (!(num & 0x7FFF)) {
638 rv = ((icUInt32Number) num) << 16;
639 } else {
640 numsgn = num & 0x8000;
641 numexp = num & 0x7C00;
642 nummnt = num & 0x03FF;
643 if (!numexp) {
644 exp = -1;
645 do {
646 exp++;
647 nummnt <<= 1;
648 } while (!(nummnt & 0x0400)); // Shift until leading bit overflows into exponent bit
649 rvsgn = ((icUInt32Number) numsgn) << 16;
650 tmpexp = ((icUInt32Number) (numexp >> 10)) - 15 + 127 - exp;
651 rvexp = (icUInt32Number) (tmpexp << 23);
652 rvmnt = ((icUInt32Number) (nummnt & 0x03FFu)) << 13;
653 rv = (rvsgn | rvexp | rvmnt);
654 } else if (numexp == 0x7C00) {
655 if (!nummnt) {
656 rv = (((icUInt32Number) numsgn) << 16) | ((icUInt32Number) 0x7F800000);
657 } else {
658 rv = (icUInt32Number) 0xFFC00000;
659 }
660 } else {
661 rvsgn = ((icUInt32Number) numsgn) << 16;
662 tmpexp = ((icUInt32Number) (numexp >> 10)) - 15 + 127;
663 rvexp = (icUInt32Number) (tmpexp << 23);
664 rvmnt = ((icUInt32Number) nummnt) << 13;
665 rv = (rvsgn | rvexp | rvmnt);
666 }
667 }
668 rvfp = (icFloatNumber*)&rv;
669 rvf = *rvfp;
670 return rvf;
671}
672
674{
676 icUInt16Number rvsgn, rvexp, rvmnt;
677 icUInt32Number flt, *fltp, fltsgn, fltexp, fltmnt;
678 int exp;
679
680 fltp = (icUInt32Number*)&num;
681 flt = *fltp;
682 if (!(flt & 0x7FFFFFFF)) {
683 rv = (icUInt16Number) (flt >> 16);
684 } else {
685 fltsgn = flt & 0x80000000;
686 fltexp = flt & 0x7F800000;
687 fltmnt = flt & 0x007FFFFF;
688 if (!fltexp) {
689 rv = (icUInt16Number) (fltsgn >> 16);
690 } else if (fltexp == 0x7F800000) {
691 if (!fltmnt) {
692 rv = (icUInt16Number) ((fltsgn >> 16) | 0x7C00); // Signed Inf
693 } else {
694 rv = (icUInt16Number) 0xFE00; // NaN
695 }
696 } else { // Normalized number
697 rvsgn = (icUInt16Number) (fltsgn >> 16);
698 exp = ((int)(fltexp >> 23)) - 127 + 15;
699 if (exp >= 0x1F) { // Overflow
700 rv = (icUInt16Number) ((fltsgn >> 16) | 0x7C00); // Signed Inf
701 } else if (exp <= 0) { // Underflow
702 if ((14 - exp) > 24) {
703 rvmnt = (icUInt16Number) 0; // Set mantissa to zero
704 } else {
705 fltmnt |= 0x00800000; // Include hidden leading bit
706 rvmnt = (icUInt16Number) (fltmnt >> (14 - exp));
707 if ((fltmnt >> (13 - exp)) & 0x00000001) // Rounding?
708 rvmnt += (icUInt16Number) 1;
709 }
710 rv = (rvsgn | rvmnt);
711 } else {
712 rvexp = (icUInt16Number) (exp << 10);
713 rvmnt = (icUInt16Number) (fltmnt >> 13);
714 if (fltmnt & 0x00001000) // Rounding?
715 rv = (rvsgn | rvexp | rvmnt) + (icUInt16Number) 1;
716 else
717 rv = (rvsgn | rvexp | rvmnt);
718 }
719 }
720 }
721 return rv;
722}
723
725{
726 icUInt8Number rv;
727
728 if (num<0)
729 num = 0;
730 else if (num>1.0)
731 num = 1.0;
732
733 rv = (icUInt8Number)icRoundOffset(num*255.0);
734
735 return rv;
736}
737
739{
740 icFloatNumber rv = (icFloatNumber)((icFloatNumber)num / 255.0);
741
742 return rv;
743}
744
746{
748
749 if (num<0)
750 num = 0;
751 else if (num>1.0)
752 num = 1.0;
753
754 rv = (icUInt16Number)icRoundOffset(num*65535.0);
755
756 return rv;
757}
758
760{
761 icFloatNumber rv = (icFloatNumber)((icFloatNumber)num / 65535.0);
762
763 return rv;
764}
765
767{
768 icFloatNumber v = num + 128.0f;
769 if (v<0)
770 v=0;
771 else if (v>255)
772 v=255;
773
774 return (icUInt8Number)(v + 0.5);
775}
776
778{
779 return (icFloatNumber)num - 128.0f;
780}
781
782ICCPROFLIB_API icFloatNumber icD50XYZ[3] = { 0.9642f, 1.0000f, 0.8249f };
783ICCPROFLIB_API icFloatNumber icD50XYZxx[3] = { 96.42f, 100.00f, 82.49f };
784
786{
787 if (!WhiteXYZ)
788 WhiteXYZ = icD50XYZ;
789
790 XYZ[0] = XYZ[0] / WhiteXYZ[0];
791 XYZ[1] = XYZ[1] / WhiteXYZ[1];
792 XYZ[2] = XYZ[2] / WhiteXYZ[2];
793}
794
796{
797 if (!WhiteXYZ)
798 WhiteXYZ = icD50XYZ;
799
800 XYZ[0] = XYZ[0] * WhiteXYZ[0];
801 XYZ[1] = XYZ[1] * WhiteXYZ[1];
802 XYZ[2] = XYZ[2] * WhiteXYZ[2];
803}
804
806{
807 if (v> 0.008856) {
808 return (icFloatNumber)ICC_CBRTF(v);
809 }
810 else {
811 return (icFloatNumber)(7.787037037037037037037037037037*v + 16.0/116.0);
812 }
813}
814
816{
817 if (v > 0.20689303448275862068965517241379)
818 return v*v*v;
819 else
820#ifndef SAMPLEICC_NOCLIPLABTOXYZ
821 if (v>16.0/116.0)
822#endif
823 return (icFloatNumber)((v - 16.0 / 116.0) / 7.787037037037037037037037037037);
824#ifndef SAMPLEICC_NOCLIPLABTOXYZ
825 else
826 return 0.0;
827#endif
828}
829
830void icLabtoXYZ(icFloatNumber *XYZ, const icFloatNumber *Lab /*=NULL*/, const icFloatNumber *WhiteXYZ /*=NULL*/)
831{
832 if (!Lab)
833 Lab = XYZ;
834
835 if (!WhiteXYZ)
836 WhiteXYZ = icD50XYZ;
837
838 icFloatNumber fy = (icFloatNumber)((Lab[0] + 16.0) / 116.0);
839
840 XYZ[0] = icICubeth((icFloatNumber)(Lab[1]/500.0 + fy)) * WhiteXYZ[0];
841 XYZ[1] = icICubeth(fy) * WhiteXYZ[1];
842 XYZ[2] = icICubeth((icFloatNumber)(fy - Lab[2]/200.0)) * WhiteXYZ[2];
843
844}
845
846void icXYZtoLab(icFloatNumber *Lab, const icFloatNumber *XYZ /*=NULL*/, const icFloatNumber *WhiteXYZ /*=NULL*/)
847{
848 icFloatNumber Xn, Yn, Zn;
849
850 if (!XYZ)
851 XYZ = Lab;
852
853 if (!WhiteXYZ)
854 WhiteXYZ = icD50XYZ;
855
856 Xn = icCubeth(XYZ[0] / WhiteXYZ[0]);
857 Yn = icCubeth(XYZ[1] / WhiteXYZ[1]);
858 Zn = icCubeth(XYZ[2] / WhiteXYZ[2]);
859
860 Lab[0] = (icFloatNumber)(116.0 * Yn - 16.0);
861 Lab[1] = (icFloatNumber)(500.0 * (Xn - Yn));
862 Lab[2] = (icFloatNumber)(200.0 * (Yn - Zn));
863
864}
865
866void icLch2Lab(icFloatNumber *Lab, icFloatNumber *Lch /*=NULL*/)
867{
868 if (!Lch) {
869 Lch = Lab;
870 }
871 else
872 Lab[0] = Lch[0];
873
874 icFloatNumber a = (icFloatNumber)(Lch[1] * cos(Lch[2] * PI / 180.0));
875 icFloatNumber b = (icFloatNumber)(Lch[1] * sin(Lch[2] * PI / 180.0));
876
877 Lab[1] = a;
878 Lab[2] = b;
879}
880
881void icLab2Lch(icFloatNumber *Lch, icFloatNumber *Lab /*=NULL*/)
882{
883 if (!Lab) {
884 Lab = Lch;
885 }
886 else
887 Lch[0] = Lab[0];
888
889 icFloatNumber c = (icFloatNumber)sqrt((double)Lab[1]*Lab[1] + (double)Lab[2]*Lab[2]);
890 icFloatNumber h = (icFloatNumber)(atan2(Lab[2], Lab[1]) * 180.0 / PI);
891 while (h<0.0)
892 h+=360.0;
893
894 Lch[1] = c;
895 Lch[2] = h;
896}
897
899{
900 return( v1 < v2 ? v1 : v2 );
901}
902
904{
905 return( v1 > v2 ? v1 : v2 );
906}
907
909{
910 return( v1 < v2 ? v1 : v2 );
911}
912
914{
915 return( v1 > v2 ? v1 : v2 );
916}
917
918
920{
921 Lab[0] *= 100.0;
922 Lab[1] = (icFloatNumber)(Lab[1]*255.0 - 128.0);
923 Lab[2] = (icFloatNumber)(Lab[2]*255.0 - 128.0);
924}
925
926
928{
929 Lab[0] /= 100.0;
930 Lab[1] = (icFloatNumber)((Lab[1] + 128.0) / 255.0);
931 Lab[2] = (icFloatNumber)((Lab[2] + 128.0) / 255.0);
932}
933
935{
936 XYZ[0] = (icFloatNumber)(XYZ[0] * 65535.0 / 32768.0);
937 XYZ[1] = (icFloatNumber)(XYZ[1] * 65535.0 / 32768.0);
938 XYZ[2] = (icFloatNumber)(XYZ[2] * 65535.0 / 32768.0);
939}
940
942{
943 XYZ[0] = (icFloatNumber)(XYZ[0] * 32768.0 / 65535.0);
944 XYZ[1] = (icFloatNumber)(XYZ[1] * 32768.0 / 65535.0);
945 XYZ[2] = (icFloatNumber)(XYZ[2] * 32768.0 / 65535.0);
946}
947
948
949#define DUMPBYTESPERLINE 16
950
951void icMemDump(std::string &sDump, void *pBuf, icUInt32Number nNum)
952{
953 icUInt8Number *pData = (icUInt8Number *)pBuf;
954 icChar buf[80] = {0};
955 icChar num[10] = {0};
956
957 icInt32Number i, j;
959
961 sDump.reserve(sDump.size() + lines*79);
962
963 for (i=0; i<(icInt32Number)nNum; i++, pData++) {
965 if (!j) {
966 if (i) {
967 sDump += (const icChar*)buf;
968 }
969 memset(buf, ' ', 76);
970 buf[76] = ' ';
971 buf[77] = '\n';
972 buf[78] = '\0';
973 sprintf(num, "%08X:", i);
974 strncpy(buf, num, 9);
975 }
976
977 sprintf(num, "%02X", *pData);
978 strncpy(buf+10+j*3, num, 2);
979
980 c=*pData;
981 if (!isprint(c))
982 c='.';
983 buf[10+16*3 + 1 + j] = c;
984 }
985 sDump += buf;
986}
987
988void icMatrixDump(std::string &sDump, icS15Fixed16Number *pMatrix)
989{
990 icChar buf[128];
991
992 sprintf(buf, "%8.4lf %8.4lf %8.4lf\n", icFtoD(pMatrix[0]), icFtoD(pMatrix[1]), icFtoD(pMatrix[2]));
993 sDump += buf;
994 sprintf(buf, "%8.4lf %8.4lf %8.4lf\n", icFtoD(pMatrix[3]), icFtoD(pMatrix[4]), icFtoD(pMatrix[5]));
995 sDump += buf;
996 sprintf(buf, "%8.4lf %8.4lf %8.4lf\n", icFtoD(pMatrix[6]), icFtoD(pMatrix[7]), icFtoD(pMatrix[8]));
997 sDump += buf;
998}
999
1000const icChar* icGet16bitSig(icChar* pBuf, icUInt16Number nSig, bool bGetHexVal)
1001{
1002 icUInt16Number sig = nSig;
1003 icUInt8Number c;
1004
1005 if (!nSig) {
1006 strcpy(pBuf, "NULL");
1007 return pBuf;
1008 }
1009
1010 pBuf[0] = '\'';
1011 c = (icUInt8Number)(sig >> 8);
1012 if (!isprint(c))
1013 c = '?';
1014 pBuf[1] = c;
1015 c = (icUInt8Number)(sig & 0x00FF);
1016 if (!isprint(c))
1017 c = '?';
1018 pBuf[2] = c;
1019
1020 if (bGetHexVal)
1021 sprintf(pBuf + 3, "' = %04X", nSig);
1022 else
1023 sprintf(pBuf + 3, "'");
1024
1025 return pBuf;
1026}
1027
1028const icChar *icGetSig(icChar *pBuf, icUInt32Number nSig, bool bGetHexVal)
1029{
1030 int i;
1031 icUInt32Number sig=nSig;
1032 icUInt8Number c;
1033
1034 if (!nSig) {
1035 strcpy(pBuf, "NULL");
1036 return pBuf;
1037 }
1038
1039 pBuf[0] = '\'';
1040 for (i=1; i<5; i++) {
1041 c=(icUInt8Number)(sig>>24);
1042 if (!isprint(c))
1043 c='?';
1044 pBuf[i]=c;
1045 sig <<=8;
1046 }
1047
1048 if (bGetHexVal)
1049 sprintf(pBuf+5, "' = %08X", nSig);
1050 else
1051 sprintf(pBuf+5, "'");
1052
1053 return pBuf;
1054}
1055
1057{
1058 int i, j=-1;
1059 icUInt32Number sig=nSig;
1060 icUInt8Number c;
1061 bool bGetHexVal = false;
1062
1063 for (i=0; i<4; i++) {
1064 c=(icUInt8Number)(sig>>24);
1065 if (!c) {
1066 j=i;
1067 }
1068 else if (j!=-1) {
1069 bGetHexVal = true;
1070 }
1071 else if (!isprint(c) ||c==':') {
1072 c='?';
1073 bGetHexVal = true;
1074 }
1075 pBuf[i]=c;
1076 sig <<=8;
1077 }
1078
1079 if (bGetHexVal)
1080 sprintf(pBuf, "%08Xh", nSig);
1081 else
1082 pBuf[4] = '\0';
1083
1084 return pBuf;
1085}
1086
1087
1088const icChar *icGetColorSig(icChar *pBuf, icUInt32Number nSig, bool bGetHexVal)
1089{
1090 icUInt32Number sig=nSig;
1091
1092 switch (icGetColorSpaceType(nSig)) {
1093 case icSigNChannelData:
1099
1100 pBuf[0]='\"';
1101 pBuf[1] = (icUInt8Number)(sig>>24);
1102 sig<<=8;
1103 pBuf[2] = (icUInt8Number)(sig>>24);
1104 sprintf(pBuf+3, "%04X\"", icNumColorSpaceChannels(nSig));
1105 return pBuf;
1106
1107 default:
1108 {
1109
1110 int i, j=-1;
1111 icUInt8Number c;
1112 bool bNeedHexVal = false;
1113
1114 pBuf[0] = '\'';
1115 for (i=1; i<5; i++) {
1116 c=(icUInt8Number)(sig>>24);
1117 if (!isprint(c)) {
1118 c = '?';
1119 bNeedHexVal = true;
1120 }
1121 pBuf[i]=c;
1122 sig <<=8;
1123 }
1124
1125 if (bGetHexVal)
1126 sprintf(pBuf+5, "' = %08X", nSig);
1127 else if (bNeedHexVal) {
1128 sprintf(pBuf, "%08Xh", nSig);
1129 }
1130 else
1131 sprintf(pBuf+5, "'");
1132 }
1133 }
1134
1135 return pBuf;
1136}
1137
1138
1140{
1141 icUInt32Number sig=nSig;
1142
1143 switch (icGetColorSpaceType(nSig)) {
1144 case icSigNChannelData:
1150
1151 pBuf[0] = (icUInt8Number)(sig>>24);
1152 sig<<=8;
1153 pBuf[1] = (icUInt8Number)(sig>>24);
1154 sprintf(pBuf+2, "%04X", icNumColorSpaceChannels(nSig));
1155 return pBuf;
1156
1157 default:
1158 {
1159
1160 int i, j=-1;
1161 icUInt8Number c;
1162 bool bGetHexVal = false;
1163
1164 for (i=0; i<4; i++) {
1165 c=(icUInt8Number)(sig>>24);
1166 if (!c) {
1167 j=i;
1168 }
1169 else if (j!=-1) {
1170 bGetHexVal = true;
1171 }
1172 else if (!isprint(c) ||c==':') {
1173 c='?';
1174 bGetHexVal = true;
1175 }
1176 pBuf[i]=c;
1177 sig <<=8;
1178 }
1179
1180 if (bGetHexVal)
1181 sprintf(pBuf, "%08Xh", nSig);
1182 else
1183 pBuf[4] = '\0';
1184 }
1185 }
1186
1187 return pBuf;
1188}
1189
1190
1192{
1193 char buf[20];
1194 std::string rv = ":";
1195
1196 rv += icGetSigStr(buf, nSig);
1197
1198 return rv;
1199}
1200
1202{
1203 icSignature rv = 0;
1204 const char *ptr = sigPath.c_str();
1205 while(*ptr==':') {
1206 std::string sigStr;
1207 ptr++;
1208 while(*ptr && *ptr!=':') {
1209 sigStr += *ptr;
1210 ptr++;
1211 }
1212 rv = icGetSigVal(sigStr.c_str());
1213 //Skip embedded tag path entry
1214 if (rv != icSigEmbeddedV5ProfileTag)
1215 break;
1216 }
1217 return rv;
1218}
1219
1221{
1222 size_t n = sigPath.length();
1223 if (!n)
1224 return icGetSigVal(sigPath.c_str());
1225
1226 const char *sig = sigPath.c_str();
1227
1228 for (n = n - 1; n > 0; n--) {
1229 if (sig[n] == ':') {
1230 break;
1231 }
1232 }
1233 if (/* n >= 0 && */ sig[n] == ':')
1234 n++;
1235 return icGetSigVal(sig+n);
1236}
1237
1239{
1240 icSignature rv = 0;
1241 const char *ptr = sigPath.c_str();
1242 if(*ptr==':') {
1243 std::string sigStr;
1244 ptr++;
1245 ptr = strchr(ptr+1, ':');
1246 if (ptr) {
1247 ptr++;
1248 while(*ptr && *ptr!=':') {
1249 sigStr += *ptr;
1250 ptr++;
1251 }
1252 rv = icGetSigVal(sigStr.c_str());
1253 }
1254 }
1255 return rv;
1256}
1257
1259{
1261
1262 switch(strlen(pBuf)) {
1263 case 0:
1264 return 0;
1265
1266 case 1:
1267 return (icUInt32Number)((((unsigned long)pBuf[0])<<24) +
1268 0x202020);
1269
1270 case 2:
1271 return (icUInt32Number)((((unsigned long)pBuf[0])<<24) +
1272 (((unsigned long)pBuf[1])<<16) +
1273 0x2020);
1274
1275 case 3:
1276 return (icUInt32Number)((((unsigned long)pBuf[0])<<24) +
1277 (((unsigned long)pBuf[1])<<16) +
1278 (((unsigned long)pBuf[2])<<8) +
1279 0x20);
1280
1281 case 4:
1282 default:
1283 return (icUInt32Number)((((unsigned long)pBuf[0])<<24) +
1284 (((unsigned long)pBuf[1])<<16) +
1285 (((unsigned long)pBuf[2])<<8) +
1286 (((unsigned long)pBuf[3])));
1287
1288 case 6: //Channel based color signatures
1289 sscanf(pBuf+2, "%x", &v);
1290
1291 return (icUInt32Number)((((unsigned long)pBuf[0])<<24) +
1292 (((unsigned long)pBuf[1])<<16) +
1293 v);
1294
1295 case 8:
1296 case 9:
1297 sscanf(pBuf, "%x", &v);
1298 return v;
1299 }
1300}
1301
1302
1304{
1305 switch(sig) {
1306 case icSigGrayData:
1307 case icSigGamutData:
1308 return 1;
1309
1310 case icSig2colorData:
1311 return 2;
1312
1313 case icSigXYZData:
1314 case icSigLabData:
1315 case icSigLuvData:
1316 case icSigYCbCrData:
1317 case icSigYxyData:
1318 case icSigRgbData:
1319 case icSigHsvData:
1320 case icSigHlsData:
1321 case icSigCmyData:
1322 case icSig3colorData:
1323 case icSigDevLabData:
1324 case icSigDevXYZData:
1325 return 3;
1326
1327 case icSigCmykData:
1328 case icSig4colorData:
1329 return 4;
1330
1331 default:
1332 switch (icGetColorSpaceType(sig)) {
1333 case icSigNChannelData:
1341
1342 default:
1343 {
1344 icChar szSig[5] = {0};
1345 szSig[0] = (icChar)(sig>>24);
1346 szSig[1] = (icChar)(sig>>16);
1347 szSig[2] = (icChar)(sig>>8);
1348 szSig[3] = (icChar)(sig);
1349 szSig[4] = '\0';
1350
1351 if (!strcmp(szSig+1, "CLR")) {
1352 int d0 = icHexDigit(szSig[0]);
1353 if (d0>=0)
1354 return d0;
1355 }
1356 else if (!strncmp(szSig, "MCH", 3)) { //Litte CMS multi-channel notation (not part of ICC specification)
1357 int d0 = icHexDigit(szSig[3]);
1358 if (d0>=0)
1359 return d0;
1360 }
1361 }
1362 return 0;
1363 }
1364 }
1365}
1366
1368{
1369 if (pHdr->spectralPCS)
1371 else
1372 return icGetSpaceSamples(pHdr->pcs);
1373}
1374
1376{
1377 switch (nStorageType) {
1378 case icValueTypeUInt8:
1379 return 1;
1380 case icValueTypeUInt16:
1381 case icValueTypeFloat16:
1382 return 2;
1383 case icValueTypeFloat32:
1384 return 4;
1385 default:
1386 return 0;
1387 }
1388}
1389
1390
1398
1400{
1401 return (rng1.start == rng2.start &&
1402 rng1.end == rng2.end &&
1403 rng1.steps == rng2.steps);
1404}
1405
1406CIccInfo::CIccInfo() : m_szStr{}, m_szSigStr{}
1407{
1408 m_str = new std::string;
1409}
1410
1412{
1413 delete m_str;
1414}
1415
1417{
1418 icChar buf[24];
1419 // icGetSig() will print 'NULL' if val is 0x00000000 which is easier to post-process
1420 // if (!val)
1421 // return "Unknown";
1422
1423 sprintf(m_szStr, "Unknown %s", icGetSig(buf, val));
1424
1425 return m_szStr;
1426}
1427
1429{
1430 icFloatNumber ver = (icFloatNumber)(((val>>28)&0xf)*10.0 + ((val>>24)&0xf) +
1431 ((val>>20)&0xf)/10.0 + ((val>>16)&0xf)/100.0);
1432
1433 sprintf(m_szStr, "%.2lf", ver);
1434
1435 return m_szStr;
1436}
1437
1439{
1440 icFloatNumber ver = (icFloatNumber)(((val >> 12) & 0xf)*10.0 + ((val >> 8) & 0xf) +
1441 ((val >> 4) & 0xf) / 10.0 + (val & 0xf) / 100.0);
1442
1443 sprintf(m_szStr, "%.2lf", ver);
1444
1445 return m_szStr;
1446}
1447
1449{
1450 if (val & icTransparency)
1451 strcpy(m_szStr, "Transparency");
1452 else
1453 strcpy(m_szStr, "Reflective");
1454
1455 int l=(int)strlen(m_szStr);
1456
1457 if (val & icMatte)
1458 strcpy(m_szStr+l, " | Matte");
1459 else
1460 strcpy(m_szStr+l, " | Glossy");
1461
1462 return m_szStr;
1463}
1464
1465const icChar *CIccInfo::GetProfileFlagsName(icUInt32Number val, bool bCheckMCS/*=false*/)
1466{
1467 if (val & icEmbeddedProfileTrue)
1468 strcpy(m_szStr, "EmbeddedProfileTrue");
1469 else
1470 strcpy(m_szStr, "EmbeddedProfileFalse");
1471
1472 int l=(int)strlen(m_szStr);
1473
1474 if (val & icUseWithEmbeddedDataOnly)
1475 strcpy(m_szStr+l, " | UseWithEmbeddedDataOnly");
1476 else
1477 strcpy(m_szStr+l, " | UseAnywhere");
1478
1479 if (bCheckMCS) {
1480 l=(int)strlen(m_szStr);
1481
1482 if (val & icMCSNeedsSubsetTrue)
1483 strcpy(m_szStr+l, " | MCSNeedsSubset");
1484 else
1485 strcpy(m_szStr+l, " | MCSConnectAny");
1486 }
1487
1488 if (val & icExtendedRangePCS)
1489 strcpy(m_szStr + l, " | ExtendedRangePCS");
1490
1491
1492 return m_szStr;
1493}
1494
1496{
1498 if (rv) {
1499 return rv;
1500 }
1501 return GetUnknownName(sig);
1502}
1503
1505{
1507 return m_str->c_str();
1508 }
1509 return GetUnknownName(sig);
1510}
1511
1513{
1515 return m_str->c_str();
1516 }
1517 return GetUnknownName(sig);
1518}
1519
1521{
1522 switch(sig) {
1523 case icSigDigitalCamera:
1524 return "DigitalCamera";
1525
1526 case icSigFilmScanner:
1527 return "FilmScanner";
1528
1530 return "ReflectiveScanner";
1531
1532 case icSigInkJetPrinter:
1533 return "InkJetPrinter";
1534
1536 return "ThermalWaxPrinter";
1537
1539 return "ElectrophotographicPrinter";
1540
1542 return "ElectrostaticPrinter";
1543
1545 return "DyeSublimationPrinter";
1546
1548 return "PhotographicPaperPrinter";
1549
1550 case icSigFilmWriter:
1551 return "FilmWriter";
1552
1553 case icSigVideoMonitor:
1554 return "VideoMonitor";
1555
1556 case icSigVideoCamera:
1557 return "VideoCamera";
1558
1560 return "ProjectionTelevision";
1561
1562 case icSigCRTDisplay:
1563 return "CRTDisplay";
1564
1565 case icSigPMDisplay:
1566 return "PMDisplay";
1567
1568 case icSigAMDisplay:
1569 return "AMDisplay";
1570
1571 case icSigPhotoCD:
1572 return "PhotoCD";
1573
1575 return "PhotoImageSetter";
1576
1577 case icSigGravure:
1578 return "Gravure";
1579
1581 return "OffsetLithography";
1582
1583 case icSigSilkscreen:
1584 return "Silkscreen";
1585
1586 case icSigFlexography:
1587 return "Flexography";
1588
1589 default:
1590 return GetUnknownName(sig);
1591 }
1592}
1593
1595{
1597 if (rv) {
1598 return rv;
1599 }
1600
1601 return GetUnknownName(sig);
1602}
1603
1605{
1606
1608 return m_str->c_str();
1609 }
1610
1611 return GetUnknownName(sig);
1612}
1613
1614std::string CIccInfo::GetSigPathName(std::string sigPath)
1615{
1616 std::string rv;
1617 const char *ptr = sigPath.c_str();
1618 int n =0;
1619 while(*ptr==':') {
1620 std::string sigStr;
1621 ptr++;
1622 while(*ptr && *ptr!=':') {
1623 sigStr += *ptr;
1624 ptr++;
1625 }
1626 icSignature sig = icGetSigVal(sigStr.c_str());
1627 if (n!=0) {
1628 rv += ">";
1629 }
1630 rv += GetPathEntrySigName(sig);
1631 n++;
1632 }
1633 if (n > 0)
1634 rv += ":";
1635
1636 return rv;
1637}
1638
1639
1641{
1642 switch (sig) {
1643 case icSigNoColorData:
1644 return "NoData";
1645
1646 case icSigXYZData:
1647 case icSigDevXYZData:
1648 return "XYZData";
1649
1650 case icSigLabData:
1651 case icSigDevLabData:
1652 return "LabData";
1653
1654 case icSigLuvData:
1655 return "LuvData";
1656
1657 case icSigYCbCrData:
1658 return "YCbCrData";
1659
1660 case icSigYxyData:
1661 return "YxyData";
1662
1663 case icSigRgbData:
1664 return "RgbData";
1665
1666 case icSigGrayData:
1667 return "GrayData";
1668
1669 case icSigHsvData:
1670 return "HsvData";
1671
1672 case icSigHlsData:
1673 return "HlsData";
1674
1675 case icSigCmykData:
1676 return "CmykData";
1677
1678 case icSigCmyData:
1679 return "CmyData";
1680
1681 case icSigMCH1Data:
1682 return "MCH1Data/1ColorData";
1683
1684 case icSigMCH2Data:
1685 return "MCH2Data/2ColorData";
1686
1687 case icSigMCH3Data:
1688 return "MCH3Data/3ColorData";
1689
1690 case icSigMCH4Data:
1691 return "MCH4Data/4ColorData";
1692
1693 case icSigMCH5Data:
1694 return "MCH5Data/5ColorData";
1695
1696 case icSigMCH6Data:
1697 return "MCH6Data/6ColorData";
1698
1699 case icSigMCH7Data:
1700 return "MCH7Data/7ColorData";
1701
1702 case icSigMCH8Data:
1703 return "MCH8Data/8ColorData";
1704
1705 case icSigMCH9Data:
1706 return "MCH9Data/9ColorData";
1707
1708 case icSigMCHAData:
1709 return "MCHAData/10ColorData";
1710
1711 case icSigMCHBData:
1712 return "MCHBData/11ColorData";
1713
1714 case icSigMCHCData:
1715 return "MCHCData/12ColorData";
1716
1717 case icSigMCHDData:
1718 return "MCHDData/13ColorData";
1719
1720 case icSigMCHEData:
1721 return "MCHEData/14ColorData";
1722
1723 case icSigMCHFData:
1724 return "MCHFData/15ColorData";
1725
1726 case icSigGamutData:
1727 return "GamutData";
1728
1729 case icSigNamedData:
1730 return "NamedData";
1731
1732 default:
1733 switch(icGetColorSpaceType(sig)) {
1734 case icSigNChannelData:
1735 sprintf(m_szStr, "0x%04XChannelData", icNumColorSpaceChannels(sig));
1736 return m_szStr;
1737
1739 sprintf(m_szStr, "0x%04XChannelReflectanceData", icNumColorSpaceChannels(sig));
1740 return m_szStr;
1741
1743 sprintf(m_szStr, "0x%04XChannelTransmissionData", icNumColorSpaceChannels(sig));
1744 return m_szStr;
1745
1747 sprintf(m_szStr, "0x%04XChannelRadiantData", icNumColorSpaceChannels(sig));
1748 return m_szStr;
1749
1751 sprintf(m_szStr, "0x%04XChannelBiDirReflectanceData", icNumColorSpaceChannels(sig));
1752 return m_szStr;
1753
1755 sprintf(m_szStr, "0x%04XChannelSparseMatrixReflectanceData", icNumColorSpaceChannels(sig));
1756 return m_szStr;
1757
1758 default:
1760 if (nChan>0) {
1761 sprintf(m_szStr, "0x%XColorData", nChan);
1762 return m_szStr;
1763 }
1764 return GetUnknownName(sig);
1765 }
1766 }
1767}
1768
1770{
1771 switch(icGetColorSpaceType(sig)) {
1773 return "NoSpectralData";
1774
1775 case icSigNChannelData:
1776 sprintf(m_szStr, "0x%04XChannelData", icNumColorSpaceChannels(sig));
1777 return m_szStr;
1778
1780 sprintf(m_szStr, "0x%04XChannelReflectanceData", icNumColorSpaceChannels(sig));
1781 return m_szStr;
1782
1784 sprintf(m_szStr, "0x%04XChannelTransmissionData", icNumColorSpaceChannels(sig));
1785 return m_szStr;
1786
1788 sprintf(m_szStr, "0x%04XChannelRadiantData", icNumColorSpaceChannels(sig));
1789 return m_szStr;
1790
1792 sprintf(m_szStr, "0x%04XChannelBiSpectralReflectanceData", icNumColorSpaceChannels(sig));
1793 return m_szStr;
1794
1796 sprintf(m_szStr, "0x%04XChannelSparseMatrixReflectanceData", icNumColorSpaceChannels(sig));
1797 return m_szStr;
1798
1799 default:
1800 return GetUnknownName(sig);
1801 }
1802}
1803
1805{
1806 switch (sig) {
1807 case icSigInputClass:
1808 return "InputClass";
1809
1810 case icSigDisplayClass:
1811 return "DisplayClass";
1812
1813 case icSigOutputClass:
1814 return "OutputClass";
1815
1816 case icSigLinkClass:
1817 return "LinkClass";
1818
1819 case icSigAbstractClass:
1820 return "AbstractClass";
1821
1823 return "ColorSpaceClass";
1824
1826 return "NamedColorClass";
1827
1829 return "ColorEncodingClass";
1830
1832 return "MaterialIdentificationClass";
1833
1835 return "MaterialVisualizationClass";
1836
1838 return "MaterialLinkClass";
1839
1840 default:
1841 return GetUnknownName(sig);
1842 }
1843}
1844
1846{
1847 switch (sig) {
1848 case icSigMacintosh:
1849 return "Macintosh";
1850
1851 case icSigMicrosoft:
1852 return "Microsoft";
1853
1854 case icSigSolaris:
1855 return "Solaris";
1856
1857 case icSigSGI:
1858 return "SGI";
1859
1860 case icSigTaligent:
1861 return "Taligent";
1862
1864 return "Unknown";
1865
1866 default:
1867 return GetUnknownName(sig);
1868 }
1869}
1870
1871
1872//The following signatures come from the signature registry
1873//Return the Description (minus CMM).
1875{
1876 switch (sig) {
1877 case icSigAdobe:
1878 return "Adobe";
1879
1880 case icSigAgfa:
1881 return "Agfa";
1882
1883 case icSigApple:
1884 return "Apple";
1885
1886 case icSigColorGear:
1887 return "ColorGear";
1888
1889 case icSigColorGearLite:
1890 return "ColorGear Lite";
1891
1892 case icSigColorGearC:
1893 return "ColorGear C";
1894
1895 case icSigEFI:
1896 return "EFI";
1897
1898 case icSigExactScan:
1899 return "ExactScan";
1900
1901 case icSigFujiFilm:
1902 return "Fuji Film";
1903
1904 case icSigHarlequinRIP:
1905 return "Harlequin RIP";
1906
1907 case icSigArgyllCMS:
1908 return "Argyll CMS";
1909
1910 case icSigLogoSync:
1911 return "LogoSync";
1912
1913 case icSigHeidelberg:
1914 return "Heidelberg";
1915
1916 case icSigLittleCMS:
1917 return "Little CMS";
1918
1919 case icSigKodak:
1920 return "Kodak";
1921
1922 case icSigKonicaMinolta:
1923 return "Konica Minolta";
1924
1925 case icSigMutoh:
1926 return "Mutoh";
1927
1928 case icSigRefIccMAX:
1929 return "RefIccMAX";
1930
1931 case icSigDemoIccMAX:
1932 return "DemoIccMAX";
1933
1934 case icSigRolfGierling:
1935 return "Rolf Gierling Multitools";
1936
1937 case icSigSampleICC:
1938 return "SampleIcc";
1939
1940 case icSigToshiba:
1941 return "Toshiba";
1942
1944 return "the imaging factory";
1945
1946 case icSigVivo:
1947 return "Vivo";
1948
1949 case icSigWareToGo:
1950 return "Ware To Go";
1951
1952 case icSigMicrosoft:
1953 return "Windows Color System";
1954
1955 case icSigZoran:
1956 return "Zoran";
1957
1958 default:
1959 return GetUnknownName(sig);
1960 }
1961}
1962
1963
1965{
1966 switch (sig) {
1968 return "perceptualReferenceMediumGamut";
1969
1970 default:
1971 return GetUnknownName(sig);
1972 }
1973}
1974
1975
1977{
1978 switch (sig) {
1980 return "Scene Colorimetry Estimates";
1981
1983 return "Scene Appearance Estimates";
1984
1986 return "Focal Plane Colorimetry Estimates";
1987
1989 return "Reflection Hardcopy Original Colorimetry";
1990
1992 return "Reflection Print Output Colorimetry";
1993
1994 default:
1995 return GetUnknownName(sig);
1996 }
1997}
1998
1999
2001{
2002 const icChar *rv;
2003
2005 if (rv != m_szStr)
2006 return rv;
2007
2009 if (rv != m_szStr)
2010 return rv;
2011
2013 if (rv != m_szStr)
2014 return rv;
2015
2017 if (rv != m_szStr)
2018 return rv;
2019
2021 if (rv != m_szStr)
2022 return rv;
2023
2025 if (rv != m_szStr)
2026 return rv;
2027
2029 if (rv != m_szStr)
2030 return rv;
2031
2033}
2034
2036{
2037 const icChar *rv;
2038
2040 if (rv != m_szStr)
2041 return rv;
2042
2044 if (rv != m_szStr)
2045 return rv;
2046
2048 if (rv != m_szStr)
2049 return rv;
2050
2051 return GetUnknownName(sig);
2052}
2053
2054
2056{
2057 switch (val) { // Directly switch on the enum without casting to int
2058 case icFlare0:
2059 return "Flare 0"; // Properly handle the 0% flare
2060
2061 case icFlare100:
2062 return "Flare 100"; // Properly handle the 100% flare
2063
2064 default:
2065 // Handle icMaxEnumFlare explicitly here if needed
2066 if (val == icMaxEnumFlare) {
2067 return "Max Flare"; // Special handling for the max sentinel value
2068 }
2069 // General default case for truly unexpected values
2070 std::snprintf(m_szStr, sizeof(m_szStr), "Unknown Flare '%d'", (int)val);
2071 return m_szStr;
2072 }
2073}
2074
2075
2077{
2078 switch (val) { // Directly use enum type, casting is not needed
2079 case icGeometryUnknown:
2080 return "Geometry Unknown";
2081 case icGeometry045or450:
2082 return "Geometry 0-45 or 45-0";
2083 case icGeometry0dord0:
2084 return "Geometry 0-d or d-0";
2085 default:
2086 std::snprintf(m_szStr, sizeof(m_szStr), "Unknown Geometry '%d'", (int)val);
2087 return m_szStr;
2088 }
2089}
2090
2092{
2093 switch (val) {
2094 case icPerceptual:
2095 return "Perceptual";
2096
2098 if (bIsV5)
2099 return "Relative";
2100 else
2101 return "Relative Colorimetric";
2102
2103 case icSaturation:
2104 return "Saturation";
2105
2107 if (bIsV5)
2108 return "Absolute";
2109 else
2110 return "Absolute Colorimetric";
2111
2112 default:
2113 sprintf(m_szStr, "Unknown Intent '%d", val);
2114 return m_szStr;
2115 }
2116}
2117
2119{
2120 switch (val) {
2121 case icSpotShapeUnknown:
2122 return "Spot Shape Unknown";
2123
2125 return "Spot Shape Printer Default";
2126
2127 case icSpotShapeRound:
2128 return "Spot Shape Round";
2129
2130 case icSpotShapeDiamond:
2131 return "Spot Shape Diamond";
2132
2133 case icSpotShapeEllipse:
2134 return "Spot Shape Ellipse";
2135
2136 case icSpotShapeLine:
2137 return "Spot Shape Line";
2138
2139 case icSpotShapeSquare:
2140 return "Spot Shape Square";
2141
2142 case icSpotShapeCross:
2143 return "Spot Shape Cross";
2144
2145 default:
2146 sprintf(m_szStr, "Unknown Spot Shape '%d", val);
2147 return m_szStr;
2148 }
2149}
2150
2152{
2153 switch (val) {
2154 case icStdObsUnknown:
2155 return "Unknown observer";
2156
2158 return "CIE 1931 (two degree) standard observer";
2159
2161 return "CIE 1964 (ten degree) standard observer";
2162
2163 default:
2164 sprintf(m_szStr, "Unknown Observer '%d", val);
2165 return m_szStr;
2166 }
2167}
2168
2170{
2171 switch (val) {
2173 return "Illuminant Unknown";
2174
2175 case icIlluminantD50:
2176 return "Illuminant D50";
2177
2178 case icIlluminantD65:
2179 return "Illuminant D65";
2180
2181 case icIlluminantD93:
2182 return "Illuminant D93";
2183
2184 case icIlluminantF2:
2185 return "Illuminant F2";
2186
2187 case icIlluminantD55:
2188 return "Illuminant D55";
2189
2190 case icIlluminantA:
2191 return "Illuminant A";
2192
2194 return "Illuminant EquiPowerE";
2195
2196 case icIlluminantF8:
2197 return "Illuminant F8";
2198
2200 return "Illuminant Black Body";
2201
2203 return "Illuminant Daylight";
2204
2205 case icIlluminantB:
2206 return "Illuminant B";
2207
2208 case icIlluminantC:
2209 return "Illuminant C";
2210
2211 case icIlluminantF1:
2212 return "Illuminant F1";
2213
2214 case icIlluminantF3:
2215 return "Illuminant F3";
2216
2217 case icIlluminantF4:
2218 return "Illuminant F4";
2219
2220 case icIlluminantF5:
2221 return "Illuminant F5";
2222
2223 case icIlluminantF6:
2224 return "Illuminant F6";
2225
2226 case icIlluminantF7:
2227 return "Illuminant F7";
2228
2229 case icIlluminantF9:
2230 return "Illuminant F9";
2231
2232 case icIlluminantF10:
2233 return "Illuminant F10";
2234
2235 case icIlluminantF11:
2236 return "Illuminant F11";
2237
2238 case icIlluminantF12:
2239 return "Illuminant F12";
2240
2241 default:
2242 sprintf(m_szStr, "Unknown Illuminant '%d", val);
2243 return m_szStr;
2244 }
2245}
2246
2248{
2249 switch (sig) {
2250 case icSigStatusA:
2251 return "Status A";
2252
2253 case icSigStatusE:
2254 return "Status E";
2255
2256 case icSigStatusI:
2257 return "Status I";
2258
2259 case icSigStatusT:
2260 return "Status T";
2261
2262 case icSigStatusM:
2263 return "Status M";
2264
2265 case icSigDN:
2266 return "DIN with no polarizing filter";
2267
2268 case icSigDNP:
2269 return "DIN with polarizing filter";
2270
2271 case icSigDNN:
2272 return "Narrow band DIN with no polarizing filter";
2273
2274 case icSigDNNP:
2275 return "Narrow band DIN with polarizing filter";
2276
2277 default:
2278 {
2279 char buf[10] = {0};
2280 buf[0] = (char)(sig>>24);
2281 buf[1] = (char)(sig>>16);
2282 buf[2] = (char)(sig>>8);
2283 buf[3] = (char)(sig);
2284 buf[4] = '\0';
2285
2286 sprintf(m_szStr, "Unknown Measurement Type '%s'", buf);
2287 return m_szStr;
2288 }
2289 }
2290}
2291
2292
2294{
2295 char *ptr = m_szStr;
2296 int i;
2297
2298 for (i=0; i<16; i++, ptr+=2) {
2299 sprintf(ptr, "%02x", profileID->ID8[i]);
2300 }
2301
2302 return m_szStr;
2303}
2304
2306{
2307 int i;
2308
2309 for (i=0; i<16; i++) {
2310 if (profileID->ID8[i])
2311 break;
2312 }
2313
2314 return i<16;
2315}
2316
2318{
2319 switch(colorant) {
2320 case icColorantITU:
2321 return "ITU-R BT.709";
2322
2323 case icColorantSMPTE:
2324 return "SMPTE RP145-1994";
2325
2326 case icColorantEBU:
2327 return "EBU Tech.3213-E";
2328
2329 case icColorantP22:
2330 return "P22";
2331
2332 default:
2333 return "Customized Encoding";
2334 }
2335}
2336
2337icValidateStatus CIccInfo::CheckData(std::string &sReport, const icXYZNumber &XYZ, std::string sDesc/*=""*/)
2338{
2340
2341 if (XYZ.X < 0) {
2342 sReport += icMsgValidateNonCompliant;
2343 sReport += sDesc;
2344 sReport += " - XYZNumber: Negative X value!\n";
2346 }
2347
2348 if (XYZ.Y < 0) {
2349 sReport += icMsgValidateNonCompliant;
2350 sReport += sDesc;
2351 sReport += " - XYZNumber: Negative Y value!\n";
2353 }
2354
2355 if (XYZ.Z < 0) {
2356 sReport += icMsgValidateNonCompliant;
2357 sReport += sDesc;
2358 sReport += " - XYZNumber: Negative Z value!\n";
2360 }
2361
2362 return rv;
2363}
2364
2365icValidateStatus CIccInfo::CheckData(std::string &sReport, const icFloatXYZNumber &XYZ, std::string sDesc/*=""*/)
2366{
2368
2369 if (XYZ.X < 0) {
2370 sReport += icMsgValidateNonCompliant;
2371 sReport += sDesc;
2372 sReport += " - FloatXYZNumber: Negative X value!\n";
2374 }
2375
2376 if (XYZ.Y < 0) {
2377 sReport += icMsgValidateNonCompliant;
2378 sReport += sDesc;
2379 sReport += " - FloatXYZNumber: Negative Y value!\n";
2381 }
2382
2383 if (XYZ.Z < 0) {
2384 sReport += icMsgValidateNonCompliant;
2385 sReport += sDesc;
2386 sReport += " - FloatXYZNumber: Negative Z value!\n";
2388 }
2389
2390 return rv;
2391}
2392
2393icValidateStatus CIccInfo::CheckData(std::string &sReport, const icSpectralRange &range, std::string sDesc/*=""*/)
2394{
2396
2397 if (icF16toF(range.end)<=icF16toF(range.start)) {
2398 sReport += icMsgValidateNonCompliant;
2399 sReport += sDesc;
2400 sReport += " - spectralRange: end wavelength must be greater than start wavelength!\n";
2402 }
2403
2404 if (range.steps<2) {
2405 sReport += icMsgValidateNonCompliant;
2406 sReport += sDesc;
2407 sReport += " - spectralRange: wavelength range must have at least two steps!\n";
2409 }
2410
2411 return rv;
2412}
2413
2414icValidateStatus CIccInfo::CheckData(std::string &sReport, const icDateTimeNumber &dateTime, std::string sDesc/*=""*/)
2415{
2417
2418 struct tm *newtime;
2419 time_t long_time;
2420
2421 time( &long_time ); /* Get time as long integer. */
2422 newtime = localtime( &long_time );
2423
2424 icChar buf[128];
2425 if (dateTime.year<1992) {
2426 sReport += icMsgValidateWarning;
2427 sReport += sDesc;
2428 sprintf(buf," - %u: Invalid year!\n",dateTime.year);
2429 sReport += buf;
2430 rv = icValidateWarning;
2431 }
2432
2433 int year = newtime->tm_year+1900;
2434 if (newtime->tm_mon==11 && newtime->tm_mday==31) {
2435 if (dateTime.year>(year+1)) {
2436 sReport += icMsgValidateWarning;
2437 sReport += sDesc;
2438 sprintf(buf," - %u: Invalid year!\n",dateTime.year);
2439 sReport += buf;
2441 }
2442 }
2443 else {
2444 if (dateTime.year>year) {
2445 sReport += icMsgValidateWarning;
2446 sReport += sDesc;
2447 sprintf(buf," - %u: Invalid year!\n",dateTime.year);
2448 sReport += buf;
2450 }
2451 }
2452
2453 if (dateTime.month<1 || dateTime.month>12) {
2454 sReport += icMsgValidateWarning;
2455 sReport += sDesc;
2456 sprintf(buf," - %u: Invalid month!\n",dateTime.month);
2457 sReport += buf;
2459 }
2460
2461 if (dateTime.day<1 || dateTime.day>31) {
2462 sReport += icMsgValidateWarning;
2463 sReport += sDesc;
2464 sprintf(buf," - %u: Invalid day!\n",dateTime.day);
2465 sReport += buf;
2467 }
2468
2469 if (dateTime.month==2) {
2470 if (dateTime.day>29) {
2471 sReport += icMsgValidateWarning;
2472 sReport += sDesc;
2473 sprintf(buf," - %u: Invalid day for February!\n",dateTime.day);
2474 sReport += buf;
2476 }
2477
2478 if (dateTime.day==29) {
2479 if ((dateTime.year%4)!=0) {
2480 sReport += icMsgValidateWarning;
2481 sReport += sDesc;
2482 sprintf(buf," - %u: Invalid day for February, year is not a leap year(%u)!\n",dateTime.day, dateTime.year);
2483 sReport += buf;
2485 }
2486 }
2487 }
2488
2489 if (dateTime.hours>23) {
2490 sReport += icMsgValidateWarning;
2491 sReport += sDesc;
2492 sprintf(buf," - %u: Invalid hour!\n",dateTime.hours);
2493 sReport += buf;
2495 }
2496
2497 if (dateTime.minutes>59) {
2498 sReport += icMsgValidateWarning;
2499 sReport += sDesc;
2500 sprintf(buf," - %u: Invalid minutes!\n",dateTime.minutes);
2501 sReport += buf;
2503 }
2504
2505 if (dateTime.seconds>59) {
2506 sReport += icMsgValidateWarning;
2507 sReport += sDesc;
2508 sprintf(buf," - %u: Invalid seconds!\n",dateTime.hours);
2509 sReport += buf;
2511 }
2512
2513 return rv;
2514}
2515
2516icValidateStatus CIccInfo::CheckLuminance(std::string &sReport, const icFloatXYZNumber &XYZ, std::string sDesc/*=""*/)
2517{
2519
2520 if (fabs(XYZ.Y - 1.0) < 0.01) {
2521 sReport += icMsgValidateWarning;
2522 sReport += sDesc;
2523 sReport += " - XYZNumber appears to be normalized! Y value should reflect absolute luminance.\n";
2524 rv = icValidateWarning;
2525 }
2526
2527 return rv;
2528}
2529
2530
2532{
2533 bool rv = true;
2534
2535 switch(sig) {
2536 case icSigXYZData:
2537 case icSigLabData:
2538 case icSigLuvData:
2539 case icSigYCbCrData:
2540 case icSigYxyData:
2541 case icSigRgbData:
2542 case icSigGrayData:
2543 case icSigHsvData:
2544 case icSigHlsData:
2545 case icSigCmykData:
2546 case icSigCmyData:
2547 case icSigMCH1Data:
2548 case icSigNamedData:
2549 case icSigGamutData:
2550 case icSig2colorData:
2551 case icSig3colorData:
2552 case icSig4colorData:
2553 case icSig5colorData:
2554 case icSig6colorData:
2555 case icSig7colorData:
2556 case icSig8colorData:
2557 case icSig9colorData:
2558 case icSig10colorData:
2559 case icSig11colorData:
2560 case icSig12colorData:
2561 case icSig13colorData:
2562 case icSig14colorData:
2563 case icSig15colorData:
2564 break;
2565
2566 default:
2567 switch(icGetColorSpaceType(sig)) {
2568 case icSigNChannelData:
2569 break;
2570 default:
2571 rv = false;
2572 }
2573 }
2574
2575 return rv;
2576}
2577
2578
2595
2596CIccPixelBuf::CIccPixelBuf(int nChan/* =icDefaultPixelBufSize */) : m_buf{}
2597{
2598 if (nChan>icDefaultPixelBufSize) {
2599 m_pixel = new icFloatNumber[nChan];
2600 }
2601 else {
2602 m_pixel = m_buf;
2603 }
2604}
2605
2607{
2608 if (m_pixel && m_pixel!=m_buf)
2609 delete [] m_pixel;
2610}
2611
2612#ifdef USEREFICCMAXNAMESPACE
2613} //namespace refIccMAX
2614#endif
icArraySignature sig
File: IccArrayFactory.h.
icFloatNumber icD50XYZ[3]
Definition IccUtil.cpp:782
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
icUInt16Number icU1Fixed15Number
Definition IccDefs.h:82
#define icSigDevXYZData
Definition IccDefs.h:92
icUInt16Number icU8Fixed8Number
Definition IccDefs.h:83
char icChar
Definition IccDefs.h:109
#define icSigDevLabData
Additional convenience color space signatures to distinguish between device encoding and PCS encoding...
Definition IccDefs.h:91
icValidateStatus
Definition IccDefs.h:118
@ icValidateOK
Definition IccDefs.h:119
@ icValidateWarning
Definition IccDefs.h:120
@ icValidateNonCompliant
Definition IccDefs.h:121
File: IccIO.h.
#define F(x, y, z)
Definition IccMD5.cpp:64
File: IccMpeFactory.h.
#define ICC_CBRTF(v)
#define ICCPROFLIB_API
File: IccStructFactory.h.
const icChar * szName
File: IccTagFactory.h.
icValidateStatus icMaxStatus(icValidateStatus s1, icValidateStatus s2)
Name: icMaxStatus.
Definition IccUtil.cpp:244
std::string icGetSigPath(icUInt32Number nSig)
Definition IccUtil.cpp:1191
icU1Fixed15Number icDtoUSF(icFloatNumber num)
Definition IccUtil.cpp:587
const icChar * icGetColorSig(icChar *pBuf, icUInt32Number nSig, bool bGetHexVal)
Definition IccUtil.cpp:1088
icFloatNumber icU8toAB(icUInt8Number num)
Definition IccUtil.cpp:777
icFloatNumber icD50XYZxx[3]
Definition IccUtil.cpp:783
const char * icMsgValidateWarning
Definition IccUtil.cpp:90
icFloatNumber icU16toF(icUInt16Number num)
Definition IccUtil.cpp:759
icUInt8Number icABtoU8(icFloatNumber num)
Definition IccUtil.cpp:766
static icFloatNumber icSq(icFloatNumber x)
Definition IccUtil.cpp:521
void icXyzToPcs(icFloatNumber *XYZ)
Definition IccUtil.cpp:941
icFloatNumber icUCFtoD(icU8Fixed8Number num)
Definition IccUtil.cpp:622
icFloatNumber icCubeth(icFloatNumber v)
Definition IccUtil.cpp:805
bool icValidTagPos(const icPositionNumber &pos, icUInt32Number nTagHeaderSize, icUInt32Number nTagSize, bool bAllowEmpty)
Name: icValidTagPos.
Definition IccUtil.cpp:163
static icInt32Number icHexDigit(icChar digit)
Definition IccUtil.cpp:251
void icDeNormXyz(icFloatNumber *XYZ, icFloatNumber *WhiteXYZ)
Definition IccUtil.cpp:795
static bool icIsS15Fixed16NumberNear(icS15Fixed16Number F, icFloatNumber D)
Definition IccUtil.cpp:356
icU16Fixed16Number icDtoUF(icFloatNumber num)
Definition IccUtil.cpp:566
void icXyzFromPcs(icFloatNumber *XYZ)
Floating point encoding of XYZ in PCS is in range 0.0 to 1.0 (Note: X=1.0 is encoded as about 0....
Definition IccUtil.cpp:934
bool icSameSpectralRange(const icSpectralRange &rng1, const icSpectralRange &rng2)
Definition IccUtil.cpp:1399
void icMatrixMultiply3x3(icFloatNumber *result, const icFloatNumber *l, const icFloatNumber *r)
Name: icMatrixMultiply3x3.
Definition IccUtil.cpp:457
bool icMatrixInvert3x3(icFloatNumber *M)
Name: icMatrixInvert3x3.
Definition IccUtil.cpp:391
icFloatNumber icUFtoD(icU16Fixed16Number num)
Definition IccUtil.cpp:580
void icVectorApplyMatrix3x3(icFloatNumber *result, const icFloatNumber *m, const icFloatNumber *v)
Name: icVectorApplyMatrix3x3.
Definition IccUtil.cpp:502
icUInt32Number icGetSpaceSamples(icColorSpaceSignature sig)
Definition IccUtil.cpp:1303
#define PI
Definition IccUtil.cpp:84
bool icIsIllumD50(icXYZNumber xyz)
Definition IccUtil.cpp:363
void icLch2Lab(icFloatNumber *Lab, icFloatNumber *Lch)
Definition IccUtil.cpp:866
void icMatrixDump(std::string &sDump, icS15Fixed16Number *pMatrix)
Definition IccUtil.cpp:988
icSignature icGetLastSigPathSig(std::string sigPath)
Definition IccUtil.cpp:1220
bool icIsNear(icFloatNumber v1, icFloatNumber v2, icFloatNumber nearRange)
Name: icIsNear.
Definition IccUtil.cpp:142
void * icRealloc(void *ptr, size_t size)
Name: icRealloc.
Definition IccUtil.cpp:111
icFloatNumber icFtoD(icS15Fixed16Number num)
Definition IccUtil.cpp:559
const icChar * icGetColorSigStr(icChar *pBuf, icUInt32Number nSig)
Definition IccUtil.cpp:1139
icFloatNumber icICubeth(icFloatNumber v)
Definition IccUtil.cpp:815
icFloatNumber icU8toF(icUInt8Number num)
Definition IccUtil.cpp:738
icUInt32Number icGetSpectralSpaceSamples(const icHeader *pHdr)
Definition IccUtil.cpp:1367
void icLabFromPcs(icFloatNumber *Lab)
Floating point encoding of Lab in PCS is in range 0.0 to 1.0.
Definition IccUtil.cpp:919
void icNormXyz(icFloatNumber *XYZ, icFloatNumber *WhiteXYZ)
Definition IccUtil.cpp:785
icFloatNumber icMin(icFloatNumber v1, icFloatNumber v2)
Definition IccUtil.cpp:898
icSignature icGetSecondSigPathSig(std::string sigPath)
Definition IccUtil.cpp:1238
icUInt8Number icFtoU8(icFloatNumber num)
Definition IccUtil.cpp:724
const char * icMsgValidateInformation
Definition IccUtil.cpp:93
void icLabToPcs(icFloatNumber *Lab)
Definition IccUtil.cpp:927
icFloatNumber icRmsDif(const icFloatNumber *v1, const icFloatNumber *v2, icUInt32Number nSample)
Definition IccUtil.cpp:532
void icColorValue(icChar *szValue, icFloatNumber nValue, icColorSpaceSignature csSig, int nIndex, bool bUseLegacy)
Definition IccUtil.cpp:330
icUInt32Number icGetMaterialColorSpaceSamples(icMaterialColorSignature sig)
Definition IccUtil.cpp:1391
void icLabtoXYZ(icFloatNumber *XYZ, const icFloatNumber *Lab, const icFloatNumber *WhiteXYZ)
Definition IccUtil.cpp:830
double icRoundOffset(double v)
Name: icRoundOffset.
Definition IccUtil.cpp:223
icFloat16Number icFtoF16(icFloat32Number num)
Definition IccUtil.cpp:673
bool icIsSpaceCLR(icColorSpaceSignature sig)
Definition IccUtil.cpp:262
icS15Fixed16Number icDtoF(icFloatNumber num)
Definition IccUtil.cpp:545
void icMemDump(std::string &sDump, void *pBuf, icUInt32Number nNum)
Definition IccUtil.cpp:951
icUInt32Number icIntMax(icUInt32Number v1, icUInt32Number v2)
Definition IccUtil.cpp:913
icFloatNumber icDeltaE(const icFloatNumber *lab1, const icFloatNumber *lab2)
Definition IccUtil.cpp:527
const char * icMsgValidateNonCompliant
Definition IccUtil.cpp:91
icUInt16Number icFtoU16(icFloatNumber num)
Definition IccUtil.cpp:745
icFloatNumber icUSFtoD(icU1Fixed15Number num)
Definition IccUtil.cpp:601
icFloatNumber icMax(icFloatNumber v1, icFloatNumber v2)
Definition IccUtil.cpp:903
icUInt32Number icIntMin(icUInt32Number v1, icUInt32Number v2)
Definition IccUtil.cpp:908
icUInt8Number icGetStorageTypeBytes(icUInt16Number nStorageType)
Definition IccUtil.cpp:1375
void icLab2Lch(icFloatNumber *Lch, icFloatNumber *Lab)
Definition IccUtil.cpp:881
void icColorIndexName(icChar *szName, icColorSpaceSignature csSig, int nIndex, int nColors, const icChar *szUnknown)
Definition IccUtil.cpp:295
const char * icMsgValidateCriticalError
Definition IccUtil.cpp:92
icUInt32Number icGetSigVal(const icChar *pBuf)
Definition IccUtil.cpp:1258
const icChar * icGet16bitSig(icChar *pBuf, icUInt16Number nSig, bool bGetHexVal)
Definition IccUtil.cpp:1000
bool icValidOverlap(const icPositionNumber &pos1, const icPositionNumber &pos2, bool bAllowSame)
Name: icValidOverlap.
Definition IccUtil.cpp:195
void icXYZtoLab(icFloatNumber *Lab, const icFloatNumber *XYZ, const icFloatNumber *WhiteXYZ)
Definition IccUtil.cpp:846
icFloatNumber icF16toF(icFloat16Number num)
Definition IccUtil.cpp:629
#define DUMPBYTESPERLINE
Definition IccUtil.cpp:949
const icChar * icGetSigStr(icChar *pBuf, icUInt32Number nSig)
Definition IccUtil.cpp:1056
icSignature icGetFirstSigPathSig(std::string sigPath)
Definition IccUtil.cpp:1201
const icChar * icGetSig(icChar *pBuf, icUInt32Number nSig, bool bGetHexVal)
Definition IccUtil.cpp:1028
icU8Fixed8Number icDtoUCF(icFloatNumber num)
Definition IccUtil.cpp:608
File: IccUtil.h.
icValidateStatus icMaxStatus(icValidateStatus s1, icValidateStatus s2)
Name: icMaxStatus.
Definition IccUtil.cpp:244
const char * icMsgValidateWarning
Definition IccUtil.cpp:90
const icChar * icGetSig(icChar *pBuf, icUInt32Number sig, bool bGetHexVal=true)
Definition IccUtil.cpp:1028
icUInt32Number icGetSpaceSamples(icColorSpaceSignature sig)
Definition IccUtil.cpp:1303
#define icDefaultPixelBufSize
Type: Class.
Definition IccUtil.h:373
const char * icMsgValidateNonCompliant
Definition IccUtil.cpp:91
icUInt32Number icGetSigVal(const icChar *pBuf)
Definition IccUtil.cpp:1258
icFloat32Number icF16toF(icFloat16Number num)
Definition IccUtil.cpp:629
icTagTypeSignature
unsigned int icUInt32Number
static bool GetArraySigName(std::string &arrayName, icArraySignature arrayTypeSig, bool bFillUnknown=true)
Function: GetArraySigName(structTypeSig) Get display name of structTypeSig.
bool IsProfileIDCalculated(icProfileID *profileID)
Definition IccUtil.cpp:2305
const icChar * GetVersionName(icUInt32Number val)
Definition IccUtil.cpp:1428
const icChar * GetTechnologySigName(icTechnologySignature sig)
Definition IccUtil.cpp:1520
const icChar * GetSpectralColorSigName(icSpectralColorSignature sig)
Definition IccUtil.cpp:1769
const icChar * GetStructSigName(icStructSignature sig)
Definition IccUtil.cpp:1504
const icChar * GetColorantEncoding(icColorantEncoding colorant)
Definition IccUtil.cpp:2317
const icChar * GetColorimetricIntentImageStateName(icColorimetricIntentImageStateSignature sig)
Definition IccUtil.cpp:1976
icChar m_szStr[128]
Definition IccUtil.h:358
const icChar * GetCmmSigName(icCmmSignature sig)
Definition IccUtil.cpp:1874
const icChar * GetArraySigName(icArraySignature sig)
Definition IccUtil.cpp:1512
const icChar * GetProfileClassSigName(icProfileClassSignature sig)
Definition IccUtil.cpp:1804
bool IsValidSpace(icColorSpaceSignature sig)
Definition IccUtil.cpp:2531
const icChar * GetTagSigName(icTagSignature sig)
Definition IccUtil.cpp:1495
bool IsValidSpectralSpace(icColorSpaceSignature sig)
Definition IccUtil.cpp:2579
const icChar * GetIlluminantName(icIlluminant val)
Definition IccUtil.cpp:2169
const icChar * GetElementTypeSigName(icElemTypeSignature sig)
Definition IccUtil.cpp:1604
const icChar * GetUnknownName(icUInt32Number val)
Definition IccUtil.cpp:1416
const icChar * GetSpotShapeName(icSpotShape val)
Definition IccUtil.cpp:2118
const icChar * GetProfileFlagsName(icUInt32Number val, bool bCheckMCS=false)
Definition IccUtil.cpp:1465
const icChar * GetMeasurementUnit(icSignature sig)
Definition IccUtil.cpp:2247
const icChar * GetPlatformSigName(icPlatformSignature sig)
Definition IccUtil.cpp:1845
const icChar * GetProfileID(icProfileID *profileID)
Definition IccUtil.cpp:2293
const icChar * GetPathEntrySigName(icUInt32Number val)
Definition IccUtil.cpp:2035
const icChar * GetMeasurementGeometryName(icMeasurementGeometry val)
Definition IccUtil.cpp:2076
const icChar * GetMeasurementFlareName(icMeasurementFlare val)
Definition IccUtil.cpp:2055
const icChar * GetColorSpaceSigName(icColorSpaceSignature sig)
Definition IccUtil.cpp:1640
const icChar * GetTagTypeSigName(icTagTypeSignature sig)
Definition IccUtil.cpp:1594
std::string * m_str
Definition IccUtil.h:360
const icChar * GetSigName(icUInt32Number val)
Definition IccUtil.cpp:2000
const icChar * GetReferenceMediumGamutSigNameName(icReferenceMediumGamutSignature sig)
Definition IccUtil.cpp:1964
const icChar * GetDeviceAttrName(icUInt64Number val)
Definition IccUtil.cpp:1448
icValidateStatus CheckLuminance(std::string &sReport, const icFloatXYZNumber &XYZ, std::string sDesc="")
Definition IccUtil.cpp:2516
const icChar * GetStandardObserverName(icStandardObserver val)
Definition IccUtil.cpp:2151
std::string GetSigPathName(std::string sigPath)
Definition IccUtil.cpp:1614
const icChar * GetSubClassVersionName(icUInt32Number val)
Definition IccUtil.cpp:1438
virtual ~CIccInfo()
Definition IccUtil.cpp:1411
const icChar * GetRenderingIntentName(icRenderingIntent val, bool bIsV5=false)
Definition IccUtil.cpp:2091
icValidateStatus CheckData(std::string &sReport, const icDateTimeNumber &dateTime, std::string sDesc="")
Definition IccUtil.cpp:2414
static bool GetElementSigName(std::string &elemName, icElemTypeSignature elemTypeSig)
Function: GetElementSigName(elemTypeSig) Get display name of elemTypeSig.
icFloatNumber m_buf[100]
Definition IccUtil.h:386
icFloatNumber * m_pixel
Definition IccUtil.h:387
CIccPixelBuf(int nChan=100)
Definition IccUtil.cpp:2596
static bool GetStructSigName(std::string &structName, icStructSignature structTypeSig, bool bFillUnknown=true)
Function: GetStructSigName(structTypeSig) Get display name of structTypeSig.
static const icChar * GetTagSigName(icTagSignature tagTypeSig)
Function: GetTagSigName(tagSig) Get display name of tagSig.
static const icChar * GetTagTypeSigName(icTagTypeSignature tagTypeSig)
Function: GetTagTypeSigName(tagTypeSig) Get display name of tagTypeSig.
unsigned char icUInt8Number
Number definitions.
float icFloat32Number
unsigned short icUInt16Number
icUInt32Number icU16Fixed16Number
long icInt32Number
#define icNumColorSpaceChannels(sig)
icTechnologySignature
technology signature descriptions
@ icSigFilmWriter
@ icSigCRTDisplay
@ icSigOffsetLithography
@ icSigFlexography
@ icSigSilkscreen
@ icSigPhotographicPaperPrinter
@ icSigVideoMonitor
@ icSigElectrostaticPrinter
@ icSigPMDisplay
@ icSigGravure
@ icSigInkJetPrinter
@ icSigReflectiveScanner
@ icSigDigitalCamera
@ icSigVideoCamera
@ icSigDyeSublimationPrinter
@ icSigThermalWaxPrinter
@ icSigFilmScanner
@ icSigPhotoCD
@ icSigPhotoImageSetter
@ icSigElectrophotographicPrinter
@ icSigProjectionTelevision
@ icSigAMDisplay
icProfileClassSignature
profileClass enumerations
@ icSigAbstractClass
@ icSigColorEncodingClass
@ icSigDisplayClass
@ icSigMaterialVisualizationClass
@ icSigOutputClass
@ icSigInputClass
@ icSigMaterialLinkClass
@ icSigColorSpaceClass
@ icSigNamedColorClass
@ icSigMaterialIdentificationClass
@ icSigLinkClass
icIlluminant
Pre-defined illuminants, used in measurement and viewing conditions type.
@ icIlluminantF6
@ icIlluminantF8
@ icIlluminantF1
@ icIlluminantEquiPowerE
@ icIlluminantF11
@ icIlluminantF7
@ icIlluminantF2
@ icIlluminantF4
@ icIlluminantF3
@ icIlluminantD55
@ icIlluminantDaylight
@ icIlluminantB
@ icIlluminantA
@ icIlluminantF9
@ icIlluminantBlackBody
@ icIlluminantUnknown
@ icIlluminantD65
@ icIlluminantF10
@ icIlluminantD93
@ icIlluminantD50
@ icIlluminantC
@ icIlluminantF5
@ icIlluminantF12
#define icTransparency
icMeasurementFlare
Other enums.
@ icFlare100
@ icFlare0
icColorantEncoding
Colorant and Phosphor Encodings used in chromaticity type.
@ icColorantEBU
@ icColorantITU
@ icColorantSMPTE
@ icColorantP22
#define icGetColorSpaceType(sig)
icUInt16Number icFloat16Number
IEEE float storage numbers.
icMaterialColorSignature
#define icMatte
icElemTypeSignature
Multi-Processing Element type signatures.
icColorSpaceSignature
Color Space Signatures.
@ icSig14colorData
@ icSigLabData
@ icSig2colorData
@ icSigLuvData
@ icSig8colorData
@ icSigMCHCData
@ icSigNoColorData
@ icSigMCH4Data
@ icSig10colorData
@ icSig7colorData
@ icSig9colorData
@ icSigMCH6Data
@ icSigMCH8Data
@ icSigMCH7Data
@ icSigXYZData
@ icSig13colorData
@ icSigSrcMCSChannelData
@ icSig6colorData
@ icSigMCH5Data
@ icSigMCH9Data
@ icSigMCH1Data
@ icSigNamedData
@ icSigMCHEData
@ icSigCmykData
@ icSigNChannelData
@ icSigMCH3Data
@ icSigMCH2Data
@ icSigRgbData
@ icSigHlsData
@ icSigMCHAData
@ icSig4colorData
@ icSigMCHDData
@ icSigYCbCrData
@ icSig12colorData
@ icSig11colorData
@ icSigMCHBData
@ icSigMCHFData
@ icSigCmyData
@ icSigGrayData
@ icSig15colorData
@ icSig3colorData
@ icSigHsvData
@ icSigYxyData
@ icSig5colorData
icUInt32Number icSignature
#define icEmbeddedProfileTrue
@ icSigStatusI
@ icSigStatusE
@ icSigDNNP
@ icSigStatusA
@ icSigDN
@ icSigStatusT
@ icSigDNP
@ icSigDNN
@ icSigStatusM
icStructSignature
Tag Structure type signatures.
icUInt32Number icUInt64Number[2]
#define icSigUnknownData
icSpectralColorSignature
icSpectralColorSignature enumerations
@ icSigReflectanceSpectralData
@ icSigTransmisionSpectralData
@ icSigNoSpectralData
@ icSigBiSpectralReflectanceData
@ icSigRadiantSpectralData
@ icSigSparseMatrixReflectanceData
icPlatformSignature
Platform Signatures.
@ icSigSGI
@ icSigTaligent
@ icSigMacintosh
@ icSigUnkownPlatform
@ icSigSolaris
@ icSigMicrosoft
#define icMaxEnumFlare
Convenience Enum Definition - Not defined in ICC specification.
#define icUseWithEmbeddedDataOnly
icMeasurementGeometry
Measurement Geometry, used in the measurmentType tag.
@ icGeometry045or450
@ icGeometry0dord0
@ icGeometryUnknown
icArraySignature
Tag Array type signatures.
icColorimetricIntentImageStateSignature
Colorimetric Intent Image State Gamut Signatures.
@ icSigSceneColorimetryEstimates
@ icSigReflectionPrintOutputColorimetry
@ icSigFocalPlaneColorimetryEstimates
@ icSigReflectionHardcopyOriginalColorimetry
@ icSigSceneAppearanceEstimates
icSpotShape
Different Spot Shapes currently defined, used for screeningType.
@ icSpotShapeCross
@ icSpotShapeDiamond
@ icSpotShapeLine
@ icSpotShapePrinterDefault
@ icSpotShapeEllipse
@ icSpotShapeSquare
@ icSpotShapeRound
@ icSpotShapeUnknown
icInt32Number icS15Fixed16Number
Fixed numbers.
icReferenceMediumGamutSignature
Rendering Intent Gamut Signatures.
@ icSigPerceptualReferenceMediumGamut
icTagSignature
public tags and sizes
@ icSigEmbeddedV5ProfileTag
#define icExtendedRangePCS
icRenderingIntent
Rendering Intents, used in the profile header.
@ icPerceptual
@ icRelativeColorimetric
@ icAbsoluteColorimetric
@ icSaturation
@ icValueTypeFloat16
@ icValueTypeUInt8
@ icValueTypeUInt16
@ icValueTypeFloat32
#define icMCSNeedsSubsetTrue
icStandardObserver
Standard Observer, used in the measurmentType tag.
@ icStdObsUnknown
@ icStdObs1964TenDegrees
@ icStdObs1931TwoDegrees
#define icSigGamutData
Convenience Enum Definitions - Not defined in ICC specification.
icCmmSignature
CMM signatures from the signature registry (as of Mar 6, 2018)
@ icSigDemoIccMAX
@ icSigAgfa
@ icSigColorGearC
@ icSigColorGear
@ icSigTheImagingFactory
@ icSigLogoSync
@ icSigRolfGierling
@ icSigColorGearLite
@ icSigKonicaMinolta
@ icSigKodak
@ icSigSampleICC
@ icSigArgyllCMS
@ icSigHarlequinRIP
@ icSigToshiba
@ icSigExactScan
@ icSigHeidelberg
@ icSigMutoh
@ icSigEFI
@ icSigZoran
@ icSigFujiFilm
@ icSigAdobe
@ icSigLittleCMS
@ icSigRefIccMAX
@ icSigVivo
@ icSigApple
@ icSigWareToGo
The base date time number.
icUInt16Number year
icUInt16Number month
icUInt16Number minutes
icUInt16Number seconds
icUInt16Number hours
icUInt16Number day
Floting point XYZ.
icFloat32Number Z
icFloat32Number Y
icFloat32Number X
The Profile header.
icSpectralColorSignature spectralPCS
icColorSpaceSignature pcs
icUInt32Number offset
icUInt32Number size
spectral range
icUInt16Number steps
icFloat16Number start
icFloat16Number end
icS15Fixed16Number Y
icS15Fixed16Number Z
icS15Fixed16Number X
Profile ID.
icUInt8Number ID8[16]