-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathicc_oyranos_extern.c
876 lines (756 loc) · 22.3 KB
/
icc_oyranos_extern.c
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
/*
* ICC Examin ist eine ICC Profil Betrachter
*
* Copyright (C) 2004-2007 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.
*
* -----------------------------------------------------------------------------
*
* Der CMS Sortierer.
*
*/
/* Date: 25. 11. 2004 */
int icc_not_used_dummy = 0;
#if 0
#include "icc_oyranos_extern.h"
#include "oyranos_helper.h"
void* myCAllocFunc(size_t size)
{
return calloc( sizeof(char), size );
}
void myCDeAllocFunc(void * buf)
{
if(buf)
free(buf);
}
/** @brief number of channels in a colour space
*
* since: (ICC Examin: version 0.45)
*/
int
oyColourSpaceGetChannelCountFromSig ( icColorSpaceSignature color )
{
int n;
switch (color) {
case icSigXYZData: n = 3; break;
case icSigLabData: n = 3; break;
case icSigLuvData: n = 3; break;
case icSigYCbCrData: n = 3; break;
case icSigYxyData: n = 3; break;
case icSigRgbData: n = 3; break;
case icSigGrayData: n = 1; break;
case icSigHsvData: n = 3; break;
case icSigHlsData: n = 3; break;
case icSigCmykData: n = 4; break;
case icSigCmyData: n = 3; break;
case icSig2colorData: n = 2; break;
case icSig3colorData: n = 3; break;
case icSig4colorData: n = 4; break;
case icSig5colorData:
case icSigMCH5Data:
n = 5; break;
case icSig6colorData:
case icSigMCH6Data:
n = 6; break;
case icSig7colorData:
case icSigMCH7Data:
n = 7; break;
case icSig8colorData:
case icSigMCH8Data:
n = 8; break;
case icSig9colorData:
case icSigMCH9Data:
n = 9; break;
case icSig10colorData:
case icSigMCHAData:
n = 10; break;
case icSig11colorData:
case icSigMCHBData:
n = 11; break;
case icSig12colorData:
case icSigMCHCData:
n = 12; break;
case icSig13colorData:
case icSigMCHDData:
n = 13; break;
case icSig14colorData:
case icSigMCHEData:
n = 14; break;
case icSig15colorData:
case icSigMCHFData:
n = 15; break;
default: n = 0; break;
}
return n;
}
/** @brief number of channels in a colour space
*
* since: (ICC Examin: version 0.45)
*/
int
oyColourSpaceGetChannelCount( oyColourProfile_s * ref )
{
icColorSpaceSignature sig = oyProfileGetSignature ( ref );
return oyColourSpaceGetChannelCountFromSig( sig );
}
/** @brief name of a colour space
*
* since: (ICC Examin: version 0.45)
*/
const char *
oyColourSpaceGetNameFromSig( icColorSpaceSignature sig )
{
const char * text;
switch (sig) {
case icSigXYZData: text =_("XYZ"); break;
case icSigLabData: text =_("Lab"); break;
case icSigLuvData: text =_("Luv"); break;
case icSigYCbCrData: text =_("YCbCr"); break;
case icSigYxyData: text =_("Yxy"); break;
case icSigRgbData: text =_("Rgb"); break;
case icSigGrayData: text =_("Gray"); break;
case icSigHsvData: text =_("Hsv"); break;
case icSigHlsData: text =_("Hls"); break;
case icSigCmykData: text =_("Cmyk"); break;
case icSigCmyData: text =_("Cmy"); break;
case icSig2colorData: text =_("2color"); break;
case icSig3colorData: text =_("3color"); break;
case icSig4colorData: text =_("4color"); break;
case icSigMCH5Data:
case icSig5colorData: text =_("5color"); break;
case icSigMCH6Data:
case icSig6colorData: text =_("6color"); break;
case icSigMCH7Data:
case icSig7colorData: text =_("7color"); break;
case icSigMCH8Data:
case icSig8colorData: text =_("8color"); break;
case icSigMCH9Data:
case icSig9colorData: text =_("9color"); break;
case icSigMCHAData:
case icSig10colorData: text =_("10color"); break;
case icSigMCHBData:
case icSig11colorData: text =_("11color"); break;
case icSigMCHCData:
case icSig12colorData: text =_("12color"); break;
case icSigMCHDData:
case icSig13colorData: text =_("13color"); break;
case icSigMCHEData:
case icSig14colorData: text =_("14color"); break;
case icSigMCHFData:
case icSig15colorData: text =_("15color"); break;
default: { icUInt32Number i = oyValueCSpaceSig(sig);
char t[8];
memcpy (t,(char*)&i, 4);
t[4] = '?';
t[5] = 0;
text = &t[0];
break;
}
}
return text;
}
/** @brief name of a colour space
*
* since: (ICC Examin: version 0.45)
*/
const char *
oyColourSpaceGetName( oyColourProfile_s * ref )
{
icColorSpaceSignature sig = oyProfileGetSignature ( ref );
return oyColourSpaceGetNameFromSig( sig );
}
/** @brief copy pure colours
handle colour only, without from set to -1 default
*
* since: (ICC Examin: version 0.45)
*/
void
oyCopyColour ( const double * from,
double * to,
int n,
oyColourProfile_s * ref,
int channels_n )
{
int i, j;
icColorSpaceSignature sig = oyProfileGetSignature ( ref );
int c = oyColourSpaceGetChannelCountFromSig( sig );
if(!n || !to)
return;
if(from)
memcpy( to, from, sizeof(double) * n * c );
else
{
if(!channels_n && c)
channels_n = c;
else if(channels_n && !c)
c = channels_n;
if(channels_n)
switch(sig)
{
case icSigLabData:
case icSigLuvData:
case icSigHsvData:
case icSigHlsData:
case icSigYCbCrData:
for( i = 0; i < n; ++i )
{
to[i*channels_n+0] = -1;
to[i*channels_n+1] = 0;
to[i*channels_n+2] = 0;
for( j = c; j < channels_n; ++j )
if(j==c)
to[i*channels_n+j] = 1; /* set alpha */
else
to[i*channels_n+j] = 0;
}
break;
case icSigRgbData:
default:
for( i = 0; i < n; ++i )
{
for( j = 0; j < channels_n; ++j )
if(j < c)
to[i*channels_n+j] = -1;
else if(j==c)
to[i*channels_n+j] = 1; /* set alpha */
else
to[i*channels_n+j] = 0;
}
break;
}
}
}
/* Has to go to oyranos_texts.x */
char*
oyStringCopy_ ( const char * text,
oyAllocFunc_t allocateFunc )
{
char * text_copy = NULL;
if(text)
if( oyStrlen_(text) )
{
text_copy = allocateFunc(strlen(text) + 1);
oyAllocHelper_m_( text_copy, oyString, oyStrlen_(text) + 1,
allocateFunc, return 0 );
sprintf( text_copy, "%s", text );
}
return text_copy;
}
oyObject_s * oyObjectSetNames ( oyObject_s * object,
const char * nick,
const char * name,
const char * description )
{
if(!object) return 0;
if(nick || name || description)
{
if(!object->names)
{
oyAllocHelper_m_( object->names, oyNames_s_, 1, object->allocateFunc,
return 0 )
memset(object->names, 0, sizeof(oyNames_s_));
}
#define oySetString_(n_type)\
if(n_type) \
{ \
if(object->names->n_type && object->deallocateFunc) \
object->deallocateFunc( object->names->n_type ); \
oyAllocHelper_m_( object->names->n_type, oyString, sizeof(oyString) \
* (oyStrlen_(n_type) + 1) \
object->allocateFunc, return 0); \
oyStrcpy_( object->names->n_type, n_type ); \
}
oySetString_(nick)
oySetString_(name)
oySetString_(description)
#undef oySetString_
}
return object;
}
/** @brief object memory managers */
oyObject_s * oyObjectSetAllocators ( oyObject_s * object,
oyAllocFunc_t allocateFunc,
oyDeAllocFunc_t deallocateFunc )
{
if(!object) return 0;
/* we require a allocation function to be present */
if(allocateFunc)
object->allocateFunc = allocateFunc;
else
object->allocateFunc = myCAllocFunc;
object->deallocateFunc = deallocateFunc;
return object;
}
/** @brief object management */
oyObject_s *
oyObjectCopy_( oyObject_s * object,
oyOBJECT_TYPE_e type )
{
oyObject_s * o = 0;
if(object && object->allocateFunc) {
o = object->allocateFunc(sizeof(oyObject_s));
if(!o) return 0;
memset( o, 0, sizeof(oyObject_s) );
o = oyObjectSetAllocators( o, object->allocateFunc, object->deallocateFunc);
} else {
o = myCAllocFunc(sizeof(oyObject_s));
if(!o) return 0;
memset( o, 0, sizeof(oyObject_s) );
o = oyObjectSetAllocators( o, myCAllocFunc, myCDeAllocFunc );
}
if(object && object->names)
o = oyObjectSetNames( o, object->names->nick, object->names->name,
object->names->description );
if(type)
o->type = type;
o->version = oyVersion(0);
o->ref++;
return o;
}
/** @brief manage complex oyNamedColour_s inside Oyranos
*
* since: (ICC Examin: version 0.45)
*
* @param[in] chan pointer to channel data with a number of elements specified in sig or channels_n
* @param[in] sig ICC colour space signature http://www.color.org
* @param[in] channels_n elements of channels including alpha ...
* @param[in] names_chan needed if sig provides no glue about the channel colour or you use more than one extra (non colour) channel. The first deteted extra channel is by default considered alpha.
* @param[in] name of the colour
* @param[in] name_long description
* @param[in] nick_name very short, only a few letters
* @param[in] blob CGATS or other reference data
* @param[in] blob_len length of the data blob
* @param[in] ref_file possibly a ICC profile, allowed abreviations are 'sRGB' 'XYZ' 'Lab'(D50)
* @param[in] allocateFunc user controled memory allocation
* @param[in] deallocateFunc user controled memory deallocation
*
*/
oyNamedColour_s*
oyNamedColourCreate ( oyObject_s * object,
const double * chan,
int channels_n,
const char * blob,
int blob_len,
oyColourProfile_s * profile_ref)
{
oyNamedColour_s * colour = (oyNamedColour_s*)object->allocateFunc(sizeof(oyNamedColour_s));
if(!colour)
{
WARN_S("MEM Error.")
return NULL;
}
memset( colour, 0, sizeof(oyNamedColour_s) );
colour->objects = oyObjectCopy_( object, oyOBJECT_TYPE_NAMED_COLOUR_S );
colour->objects->type = oyOBJECT_TYPE_NAMED_COLOUR_S;
if(deallocateFunc)
colour->deallocateFunc = deallocateFunc;
else
colour->deallocateFunc = myCDeAllocFunc;
if(allocateFunc)
colour->allocateFunc = allocateFunc;
else
colour->allocateFunc = myCAllocFunc;
if(channels_n)
colour->channels_n = channels_n;
else if(ref)
colour->channels_n = oyColourSpaceGetChannelCount( ref ) + 1;
else
colour->channels_n = 0;
if(colour->channels_n)
colour->channels = colour->allocateFunc( colour->channels_n );
oyCopyColour( chan, &colour->channels[0], 1, ref, colour->channels_n );
colour->name = oyStringCopy_( name, colour->allocateFunc );
colour->name_long = oyStringCopy_( name_long, colour->allocateFunc );
colour->nick_name = oyStringCopy_( nick_name, colour->allocateFunc );
colour->profile = oyProfileCopy( ref, colour->allocateFunc, colour->deallocateFunc );
if(blob && blob_len)
{
colour->blob = colour->allocateFunc( blob_len );
memcpy( colour->blob, blob, blob_len );
}
return colour;
}
/** @brief set channel names
*
* The function should be used to specify extra channels or unusual colour
* layouts like CMYKRB. The number of elements in names_chan should fit to the
* channels count or to the colour space signature.
*
* You can let single entries empty if they are understandable by the
* colour space signature. Oyranos will set them for you on request.
*
* @param[in] colour address of a Oyranos named colour structure
* @param[in] names pointer to channel names
*
* since: (ICC Examin: version 0.45)
*/
void
oyNamedColourSetChannelNames ( oyNamedColour_s * colour,
const char ** names_chan )
{
oyNamedColour_s * c = colour;
if(names_chan && c->channels_n)
{
int i = 0;
c->names_chan = c->allocateFunc( (c->channels_n + 1 ) * sizeof(char*) );
c->names_chan[ c->channels_n ] = NULL;
for( ; i < c->channels_n; ++i )
{
int len = 0;
if(names_chan[i])
len = strlen(names_chan[i]);
if(len)
{
c->names_chan[i] = c->allocateFunc((len + 1 ) * sizeof(char));
sprintf( c->names_chan[i], "%s", names_chan[i] );
}
}
}
}
/** @brief copy
*
*
*
* @param[in] colour address of Oyranos colour struct
* @return copy
*
* since: (ICC Examin: version 0.45)
*/
oyNamedColour_s*
oyNamedColourCopy ( const oyNamedColour_s * colour,
oyAllocFunc_t allocateFunc,
oyDeAllocFunc_t deallocateFunc )
{
oyNamedColour_s * c = NULL;
if(!colour)
return c;
c = oyNamedColourCreate( colour->channels,
colour->channels_n,
colour->name,
colour->name_long,
colour->nick_name,
colour->blob,
colour->blob_len,
colour->profile,
allocateFunc ? allocateFunc : colour->allocateFunc,
deallocateFunc ? deallocateFunc : colour->deallocateFunc );
oyNamedColourSetChannelNames( c, (const char**)colour->names_chan );
return c;
}
/* @return pointer to D50 Lab doubles with L 0.0...1.0 a/b -1.27...1.27 */
int
oyNamedColourSetSpace ( oyNamedColour_s * colour,
oyColourProfile_s * profile )
{
WARN_S("not implemented");
return 1;
}
int
oyNamedColourConvert ( oyNamedColour_s * colour,
oyColourProfile_s * profile,
oyPointer buf,
oyDATATYPE_e buf_type )
{
oyImage_s * in = NULL,
* out = NULL;
oyColourConversion_s * conv = NULL;
int ret = 0;
in = oyImageCreate( 1,1,
(oyPointer) colour->channels ,oyDOUBLE,
colour->profile,
0,0 );
out = oyImageCreate( 1,1,
buf ,buf_type,
profile,
0,0 );
conv = oyColourConversionCreate( 0,0,0, in,out );
ret = oyColourConversionRun( conv );
conv = oyRelease( conv );
return ret;
}
int
oyNamedColourConvertStd(oyNamedColour_s * colour,
const char * colour_space_name,
oyPointer buf,
oyDATATYPE_e buf_type )
{
int ret = 0;
oyColourProfile_s * profile;
if(!colour)
return 1;
if(!colour_space_name)
return 1;
profile = oyProfileCreate ( 0, colour_space_name, 0,NULL );
ret = oyNamedColourConvert ( colour, profile, buf, buf_type );
profile = oyRelease ( profile );
return ret;
}
/** @brief get colour channels
*
*
* @param[in] colour Oyranos colour struct pointer
* @return pointer channels
*
* since: (ICC Examin: version 0.45)
*/
const double*
oyNamedColourGetChannelsConst ( oyNamedColour_s * colour )
{
static double l[3] = {-1.f,-1.f,-1.f};
if(colour)
return colour->channels;
else
return l;
}
/** @brief set colour channels
*
*
* @param[in] colour Oyranos colour struct pointer
* @param[in] channels pointer to channel data
*
* since: (ICC Examin: version 0.45)
*/
void
oyNamedColourSetChannels ( oyNamedColour_s * colour,
const double * channels )
{
int i;
if(!colour)
return;
if(channels)
for(i = 0; i < colour->channels_n; ++i)
colour->channels[i] = channels[i];
}
/** @brief get associated colour name
*
*
* @param[in] Oyranos colour struct pointer
*
* since: (ICC Examin: version 0.45)
*/
const char *
oyNamedColourGetName( oyNamedColour_s * colour )
{
double lab[3];
oyColourProfile_s * profile;
if(!colour)
return NULL;
if(colour->name)
return colour->name;
profile = oyProfileCreate ( icSigLabData, NULL, 0,NULL );
profile = oyRelease ( profile );
profile = oyProfileCreate ( 0, "Lab", 0,NULL );
oyNamedColourConvert ( colour, profile, (oyPointer)lab, oyDOUBLE );
profile = oyRelease ( profile );
colour->name = (char*) colour->allocateFunc(80);
snprintf( colour->name, 80, "%s%sLab: %.02f %.02f %.02f",
colour->nick_name ? colour->nick_name : "",
colour->nick_name ? " - " : "",
lab[0], lab[1], lab[2]
);
return colour->name;
}
/** @brief get associated colour nick name
*
*
* @param[in] Oyranos colour struct pointer
*
* since: (ICC Examin: version 0.45)
*/
const char *
oyNamedColourGetNick( oyNamedColour_s * colour )
{
if(!colour)
return NULL;
return colour->nick_name;
}
/** @brief get associated colour description
*
*
* @param[in] Oyranos colour struct pointer
*
* since: (ICC Examin: version 0.45)
*/
const char *
oyNamedColourGetDescription( oyNamedColour_s * colour )
{
int c, i;
char* tmp;
if(!colour)
return NULL;
if(colour->name_long)
return colour->name_long;
c = oyColourSpaceGetChannelCount( colour->profile );
tmp = oyStringCopy_( oyNamedColourGetName( colour ), colour->allocateFunc );
colour->name_long = (char*) colour->allocateFunc(80);
sprintf(colour->name_long, "%s", tmp);
if(colour->profile)
{
int len = strlen(colour->name_long);
snprintf(&colour->name_long[len], 80-len, " %s:",
oyColourSpaceGetName( colour->profile ) );
for(i=0; i < c && c < 32; ++i)
{
len = strlen(colour->name_long);
snprintf(&colour->name_long[len], 80-len, " %.02f", colour->channels[i]);
}
len = strlen(colour->name_long);
/*snprintf(&colour->name_long[len], 80-len, "");*/
}
return colour->name_long;
}
/** @brief release correctly
*
* set pointer to zero
* should walk to a general oyFree(void* oy_struct) function
*
* @param[in] address of Oyranos colour struct pointer
*
* since: (ICC Examin: version 0.45)
*/
oyNamedColour_s*
oyNamedColourRelease( oyNamedColour_s * colour )
{
oyNamedColour_s * c;
int i;
/* TODO */
if(!colour || !*colour)
return;
c = *colour;
if( c->type != oyOBJECT_TYPE_NAMED_COLOUR_S)
return;
c->type = oyOBJECT_TYPE_NONE;
for(i = 0; i < 32; ++i)
if(c->names_chan[i])
c->deallocateFunc( c->names_chan[i] );
if(c->name)
c->deallocateFunc( c->name );
if(c->name_long)
c->deallocateFunc( c->name_long );
if(c->nick_name)
c->deallocateFunc( c->nick_name );
if(c->blob) /* c->bloblen */
c->deallocateFunc( c->blob );
c->profile = oyRelease( c->profile );
c->deallocateFunc( c );
*colour = NULL;
}
/** @brief MSB<->LSB */
icUInt16Number
oyValueUInt16 (icUInt16Number val)
{
#if BYTE_ORDER == LITTLE_ENDIAN
# define BYTES 2
# define KORB 4
unsigned char *temp = (unsigned char*) &val;
static unsigned char korb[KORB];
int i;
for (i = 0; i < KORB ; i++ )
korb[i] = (int) 0; /* empty */
{
int klein = 0,
gross = BYTES - 1;
for (; klein < BYTES ; klein++ ) {
korb[klein] = temp[gross--];
# ifdef DEBUG_ICCFUNKT
cout << klein << " "; DBG_PROG
# endif
}
}
{
unsigned int *erg = (unsigned int*) &korb[0];
# ifdef DEBUG_ICCFUNKT
# if 0
cout << *erg << " Groesse nach Wandlung " << (int)korb[0] << " "
<< (int)korb[1] << " " << (int)korb[2] << " " <<(int)korb[3]
<< " "; DBG_PROG
# else
cout << *erg << " size after conversion " << (int)temp[0] << " " << (int)temp[1]
<< " "; DBG_PROG
# endif
# endif
# undef BYTES
# undef KORB
return (long)*erg;
}
#else
return (long)val;
#endif
}
icUInt32Number
oyValueUInt32 (icUInt32Number val)
{
#if BYTE_ORDER == LITTLE_ENDIAN
unsigned char *temp = (unsigned char*) &val;
static unsigned char uint32[4];
uint32[0] = temp[3];
uint32[1] = temp[2];
uint32[2] = temp[1];
uint32[3] = temp[0];
{
unsigned int *erg = (unsigned int*) &uint32[0];
# ifdef DEBUG_ICCFUNKT
cout << *erg << " size after conversion " << (int)temp[0] << " "
<< (int)temp[1] << " " << (int)temp[2] << " " <<(int)temp[3]
<< " "; DBG_PROG
# endif
return (icUInt32Number) *erg;
}
#else
# ifdef DEBUG_ICCFUNKT
cout << "BIG_ENDIAN" << " "; DBG_PROG
# endif
return (icUInt32Number)val;
#endif
}
unsigned long
oyValueUInt64 (icUInt64Number val)
{
#if BYTE_ORDER == LITTLE_ENDIAN
unsigned char *temp = (unsigned char*) &val;
static unsigned char uint64[8];
int little = 0,
big = 8;
for (; little < 8 ; little++ ) {
uint64[little] = temp[big--];
}
{
unsigned long *erg = (unsigned long*) &uint64[0];
# ifdef DEBUG_ICCFUNKT
cout << *erg << " size after conversion " << (int)temp[0] << " "
<< (int)temp[1] << " " << (int)temp[2] << " " <<(int)temp[3]
<< " "; DBG_PROG
# endif
return (long)*erg;
}
#else
return (long)val;
#endif
}
#define icValue_to_icUInt32Number(funkname, typ) \
typ \
funkname (typ val) \
{ \
icUInt32Number i = (typ) val; \
return (typ) oyValueUInt32 (i); \
}
icValue_to_icUInt32Number( oyValueCSpaceSig, icColorSpaceSignature )
icValue_to_icUInt32Number( oyValuePlatSig, icPlatformSignature )
icValue_to_icUInt32Number( oyValueProfCSig, icProfileClassSignature )
icValue_to_icUInt32Number( oyValueTagSig, icTagSignature )
#endif