-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathicc_helfer.cpp
1966 lines (1783 loc) · 57 KB
/
icc_helfer.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* ICC Examin ist eine ICC Profil Betrachter
*
* Copyright (C) 2004-2013 Kai-Uwe Behrmann
*
* Autor: Kai-Uwe Behrmann <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* -----------------------------------------------------------------------------
*
* preparation of ICC inner informations
*
*/
// Date: 04. 05. 2004
#if 0
# ifndef DEBUG
# define DEBUG
# endif
# define DEBUG_ICCFUNKT
#endif
#include <icc34.h>
#include "icc_utils.h"
#include "icc_formeln.h"
#include "icc_helfer.h"
#include "icc_oyranos.h"
#include "icc_profile.h"
#include "icc_examin_version.h"
#include <cstring>
#define g_message printf
/** @brief MSB<->LSB */
icUInt16Number
icValue (icUInt16Number val)
{
return oyValueUInt16 (val);
}
icUInt32Number
icValue (icUInt32Number val)
{
return oyValueUInt32 (val);
}
my_uint64_t
icValue (icUInt64Number val)
{
return oyValueUInt64 (val);
}
icInt32Number
icValue (icInt32Number val)
{
#if BYTE_ORDER == LITTLE_ENDIAN
# define BYTES 4
# define KORB 4
unsigned char *temp = (unsigned char*) &val;
static unsigned char korb[KORB];
for (int i = 0; i < KORB ; i++ )
korb[i] = (int) 0;
int klein = 0,
gross = BYTES - 1;
for (; klein < BYTES ; klein++ )
korb[klein] = temp[gross--];
signed int *erg = (signed int*) &korb[0];
# ifdef DEBUG_ICCFUNKT
cout << *erg << " size after conversion " << (int)korb[0] << " "
<< (int)korb[1] << " " << (int)korb[2] << " " <<(int)korb[3]
<< " "; DBG_PROG
# endif
# undef BYTES
# undef KORB
return (signed int)*erg;
#else
return val;
#endif
}
icInt16Number
icValue (icInt16Number val)
{
#if BYTE_ORDER == LITTLE_ENDIAN
# define BYTES 2
# define KORB 4
unsigned char *temp = (unsigned char*) &val;
static unsigned char korb[KORB];
for (int i = 0; i < KORB ; i++ )
korb[i] = (int) 0;
int klein = 0,
gross = BYTES - 1;
for (; klein < BYTES ; klein++ )
korb[klein] = temp[gross--];
signed int *erg = (signed int*) &korb[0];
# ifdef DEBUG_ICCFUNKT
cout << *erg << " size after conversion " << (int)korb[0] << " "
<< (int)korb[1] << " " << (int)korb[2] << " " <<(int)korb[3]
<< " "; DBG_PROG
# endif
# undef BYTES
# undef KORB
return (signed int)*erg;
#else
return val;
#endif
}
icS15Fixed16Number
icValueSF (double val)
{
return icValue((icS15Fixed16Number)(val * 65536.0 + 0.5));
}
icU16Fixed16Number
icValueUF (double val)
{
return icValue((icU16Fixed16Number)(val * 65536.0 + 0.5));
}
icUInt16Number
icValueUI16 (double val)
{
return icValue((icUInt16Number)(val * 65536.0 + 0.5));
}
double
icSFValue (icS15Fixed16Number val)
{
return icValue(val) / 65536.0;
}
double
icUFValue (icU16Fixed16Number val)
{
return icValue(val) / 65536.0;
}
double
icUI16Value (icUInt16Number val)
{
return icValue(val) / 65536.0;
}
icColorSpaceSignature
icValue (icColorSpaceSignature val)
{
icUInt32Number i = val;
return (icColorSpaceSignature) icValue (i);
}
#define icValue_to_icUInt32Number(typ) \
typ \
icValue (typ val) \
{ \
icUInt32Number i = val; \
return (typ) oyValueUInt32 (i); \
}
icValue_to_icUInt32Number(icPlatformSignature)
icValue_to_icUInt32Number(icProfileClassSignature)
icValue_to_icUInt32Number(icTagSignature)
icValue_to_icUInt32Number(icTagTypeSignature)
icValue_to_icUInt32Number(icTechnologySignature)
icValue_to_icUInt32Number(icStandardObserver)
icValue_to_icUInt32Number(icMeasurementGeometry)
icValue_to_icUInt32Number(icMeasurementFlare)
icValue_to_icUInt32Number(icIlluminant)
void
icValueXYZ (icXYZNumber* ic_xyz,double X, double Y, double Z)
{
ic_xyz->X = icValueSF(X);
ic_xyz->Y = icValueSF(Y);
ic_xyz->Z = icValueSF(Z);
}
// Farbkonvertierungen
void
xyYto_XYZ (ICClist<double> & Y)
{
if( (Y.size()%3) || Y.size() == 0 ) {
WARN_S( "xyY is not a multiply of 3" )
return;
}
for(unsigned int i = 0; i < Y.size()/3; ++i)
{
double xyY[3] = {Y[i*3+0], Y[i*3+1], Y[i*3+2] };
Y[i*3+0] = xyY[0]/*x*/ * xyY[2]/*Y*/ / xyY[1]/*y*/;
Y[i*3+1] = xyY[2];
Y[i*3+2] = (1-xyY[0]-xyY[1]) * xyY[2] / xyY[1];
DBG_PROG_S( Y[i*3+0] << ", " << Y[i*3+1] << ", " << Y[i*3+2] )
}
}
void
XYZto_xyY (ICClist<double> & Y)
{
if( (Y.size()%3) || Y.size() == 0 ) {
WARN_S( "XYZ is not a multiply of 3" )
return;
}
for(unsigned int i = 0; i < Y.size()/3; ++i)
{
double XYZ[3] = {Y[i*3+0], Y[i*3+1], Y[i*3+2] };
double summe = (XYZ[0] + XYZ[1] + XYZ[2]) + 0.0000001;
Y[i*3+0] = XYZ[0] / summe;
Y[i*3+1] = XYZ[1] / summe;
Y[i*3+2] = XYZ[1];
DBG_PROG_S( Y[i*3+0] << ", " << Y[i*3+1] << ", " << Y[i*3+2] )
}
}
const double*
XYZto_xyY (double* XYZ)
{
static double xyY[3];
double summe = (XYZ[0] + XYZ[1] + XYZ[2]) + 0.0000001;
xyY[0] = XYZ[0] / summe;
xyY[1] = XYZ[1] / summe;
xyY[2] = XYZ[1];
return &xyY[0];
}
// Namen
std::string
renderingIntentName (int intent)
{
std::stringstream s;
switch (intent)
{
case 0:
s << _("Perceptual");
break;
case 1:
s << _("Relative Colorimetric");
break;
case 2:
s << _("Saturation");
break;
case 3:
s << _("Absolute Colorimetric");
break;
}
return s.str();
}
int
getColorSpaceChannels (icColorSpaceSignature color)
{
return oyICCColorSpaceGetChannelCount( color );
}
icColorSpaceSignature getColorSpaceGeneric( int channels )
{
icColorSpaceSignature cs = (icColorSpaceSignature)0;
switch (channels) {
case 2: return icSig2colorData; break;
case 3: return icSig3colorData; break;
case 4: return icSig4colorData; break;
case 5: return icSig5colorData; break;
case 6: return icSig6colorData; break;
case 7: return icSig7colorData; break;
case 8: return icSig8colorData; break;
case 9: return icSig9colorData; break;
case 10: return icSig10colorData; break;
case 11: return icSig11colorData; break;
case 12: return icSig12colorData; break;
case 13: return icSig13colorData; break;
case 14: return icSig14colorData; break;
case 15: return icSig15colorData; break;
default: break;
}
return cs;
}
std::string
getColorSpaceName (icColorSpaceSignature sig)
{
std::string text;
text = oyICCColorSpaceGetName( sig );
return text;
}
ICClist<std::string>
getChannelNamesShort (icColorSpaceSignature color)
{
ICClist<std::string> texte;
std::stringstream s;
# define nFARBEN(n) for (int i = 1; i <= n; i++) \
{ s << i; \
texte.push_back (s.str()); s.str(""); \
}
switch ((uint32_t)color) {
case icSigXYZData: texte.push_back ("X");
texte.push_back ("Y");
texte.push_back ("Z"); break;
case icSigLabData: texte.push_back ("*L");
texte.push_back ("*a");
texte.push_back ("*b"); break;
case icSigLuvData: texte.push_back ("*L");
texte.push_back ("*u");
texte.push_back ("*v"); break;
case icSigYCbCrData: texte.push_back ("Y");
texte.push_back ("b");
texte.push_back ("r"); break;
case icSigYxyData: texte.push_back ("Y");
texte.push_back ("x");
texte.push_back ("y"); break;
case icSigRgbData: texte.push_back ("R");
texte.push_back ("G");
texte.push_back ("B"); break;
case icSigGrayData: texte.push_back ("K"); break;
case icSigHsvData: texte.push_back ("H");
texte.push_back ("S");
texte.push_back ("V"); break;
case icSigHlsData: texte.push_back ("H");
texte.push_back ("L");
texte.push_back ("S"); break;
case icSigCmykData: texte.push_back ("C");
texte.push_back ("M");
texte.push_back ("Y");
texte.push_back ("K"); break;
case icSigCmyData: texte.push_back ("C");
texte.push_back ("M");
texte.push_back ("Y"); break;
// case icSigMCH2Data:
case icSig2colorData: nFARBEN(2) break;
// case icSigMCH3Data:
case icSig3colorData: nFARBEN(3) break;
// case icSigMCH4Data:
case icSig4colorData: nFARBEN(4) break;
case icSigMCH5Data:
case icSig5colorData: nFARBEN(5) break;
case icSigMCH6Data:
case icSig6colorData: nFARBEN(6) break;
case icSigMCH7Data:
case icSig7colorData: nFARBEN(7) break;
case icSigMCH8Data:
case icSig8colorData: nFARBEN(8) break;
case icSigMCH9Data:
case icSig9colorData: nFARBEN(9) break;
case icSigMCHAData:
case icSig10colorData: nFARBEN(10) break;
case icSigMCHBData:
case icSig11colorData: nFARBEN(11) break;
case icSigMCHCData:
case icSig12colorData: nFARBEN(12) break;
case icSigMCHDData:
case icSig13colorData: nFARBEN(13) break;
case icSigMCHEData:
case icSig14colorData: nFARBEN(14) break;
case icSigMCHFData:
case icSig15colorData: nFARBEN(15) break;
default: texte.push_back ("-"); break;
}
# undef nFARBEN
return texte;
}
ICClist<std::string>
getChannelNames (icColorSpaceSignature sig)
{
ICClist<std::string> texte;
std::stringstream s;
# define nFARBEN(n) for (int i = 0; i < n; i++) \
{ s << i << ". " << _("Colour"); \
texte.push_back (s.str()); s.str(""); \
}
switch (sig) {
case icSigXYZData: texte.push_back (_("CIE X"));
texte.push_back (_("CIE Y (Luminance)"));
texte.push_back (_("CIE Z")); break;
case icSigLabData: texte.push_back (_("CIE *L"));
texte.push_back (_("CIE *a"));
texte.push_back (_("CIE *b")); break;
case icSigLuvData: texte.push_back (_("CIE *L"));
texte.push_back (_("CIE *u"));
texte.push_back (_("CIE *v")); break;
case icSigYCbCrData: texte.push_back (_("Luminance Y"));
texte.push_back (_("Colour b"));
texte.push_back (_("Colour r")); break;
case icSigYxyData: texte.push_back (_("CIE Y (Luminance)"));
texte.push_back (_("CIE x"));
texte.push_back (_("CIE y")); break;
case icSigRgbData: texte.push_back (_("Red"));
texte.push_back (_("Green"));
texte.push_back (_("Blue")); break;
case icSigGrayData: texte.push_back (_("Black")); break;
case icSigHsvData: texte.push_back (_("Hue"));
texte.push_back (_("Saturation"));
texte.push_back (_("Value")); break;
case icSigHlsData: texte.push_back (_("Hue"));
texte.push_back (_("Lightness"));
texte.push_back (_("Saturation")); break;
case icSigCmykData: texte.push_back (_("Cyan"));
texte.push_back (_("Magenta"));
texte.push_back (_("Yellow"));
texte.push_back (_("Black")); break;
case icSigCmyData: texte.push_back (_("Cyan"));
texte.push_back (_("Magenta"));
texte.push_back (_("Yellow")); break;
case icSig2colorData: nFARBEN(2) break;
case icSig3colorData: nFARBEN(3) break;
case icSig4colorData: nFARBEN(4) break;
case icSig5colorData: nFARBEN(5) break;
case icSig6colorData: nFARBEN(6) break;
case icSig7colorData: nFARBEN(7) break;
case icSig8colorData: nFARBEN(8) break;
case icSig9colorData: nFARBEN(9) break;
case icSig10colorData: nFARBEN(10) break;
case icSig11colorData: nFARBEN(11) break;
case icSig12colorData: nFARBEN(12) break;
case icSig13colorData: nFARBEN(13) break;
case icSig14colorData: nFARBEN(14) break;
case icSig15colorData: nFARBEN(15) break;
default: texte.push_back (_("No Colour")); break;
}
# undef nFARBEN
return texte;
}
std::string
getDeviceClassName (icProfileClassSignature sig)
{
std::string text = oyICCDeviceClassDescription( sig );
#if 0
std::string text;
switch (deviceClass)
{
case icSigInputClass: text =_("Input"); break;
case icSigDisplayClass: text =_("Display"); break;
case icSigOutputClass: text =_("Output"); break;
case icSigLinkClass: text =_("Link"); break;
case icSigAbstractClass: text =_("Abstract"); break;
case icSigColorSpaceClass: text =_("Colour Space"); break;
case icSigNamedColorClass: text =_("Named Colour"); break;
default: { icUInt32Number i = icValue(deviceClass);
char t[5];
memcpy (t,(char*)&i, 4);
t[4] = 0;
text = t;
text += "?";
break;
}
}
#endif
return text;
}
std::string
getPlatformName (icPlatformSignature platform)
{
std::string text = oyICCPlatformDescription( platform );
#if 0
switch (platform)
{
case icSigMacintosh: text =_("Macintosh"); break;
case icSigMicrosoft: text =_("Microsoft"); break;
case icSigSolaris: text =_("Solaris"); break;
case icSigSGI: text =_("SGI"); break;
case icSigTaligent: text =_("Taligent"); break;
default: { icUInt32Number i = icValue(platform);
char t[5];
memcpy (t,(char*)&i, 4);
t[4] = 0;
text = t;
text += "?";
break;
}
}
#endif
return text;
}
std::string
getSigTagName ( icTagSignature sig )
{
std::string text = oyICCTagName( sig );
#if 0
switch (sig) {
case icSigAToB0Tag: text = "A2B0"; break;
case icSigAToB1Tag: text = "A2B1"; break;
case icSigAToB2Tag: text = "A2B2"; break;
case icSigBlueColorantTag: text = "bXYZ"; break;
case icSigBlueTRCTag: text = "bTRC"; break;
case icSigBToA0Tag: text = "B2A0"; break;
case icSigBToA1Tag: text = "B2A1"; break;
case icSigBToA2Tag: text = "B2A2"; break;
case icSigCalibrationDateTimeTag: text = "calt"; break;
case icSigCharTargetTag: text = "targ"; break;
case icSigCopyrightTag: text = "cprt"; break;
case icSigCrdInfoTag: text = "crdi"; break;
case icSigDeviceMfgDescTag: text = "dmnd"; break;
case icSigDeviceModelDescTag: text = "dmdd"; break;
case icSigGamutTag: text = "gamt"; break;
case icSigGrayTRCTag: text = "kTRC"; break;
case icSigGreenColorantTag: text = "gXYZ"; break;
case icSigGreenTRCTag: text = "gTRC"; break;
case icSigLuminanceTag: text = "lumi"; break;
case icSigMeasurementTag: text = "meas"; break;
case icSigMediaBlackPointTag: text = "bkpt"; break;
case icSigMediaWhitePointTag: text = "wtpt"; break;
case icSigNamedColorTag: text = "'ncol"; break;
case icSigNamedColor2Tag: text = "ncl2"; break;
case icSigPreview0Tag: text = "pre0"; break;
case icSigPreview1Tag: text = "pre1"; break;
case icSigPreview2Tag: text = "pre2"; break;
case icSigProfileDescriptionTag: text = "desc"; break;
case 1685283693: text = "dscm"; break;
case icSigProfileSequenceDescTag: text = "pseq"; break;
case icSigPs2CRD0Tag: text = "psd0"; break;
case icSigPs2CRD1Tag: text = "psd1"; break;
case icSigPs2CRD2Tag: text = "psd2"; break;
case icSigPs2CRD3Tag: text = "psd3"; break;
case icSigPs2CSATag: text = "ps2s"; break;
case icSigPs2RenderingIntentTag: text = "ps2i"; break;
case icSigRedColorantTag: text = "rXYZ"; break;
case icSigRedTRCTag: text = "rTRC"; break;
case icSigScreeningDescTag: text = "scrd"; break;
case icSigScreeningTag: text = "scrn"; break;
case icSigTechnologyTag: text = "tech"; break;
case icSigUcrBgTag: text = "bfd"; break;
case icSigViewingCondDescTag: text = "vued"; break;
case icSigViewingConditionsTag: text = "view"; break;
case 1147500100: text = "DevD"; break;
case 1128875332: text = "CIED"; break;
case 1349350514: text = "Pmtr"; break;
case 1986226036: text = "vcgt"; break;
case 1667785060: text = "chad"; break;
case icSigChromaticityType: text = "chrm"; break;
case 1668051567: text = "clro"; break;
case 1668051572: text = "clrt"; break;
case 0x62303135: text = "b015"; break; // binuscan targ data
case 0: text = "----"; break;
default: { icUInt32Number i = icValue(sig);
char t[5];
memcpy (t,(char*)&i, 4);
t[4] = 0;
text = t;
text += "?";
break;
}
}
#endif
# ifdef DEBUG_ICCTAG_
char c[5] = "clrt";
long* l = (long*) &c[0];
cout << *l << ": " << (long)"clrt" << " "; DBG_PROG
# endif
return text;
}
std::string
getSigTagDescription ( icTagSignature sig )
{
std::string text = oyICCTagDescription( sig );
#if 0
std::string text = _("Description");
switch (sig) {
case icSigAToB0Tag: text = _("Lookup table, device to PCS, intent photometric"); break;
case icSigAToB1Tag: text = _("Lookup table, device to PCS, intent relative colorimetric"); break;
case icSigAToB2Tag: text = _("Lookup table, device to PCS, intent saturation"); break;
case icSigBlueColorantTag: text = _("Blue Colorant"); break;
case icSigBlueTRCTag: text = _("Blue tone reproduction curve"); break;
case icSigBToA0Tag: text = _("Lookup table, PCS to device, intent photometric"); break;
case icSigBToA1Tag: text = _("Lookup table, PCS to device, intent relative colorimetric"); break;
case icSigBToA2Tag: text = _("Lookup table, PCS to device, intent saturation"); break;
case icSigCalibrationDateTimeTag: text = _("Calibration date"); break;
case icSigCharTargetTag: text = _("Colour measurement data"); break;
case icSigCopyrightTag: text = _("Copyright"); break;
case icSigCrdInfoTag: text = _("crdi"); break;
case icSigDeviceMfgDescTag: text = _("Device manufacturerer description"); break;
case icSigDeviceModelDescTag: text = _("Device model description"); break;
case icSigGamutTag: text = _("gamut"); break;
case icSigGrayTRCTag: text = _("Gray tone reproduction curve"); break;
case icSigGreenColorantTag: text = _("Green Colorant"); break;
case icSigGreenTRCTag: text = _("Green tone reproduction curve"); break;
case icSigLuminanceTag: text = _("Luminance"); break;
case icSigMeasurementTag: text = _("Measurement"); break;
case icSigMediaBlackPointTag: text = _("Media black point"); break;
case icSigMediaWhitePointTag: text = _("Media white point"); break;
case icSigNamedColorTag: text = _("Named Colour"); break;
case icSigNamedColor2Tag: text = _("Named Colour 2"); break;
case icSigPreview0Tag: text = _("Preview, photografic"); break;
case icSigPreview1Tag: text = _("Preview, relative colorimetric"); break;
case icSigPreview2Tag: text = _("Preview, saturated"); break;
case icSigProfileDescriptionTag: text = _("Profile description"); break;
case 1685283693: text = _("Profile description, multilingual"); break;//dscm
case icSigProfileSequenceDescTag: text = _("Profile sequence description"); break;
case icSigPs2CRD0Tag: text = _("psd0"); break;
case icSigPs2CRD1Tag: text = _("psd1"); break;
case icSigPs2CRD2Tag: text = _("psd2"); break;
case icSigPs2CRD3Tag: text = _("psd3"); break;
case icSigPs2CSATag: text = _("ps2s"); break;
case icSigPs2RenderingIntentTag: text = _("ps2i"); break;
case icSigRedColorantTag: text = _("Red Colorant"); break;
case icSigRedTRCTag: text = _("Red tone reproduction curve"); break;
case icSigScreeningDescTag: text = _("scrd"); break;
case icSigScreeningTag: text = _("scrn"); break;
case icSigTechnologyTag: text = _("Technologie"); break;
case icSigUcrBgTag: text = _("bfd"); break;
case icSigViewingCondDescTag: text = _("Viewing conditions description"); break;
case icSigViewingConditionsTag: text = _("Viewing Conditions"); break;
case 1147500100: text = _("Device colours"); break;//DevD
case 1128875332: text = _("Measured colours"); break;//CIED
case 1349350514: text = _("Profiling parameters"); break;//Pmtr
case 1986226036: text = _("VideoCardGammaTable"); break;//vcgt
case 1667785060: text = _("Colour adaption matrix"); break; //chad
case icSigChromaticityType: text = _("Chromaticity"); break; //chrm
case 1668051567: text = _("Named colour order"); break;//clro
case 1668051572: text = _("Named colour names"); break;//clrt
case 0: text = _("----"); break;
default: { icUInt32Number i = icValue(sig);
char t[5];
memcpy (t,(char*)&i, 4);
t[4] = 0;
text = t;
text += "?";
break;
}
}
#endif
return text;
}
std::string
getSigTypeName ( icTagTypeSignature sig )
{
std::string text = oyICCTagTypeName( sig );
#if 0
std::string text;
switch (sig) {
case icSigCurveType: text = "curv"; break;
case icSigDataType: text = "data"; break;
case icSigDateTimeType: text = "dtim"; break;
case icSigLut16Type: text = "mft2"; break;
case icSigLut8Type: text = "mft1"; break;
case icSigMeasurementType: text = "meas"; break;
case icSigNamedColorType: text = "ncol"; break;
case icSigProfileSequenceDescType: text = "pseq"; break;
case icSigS15Fixed16ArrayType: text = "sf32"; break;
case icSigScreeningType: text = "scrn"; break;
case icSigSignatureType: text = "sig"; break;
case icSigTextType: text = "text"; break;
case icSigTextDescriptionType: text = "desc"; break;
case icSigU16Fixed16ArrayType: text = "uf32"; break;
case icSigUcrBgType: text = "bfd"; break;
case icSigUInt16ArrayType: text = "ui16"; break;
case icSigUInt32ArrayType: text = "ui32"; break;
case icSigUInt64ArrayType: text = "ui64"; break;
case icSigUInt8ArrayType: text = "ui08"; break;
case icSigViewingConditionsType: text = "view"; break;
case icSigXYZType: text = "XYZ"; break;
//case icSigXYZArrayType: text = "XYZ"; break;
case icSigNamedColor2Type: text = "ncl2"; break;
case icSigCrdInfoType: text = "crdi"; break;
case icSigChromaticityType: text = "chrm"; break;
case 1986226036: text = "vcgt"; break;
case icSigCopyrightTag: text = "cprt?"; break; //??? (Imacon)
case 1835824483: text = "mluc"; break;
default: { icUInt32Number i = icValue(sig);
char t[5];
memcpy (t,(char*)&i, 4);
t[4] = 0;
text = t;
text += "?";
break;
}
}
#endif
return text;
}
std::string
getSigTechnology ( icTechnologySignature sig )
{
std::string text = oyICCTechnologyDescription( sig );
#if 0
std::string text;
switch (sig) {
case icSigDigitalCamera: text = _("Digital camera"); break; //dcam
case icSigFilmScanner: text = _("Film scanner"); break; //fscn
case icSigReflectiveScanner: text = _("Reflective scanner"); break; //rscn
case icSigInkJetPrinter: text = _("InkJet printer"); break; //ijet
case icSigThermalWaxPrinter: text = _("Thermal wax printer"); break; //twax
case icSigElectrophotographicPrinter: text = _("Electrophotographic printer"); break; //epho
case icSigElectrostaticPrinter: text = _("Electrostatic printer"); break; //esta
case icSigDyeSublimationPrinter: text = _("Dye sublimation printer"); break; //dsub
case icSigPhotographicPaperPrinter: text = _("Photographic paper printer"); break; //rpho
case icSigFilmWriter: text = _("Film writer"); break; //fprn
case icSigVideoMonitor: text = _("Video Monitor"); break; //vidm
case icSigVideoCamera: text = _("Video camera"); break; //vidc
case icSigProjectionTelevision: text = _("Projection Television"); break; //pjtv
case icSigCRTDisplay: text = _("Cathode ray tube display"); break; //CRT
case icSigPMDisplay: text = _("Passive matrix monitor"); break; //PMD
case icSigAMDisplay: text = _("Active matrix monitor"); break; //AMD
case icSigPhotoCD: text = _("Photo CD"); break; //KPCD
case icSigPhotoImageSetter: text = _("PhotoImageSetter"); break; //imgs
case icSigGravure: text = _("Gravure"); break; //grav
case icSigOffsetLithography: text = _("Offset Lithography"); break; //offs
case icSigSilkscreen: text = _("Silkscreen"); break; //silk
case icSigFlexography: text = _("Flexography"); break; //flex
case icMaxEnumTechnology: text = _("----"); break;
default: { icUInt32Number i = icValue(sig);
char t[5];
memcpy (t,(char*)&i, 4);
t[4] = 0;
text = t;
text += "?";
break;
}
}
#endif
return text;
}
std::string
getChromaticityColorantType( int sig )
{
std::string text = oyICCChromaticityColorantDescription( sig );
#if 0
std::string text;
switch (type) {
case 0: text = ""; break;
case 1: text = _("ITU-R BT.709"); break;
case 2: text = _("SMPTE RP145-1994"); break;
case 3: text = _("EBU Tech.3213-E"); break;
case 4: text = _("P22"); break;
default: DBG text = _("???"); break;
}
#endif
return text;
}
std::string
getIlluminant ( icIlluminant sig )
{
std::string text = oyICCIlluminantDescription( sig );
#if 0
std::string text;
switch (sig) {
case icIlluminantUnknown: text = _("Illuminant unknown"); break;
case icIlluminantD50: text = _("Illuminant D50"); break;
case icIlluminantD65: text = _("Illuminant D65"); break;
case icIlluminantD93: text = _("Illuminant D93"); break;
case icIlluminantF2: text = _("Illuminant F2"); break;
case icIlluminantD55: text = _("Illuminant D55"); break;
case icIlluminantA: text = _("Illuminant A"); break;
case icIlluminantEquiPowerE: text = _("Illuminant with equal energy E"); break;
case icIlluminantF8: text = _("Illuminant F8"); break;
case icMaxEnumIluminant: text = _("Illuminant ---"); break;
default: text = _("???"); break;
}
#endif
return text;
}
std::string
getStandardObserver ( icStandardObserver sig )
{
std::string text = oyICCStandardObserverDescription( sig );
#if 0
std::string text;
switch (sig) {
case icStdObsUnknown: text = _("unknown"); break;
case icStdObs1931TwoDegrees: text = _("2 degree (1931)");
break;
case icStdObs1964TenDegrees: text = _("10 degree (1964)");
break;
case icMaxStdObs: text = _("---"); break;
default: text = _("???"); break;
}
#endif
return text;
}
std::string
getMeasurementGeometry ( icMeasurementGeometry sig )
{
std::string text = oyICCMeasurementGeometryDescription( sig );
#if 0
std::string text;
switch (sig) {
case icGeometryUnknown: text = _("unknown"); break;
case icGeometry045or450: text = _("0/45, 45/0"); break;
case icGeometry0dord0: text = _("0/d or d/0"); break;
case icMaxGeometry: text = _("---"); break;
default: text = _("???"); break;
}
#endif
return text;
}
std::string
getMeasurementFlare ( icMeasurementFlare sig )
{
std::string text = oyICCMeasurementFlareDescription( sig );
#if 0
std::string text;
switch (sig) {
case icFlare0: text = _("0"); break;
case icFlare100: text = _("100"); break;
case icMaxFlare: text = _("---"); break;
default: text = _("???"); break;
}
#endif
return text;
}
std::string
printDatum (icDateTimeNumber date)
{ DBG_PROG
std::stringstream s;
s <<
icValue(date.day) << "/" <<
icValue(date.month) << "/" <<
icValue(date.year) << " " <<
icValue(date.hours) << ":";
if (icValue(date.minutes) < 10)
s << "0";
s << icValue(date.minutes) << " " << _("o'clock") << " " <<
icValue(date.seconds) << " " << _("seconds");
return s.str();
}
const char* cp_nchar (char* text, int n)
{ DBG_MEM_START
static char string[1024];
/* for (int i = 0; i < 1024 ; i++)
string[i] = '\000';*/
memset( string, 0, 1024 );
if (n < 1024)
{
# if 0
memcpy (string, text, n);
# else
memcpy(&string[0], text, n);
# endif
string[n] = '\000';
}
# ifdef DEBUG
DBG_MEM_V( n << " letters copy " << (intptr_t)text << " " << string)
# endif
DBG_MEM_ENDE
return string;
}
void
oyStrAdd( std::string & text, const char * add )
{
char * ptr = (char*)malloc( strlen(text.c_str()) + strlen(add) + 64 );
sprintf( ptr, "%s%s", text.c_str(), add );
text = ptr;
free( ptr );
}
namespace icc_examin_ns {
# if defined(__GNUC__) || defined(LINUX) || defined(__APPLE__) || defined(SOLARIS)
# include <sys/time.h>
# define ZEIT_TEILER 10000
# else // WINDOWS TODO
# define ZEIT_TEILER CLOCKS_PER_SEC;
# endif
#ifndef WIN32
# include <unistd.h>
#endif
#include <time.h>
#include <math.h>
double zeitSekunden()
{
time_t zeit_ = zeit();
double teiler = ZEIT_TEILER;
double dzeit = zeit_ / teiler;
return dzeit;
}
time_t zeit()
{
time_t zeit_;
double teiler = ZEIT_TEILER;
# if defined(__GNUC__) || defined(__APPLE__) || defined(SOLARIS) || defined(BSD)
struct timeval tv;
gettimeofday( &tv, NULL );
double tmp_d;
zeit_ = tv.tv_usec/(1000000/(time_t)teiler)
+ (time_t)(modf( (double)tv.tv_sec / teiler,&tmp_d )
* teiler*teiler);
//DBG_THREAD_V( modf(tv.tv_sec/teiler,&tmp_d)*teiler*teiler<<","<<
// tv.tv_usec/(1000000/teiler) )
# else // WINDOWS TODO
zeit_ = clock();
# endif
return zeit_;
}
time_t zeitProSekunde()
{
return ZEIT_TEILER;
}
void sleep(double sekunden)
{
# if defined(__GCC__) || defined(__APPLE__)
timespec ts;
double ganz;
double rest = modf(sekunden, &ganz);
ts.tv_sec = (time_t)ganz;
ts.tv_nsec = (time_t)(rest * 1000000000);
//DBG_PROG_V( sekunden<<" "<<ts.tv_sec<<" "<<ganz<<" "<<rest )
nanosleep(&ts, 0);
# else
# if defined( WIN32 )
Sleep((DWORD)(sekunden*(double)CLOCKS_PER_SEC));
# else
usleep((time_t)(sekunden*(double)CLOCKS_PER_SEC));
# endif
# endif
}
void wait(double sekunden, int aktualisieren)
{
icc_examin_ns::sleep(sekunden);
if(aktualisieren && waitFunc)
waitFunc();
}
}
std::string zeig_bits_bin ( const void * mem,
int size,
int type)
{
std::string text;
int byte_zahl;
char txt[12];
//@todo TODO: ->hexadezimal
switch(type)
{
case oyFORMAT_BIN:
for (int k = 0; k < size; k++)
{
for (int i = 8-1; i >= 0; i--)
{
unsigned char* u8 = (unsigned char*)mem;
byte_zahl = (u8[k] >> i) & 1;
sprintf (&txt[7-i], "%d", byte_zahl);
}
text.append( txt, strlen (txt));
text.append( " ", 1); /* aller 8 bit ein leerzeichen */
}
break;
case oyFORMAT_HEX:
for (int k = 0; k < size; k++)
{