IccMAX 2.1.27
Color Profile Tools
Loading...
Searching...
No Matches
RefIccMAXCmm.cpp File Reference
#include <ApplicationServices/ApplicationServices.h>
#include <math.h>
#include <pthread.h>
#include "IccProfile.h"
#include "IccCmm.h"
+ Include dependency graph for RefIccMAXCmm.cpp:

Go to the source code of this file.

Data Structures

struct  CMMMatchRec
 
struct  CMMStorageRec
 
struct  sMemBlock
 

Macros

#define DoubToFract(x)   (((x)<=0.0)?(0):(((x)>=2.0)?(65535):((x)*32768.0 + 0.5)))
 
#define DoubToUInt16(x)   (((x)<=0.0)?(0):(((x)>=1.0)?(65535):((x)*65535.0 + 0.5)))
 
#define FractToDoub(x)   ((double)(x)/32768.0)
 
#define FractToUInt16(x)   ((x)<<1)
 
#define kCMMSTORAGE   CFSTR("com.acme.DemoCMM")
 
#define UInt16ToDoub(x)   ((double)(x)/65535.0)
 
#define UInt16ToFract(x)   ((x)>>1)
 

Typedefs

typedef struct CMMStorageRecCMMStoragePtr
 
typedef void(* MatchOneProc) (UInt16 *chan)
 

Functions

CMError CMM_CheckBitmap (CMWorldRef cw, const CMBitmap *srcMap, CMBitmapCallBackUPP progressProc, void *refCon, CMBitmap *chkMap)
 
CMError CMM_CheckColors (CMWorldRef cw, CMColor *myColors, UInt32 count, UInt8 *result)
 
CMError CMM_ConcatColorWorld (CMWorldRef cw, NCMConcatProfileSet *profileSet, CMConcatCallBackUPP proc, void *refCon)
 
CMError CMM_MatchBitmap (CMWorldRef cw, CMBitmap *srcMap, CMBitmapCallBackUPP progressProc, void *refCon, CMBitmap *dstMap)
 
CMError CMM_MatchColors (CMWorldRef cw, CMColor *myColors, UInt32 count)
 
static void * cmmallocate (CFIndex size, CFOptionFlags hint, void *info)
 
static CFAllocatorRef CMMBytesDeallocator ()
 
CMError CMMCheckBitmap (uintptr_t *cmmRefcon, const CMBitmap *srcMap, CMBitmapCallBackUPP progressProc, void *refCon, CMBitmap *chkMap)
 
CMError CMMCheckColors (uintptr_t *cmmRefcon, CMColor *colorBuf, UInt32 count, UInt8 *gamutResult)
 
CMError CMMClose (uintptr_t *cmmRefcon)
 
CMError CMMConcatInit (uintptr_t *cmmRefcon, CMConcatProfileSet *profileSet)
 
static void cmmdeallocate (void *ptr, void *info)
 
CMError CMMMatchBitmap (uintptr_t *cmmRefcon, CMBitmap *srcMap, CMBitmapCallBackUPP progressProc, void *refCon, CMBitmap *dstMap)
 
CMError CMMMatchColors (uintptr_t *cmmRefcon, CMColor *colorBuf, UInt32 count)
 
CMError CMMOpen (uintptr_t *cmmRefcon, void *hInstance)
 
static void * cmmreallocate (void *ptr, CFIndex size, CFOptionFlags hint, void *info)
 
static void create_allocator (void)
 
static CMError DoInit (CMMStoragePtr storage, CMProfileRef srcProf, CMProfileRef dstProf, UInt32 srcTransform, UInt32 dstTransform)
 
static CMError DoInitSampleICC (CMMStoragePtr storage, NCMConcatProfileSet *profileSet)
 
static void DoMatch (CMMStoragePtr storage, CMMMatchRec *pMatchInfo)
 
static uintptr_t GetCMMStorage (CMWorldRef cw)
 
CIccProfilegetIccProfLibProfileFromColorsyncProfile (CMProfileRef pref)
 
static void MatchOne_CMYK_Gray (UInt16 *chan)
 
static void MatchOne_CMYK_LAB (UInt16 *chan)
 
static void MatchOne_CMYK_RGB (UInt16 *chan)
 
static void MatchOne_CMYK_XYZ (UInt16 *chan)
 
static void MatchOne_Gray_CMYK (UInt16 *chan)
 
static void MatchOne_Gray_LAB (UInt16 *chan)
 
static void MatchOne_Gray_RGB (UInt16 *chan)
 
static void MatchOne_Gray_XYZ (UInt16 *chan)
 
static void MatchOne_LAB_CMYK (UInt16 *chan)
 
static void MatchOne_LAB_Gray (UInt16 *chan)
 
static void MatchOne_LAB_RGB (UInt16 *chan)
 
static void MatchOne_LAB_XYZ (UInt16 *chan)
 
static void MatchOne_RGB_CMYK (UInt16 *chan)
 
static void MatchOne_RGB_Gray (UInt16 *chan)
 
static void MatchOne_RGB_LAB (UInt16 *chan)
 
static void MatchOne_RGB_XYZ (UInt16 *chan)
 
static void MatchOne_XYZ_CMYK (UInt16 *chan)
 
static void MatchOne_XYZ_Gray (UInt16 *chan)
 
static void MatchOne_XYZ_LAB (UInt16 *chan)
 
static void MatchOne_XYZ_RGB (UInt16 *chan)
 
CMError NCMMConcatInit (uintptr_t *cmmRefcon, NCMConcatProfileSet *profileSet, CMConcatCallBackUPP proc, void *refCon)
 
CMError NCMMInit (uintptr_t *cmmRefcon, CMProfileRef srcProf, CMProfileRef dstProf)
 

Variables

static CFAllocatorRef cmmAllocator = NULL
 
static const CFAllocatorContext context
 

Detailed Description

File: RefIccMAXCmm.cpp

Contains: RefIccMAX CMM Component for ColorSync 2.x

Version: V1

Copyright: (c) see ICC Software License

Definition in file RefIccMAXCmm.cpp.


Data Structure Documentation

◆ CMMMatchRec

struct CMMMatchRec
Data Fields
UInt8 * dstBuf[4]
UInt32 dstChanBits
UInt32 dstColBytes
UInt32 dstRowBytes
Boolean dstSwap
UInt32 height
UInt8 * srcBuf[4]
UInt32 srcChanBits
UInt32 srcColBytes
UInt32 srcRowBytes
Boolean srcSwap
UInt32 width

◆ CMMStorageRec

struct CMMStorageRec
Data Fields
CIccCmm * cmm
OSType dstClass
OSType dstSpace
MatchOneProc proc
OSType srcClass
OSType srcSpace

◆ sMemBlock

struct sMemBlock
Data Fields
unsigned char * mem
unsigned long memSize
unsigned long size

Macro Definition Documentation

◆ DoubToFract

#define DoubToFract (   x)    (((x)<=0.0)?(0):(((x)>=2.0)?(65535):((x)*32768.0 + 0.5)))

◆ DoubToUInt16

#define DoubToUInt16 (   x)    (((x)<=0.0)?(0):(((x)>=1.0)?(65535):((x)*65535.0 + 0.5)))

◆ FractToDoub

#define FractToDoub (   x)    ((double)(x)/32768.0)

◆ FractToUInt16

#define FractToUInt16 (   x)    ((x)<<1)

◆ kCMMSTORAGE

#define kCMMSTORAGE   CFSTR("com.acme.DemoCMM")

◆ UInt16ToDoub

#define UInt16ToDoub (   x)    ((double)(x)/65535.0)

◆ UInt16ToFract

#define UInt16ToFract (   x)    ((x)>>1)

Typedef Documentation

◆ CMMStoragePtr

typedef struct CMMStorageRec * CMMStoragePtr

◆ MatchOneProc

typedef void(* MatchOneProc) (UInt16 *chan)

Function Documentation

◆ CMM_CheckBitmap()

CMError CMM_CheckBitmap ( CMWorldRef  cw,
const CMBitmap *  srcMap,
CMBitmapCallBackUPP  progressProc,
void *  refCon,
CMBitmap *  chkMap 
)
1143{
1144 CMError err = paramErr;
1145
1146 uintptr_t cmmStorage = GetCMMStorage (cw);
1147
1148 if (cmmStorage)
1149 {
1150 err = CMMCheckBitmap (&cmmStorage, srcMap, progressProc, refCon, chkMap);
1151 }
1152
1153 return err;
1154}
static uintptr_t GetCMMStorage(CMWorldRef cw)
Definition RefIccMAXCmm.cpp:1042
CMError CMMCheckBitmap(uintptr_t *cmmRefcon, const CMBitmap *srcMap, CMBitmapCallBackUPP progressProc, void *refCon, CMBitmap *chkMap)
Definition RefIccMAXCmm.cpp:1026

◆ CMM_CheckColors()

CMError CMM_CheckColors ( CMWorldRef  cw,
CMColor *  myColors,
UInt32  count,
UInt8 *  result 
)
1112{
1113 CMError err = paramErr;
1114
1115 uintptr_t cmmStorage = GetCMMStorage (cw);
1116
1117 if (cmmStorage)
1118 {
1119 err = CMMCheckColors (&cmmStorage, myColors, count, result);
1120 }
1121
1122 return err;
1123}
CMError CMMCheckColors(uintptr_t *cmmRefcon, CMColor *colorBuf, UInt32 count, UInt8 *gamutResult)
Definition RefIccMAXCmm.cpp:1015

◆ CMM_ConcatColorWorld()

CMError CMM_ConcatColorWorld ( CMWorldRef  cw,
NCMConcatProfileSet *  profileSet,
CMConcatCallBackUPP  proc,
void *  refCon 
)
1062{
1063 CMError err = paramErr;
1064
1065 if (cw)
1066 {
1067 uintptr_t cmmStorage = (uintptr_t) NULL;
1068
1069 if ((err = CMMOpen (&cmmStorage, NULL)) == noErr)
1070 {
1071 CFDataRef prop = CFDataCreateWithBytesNoCopy (NULL, (const UInt8*) cmmStorage, sizeof (cmmStorage), CMMBytesDeallocator());
1072
1073 if (prop)
1074 {
1075 CWColorWorldSetProperty (cw, kCMMSTORAGE, prop);
1076
1077 CFRelease (prop);
1078
1079 return NCMMConcatInit (&cmmStorage, profileSet, proc, refCon);
1080 }
1081 else
1082 {
1083 CMMClose(&cmmStorage);
1084
1085 err = memFullErr;
1086 }
1087 }
1088 }
1089
1090 return err;
1091}
#define kCMMSTORAGE
Definition RefIccMAXCmm.cpp:1037
CMError NCMMConcatInit(uintptr_t *cmmRefcon, NCMConcatProfileSet *profileSet, CMConcatCallBackUPP proc, void *refCon)
Definition RefIccMAXCmm.cpp:692
CMError CMMOpen(uintptr_t *cmmRefcon, void *hInstance)
Definition RefIccMAXCmm.cpp:640
static CFAllocatorRef CMMBytesDeallocator()
Definition RefIccMAXCmm.cpp:1206
CMError CMMClose(uintptr_t *cmmRefcon)
Definition RefIccMAXCmm.cpp:661

References CMMClose().

+ Here is the call graph for this function:

◆ CMM_MatchBitmap()

CMError CMM_MatchBitmap ( CMWorldRef  cw,
CMBitmap *  srcMap,
CMBitmapCallBackUPP  progressProc,
void *  refCon,
CMBitmap *  dstMap 
)
1128{
1129 CMError err = paramErr;
1130
1131 uintptr_t cmmStorage = GetCMMStorage (cw);
1132
1133 if (cmmStorage)
1134 {
1135 err = CMMMatchBitmap (&cmmStorage, srcMap, progressProc, refCon, dstMap);
1136 }
1137
1138 return err;
1139}
CMError CMMMatchBitmap(uintptr_t *cmmRefcon, CMBitmap *srcMap, CMBitmapCallBackUPP progressProc, void *refCon, CMBitmap *dstMap)
Definition RefIccMAXCmm.cpp:737

◆ CMM_MatchColors()

CMError CMM_MatchColors ( CMWorldRef  cw,
CMColor *  myColors,
UInt32  count 
)
1096{
1097 CMError err = paramErr;
1098
1099 uintptr_t cmmStorage = GetCMMStorage (cw);
1100
1101 if (cmmStorage)
1102 {
1103 err = CMMMatchColors (&cmmStorage, myColors, count);
1104 }
1105
1106 return err;
1107}
CMError CMMMatchColors(uintptr_t *cmmRefcon, CMColor *colorBuf, UInt32 count)
Definition RefIccMAXCmm.cpp:705

◆ cmmallocate()

static void * cmmallocate ( CFIndex  size,
CFOptionFlags  hint,
void *  info 
)
static
1167{
1168 return malloc(size);
1169}

◆ CMMBytesDeallocator()

static CFAllocatorRef CMMBytesDeallocator ( )
static
1207{
1208 static pthread_once_t once = PTHREAD_ONCE_INIT;
1209
1210 if (cmmAllocator == NULL)
1211 {
1212 pthread_once(&once, &create_allocator);
1213 }
1214
1215 return cmmAllocator;
1216}
static CFAllocatorRef cmmAllocator
Definition RefIccMAXCmm.cpp:1163
static void create_allocator(void)
Definition RefIccMAXCmm.cpp:1201

References cmmAllocator, and create_allocator().

+ Here is the call graph for this function:

◆ CMMCheckBitmap()

CMError CMMCheckBitmap ( uintptr_t *  cmmRefcon,
const CMBitmap *  srcMap,
CMBitmapCallBackUPP  progressProc,
void *  refCon,
CMBitmap *  chkMap 
)
1027{
1028 #pragma unused (cmmRefcon, srcMap, progressProc, refCon, chkMap)
1029 // This is just sample code.
1030 return unimpErr;
1031}

◆ CMMCheckColors()

CMError CMMCheckColors ( uintptr_t *  cmmRefcon,
CMColor *  colorBuf,
UInt32  count,
UInt8 *  gamutResult 
)
1016{
1017 #pragma unused (cmmRefcon, colorBuf)
1018 // This is just sample code. Return that everything is in gamut.
1019 UInt32 byteCount = (count + 7) / 8;
1020 memset(gamutResult, 0xFF, byteCount);
1021 return noErr;
1022}

◆ CMMClose()

CMError CMMClose ( uintptr_t *  cmmRefcon)
662{
663 if (*cmmRefcon)
664 {
665 CMMStorageRec* storage = (CMMStorageRec*)*cmmRefcon;
666 delete storage->cmm;
667 free((void*)*cmmRefcon);
668 }
669
670 return noErr;
671}
CIccCmm * cmm
Definition RefIccMAXCmm.cpp:85
Definition RefIccMAXCmm.cpp:79

References CMMStorageRec::cmm.

Referenced by CMM_ConcatColorWorld(), and cmmdeallocate().

+ Here is the caller graph for this function:

◆ CMMConcatInit()

CMError CMMConcatInit ( uintptr_t *  cmmRefcon,
CMConcatProfileSet *  profileSet 
)
683{
684 CMProfileRef srcProf = profileSet->profileSet[0];
685 CMProfileRef dstProf = profileSet->profileSet[profileSet->count-1];
686
687 return DoInit((CMMStoragePtr)*cmmRefcon, srcProf, dstProf, kDeviceToPCS, kPCSToDevice);
688}
static CMError DoInit(CMMStoragePtr storage, CMProfileRef srcProf, CMProfileRef dstProf, UInt32 srcTransform, UInt32 dstTransform)
Definition RefIccMAXCmm.cpp:538

◆ cmmdeallocate()

static void cmmdeallocate ( void *  ptr,
void *  info 
)
static
1179{
1180 void* cmmStorage = ptr;
1181
1182 if (cmmStorage)
1183 {
1184 CMMClose ((uintptr_t*) &cmmStorage);
1185 }
1186}

References CMMClose().

+ Here is the call graph for this function:

◆ CMMMatchBitmap()

CMError CMMMatchBitmap ( uintptr_t *  cmmRefcon,
CMBitmap *  srcMap,
CMBitmapCallBackUPP  progressProc,
void *  refCon,
CMBitmap *  dstMap 
)
738{
739 #pragma unused (progressProc, refCon)
740 CMMMatchRec matchInfo;
741 OSType srcSpace = 0;
742 OSType dstSpace = 0;
743
744 // Check params
745 if (srcMap==NULL || srcMap->image==NULL ||
746 dstMap==NULL || dstMap->image==NULL)
747 return paramErr;
748
749 matchInfo.height = srcMap->height;
750 matchInfo.width = srcMap->width;
751 matchInfo.srcRowBytes = srcMap->rowBytes;
752 matchInfo.dstRowBytes = dstMap->rowBytes;
753
754 switch (srcMap->space)
755 {
756 case cmGray8Space:
757 srcSpace = cmGrayData;
758 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 0;
759 matchInfo.srcBuf[1] = NULL;
760 matchInfo.srcBuf[2] = NULL;
761 matchInfo.srcBuf[3] = NULL;
762 matchInfo.srcChanBits = 8;
763 matchInfo.srcColBytes = 1;
764 break;
765
766 case cmGray16Space:
767 case cmGray16LSpace:
768 srcSpace = cmGrayData;
769 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 0;
770 matchInfo.srcBuf[1] = NULL;
771 matchInfo.srcBuf[2] = NULL;
772 matchInfo.srcBuf[3] = NULL;
773 matchInfo.srcChanBits = 16;
774 matchInfo.srcColBytes = 2;
775 break;
776
777 case cmRGB24Space:
778 srcSpace = cmRGBData;
779 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 0;
780 matchInfo.srcBuf[1] = (UInt8*)srcMap->image + 1;
781 matchInfo.srcBuf[2] = (UInt8*)srcMap->image + 2;
782 matchInfo.srcBuf[3] = NULL;
783 matchInfo.srcChanBits = 8;
784 matchInfo.srcColBytes = 3;
785 break;
786
787 case cmRGB32Space:
788 case cmRGBA32Space:
789 srcSpace = cmRGBData;
790 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 1;
791 matchInfo.srcBuf[1] = (UInt8*)srcMap->image + 2;
792 matchInfo.srcBuf[2] = (UInt8*)srcMap->image + 3;
793 matchInfo.srcBuf[3] = NULL;
794 matchInfo.srcChanBits = 8;
795 matchInfo.srcColBytes = 4;
796 break;
797
798 case cmRGB48Space:
799 case cmRGB48LSpace:
800 srcSpace = cmRGBData;
801 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 0;
802 matchInfo.srcBuf[1] = (UInt8*)srcMap->image + 2;
803 matchInfo.srcBuf[2] = (UInt8*)srcMap->image + 4;
804 matchInfo.srcBuf[3] = NULL;
805 matchInfo.srcChanBits = 16;
806 matchInfo.srcColBytes = 6;
807 break;
808
809 case cmCMYK32Space:
810 srcSpace = cmCMYKData;
811 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 0;
812 matchInfo.srcBuf[1] = (UInt8*)srcMap->image + 1;
813 matchInfo.srcBuf[2] = (UInt8*)srcMap->image + 2;
814 matchInfo.srcBuf[3] = (UInt8*)srcMap->image + 3;
815 matchInfo.srcChanBits = 8;
816 matchInfo.srcColBytes = 4;
817 break;
818
819 case cmCMYK64Space:
820 case cmCMYK64LSpace:
821 srcSpace = cmCMYKData;
822 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 0;
823 matchInfo.srcBuf[1] = (UInt8*)srcMap->image + 2;
824 matchInfo.srcBuf[2] = (UInt8*)srcMap->image + 4;
825 matchInfo.srcBuf[3] = (UInt8*)srcMap->image + 6;
826 matchInfo.srcChanBits = 16;
827 matchInfo.srcColBytes = 8;
828 break;
829
830 case cmLAB24Space:
831 srcSpace = cmLabData;
832 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 0;
833 matchInfo.srcBuf[1] = (UInt8*)srcMap->image + 1;
834 matchInfo.srcBuf[2] = (UInt8*)srcMap->image + 2;
835 matchInfo.srcBuf[3] = NULL;
836 matchInfo.srcChanBits = 8;
837 matchInfo.srcColBytes = 3;
838 break;
839
840 case cmLAB48Space:
841 case cmLAB48LSpace:
842 srcSpace = cmLabData;
843 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 0;
844 matchInfo.srcBuf[1] = (UInt8*)srcMap->image + 2;
845 matchInfo.srcBuf[2] = (UInt8*)srcMap->image + 4;
846 matchInfo.srcBuf[3] = NULL;
847 matchInfo.srcChanBits = 16;
848 matchInfo.srcColBytes = 6;
849 break;
850
851 case cmXYZ24Space:
852 srcSpace = cmXYZData;
853 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 0;
854 matchInfo.srcBuf[1] = (UInt8*)srcMap->image + 1;
855 matchInfo.srcBuf[2] = (UInt8*)srcMap->image + 2;
856 matchInfo.srcBuf[3] = NULL;
857 matchInfo.srcChanBits = 8;
858 matchInfo.srcColBytes = 3;
859 break;
860
861 case cmXYZ48Space:
862 case cmXYZ48LSpace:
863 srcSpace = cmXYZData;
864 matchInfo.srcBuf[0] = (UInt8*)srcMap->image + 0;
865 matchInfo.srcBuf[1] = (UInt8*)srcMap->image + 2;
866 matchInfo.srcBuf[2] = (UInt8*)srcMap->image + 4;
867 matchInfo.srcBuf[3] = NULL;
868 matchInfo.srcChanBits = 16;
869 matchInfo.srcColBytes = 6;
870 break;
871
872 default:
873 return cmInvalidSrcMap;
874 break;
875 }
876
877
878 switch (dstMap->space)
879 {
880 case cmGray8Space:
881 dstSpace = cmGrayData;
882 matchInfo.dstBuf[0] = (UInt8*)srcMap->image + 0;
883 matchInfo.dstBuf[1] = NULL;
884 matchInfo.dstBuf[2] = NULL;
885 matchInfo.dstBuf[3] = NULL;
886 matchInfo.dstChanBits = 8;
887 matchInfo.dstColBytes = 1;
888 break;
889
890 case cmGray16Space:
891 case cmGray16LSpace:
892 dstSpace = cmGrayData;
893 matchInfo.dstBuf[0] = (UInt8*)srcMap->image + 0;
894 matchInfo.dstBuf[1] = NULL;
895 matchInfo.dstBuf[2] = NULL;
896 matchInfo.dstBuf[3] = NULL;
897 matchInfo.dstChanBits = 16;
898 matchInfo.dstColBytes = 2;
899 break;
900
901 case cmRGB24Space:
902 dstSpace = cmRGBData;
903 matchInfo.dstBuf[0] = (UInt8*)dstMap->image + 0;
904 matchInfo.dstBuf[1] = (UInt8*)dstMap->image + 1;
905 matchInfo.dstBuf[2] = (UInt8*)dstMap->image + 2;
906 matchInfo.dstBuf[3] = NULL;
907 matchInfo.dstChanBits = 8;
908 matchInfo.dstColBytes = 3;
909 break;
910
911 case cmRGB32Space:
912 case cmRGBA32Space:
913 dstSpace = cmRGBData;
914 matchInfo.dstBuf[0] = (UInt8*)dstMap->image + 1;
915 matchInfo.dstBuf[1] = (UInt8*)dstMap->image + 2;
916 matchInfo.dstBuf[2] = (UInt8*)dstMap->image + 3;
917 matchInfo.dstBuf[3] = NULL;
918 matchInfo.dstChanBits = 8;
919 matchInfo.dstColBytes = 4;
920 break;
921
922 case cmRGB48Space:
923 case cmRGB48LSpace:
924 dstSpace = cmRGBData;
925 matchInfo.dstBuf[0] = (UInt8*)dstMap->image + 0;
926 matchInfo.dstBuf[1] = (UInt8*)dstMap->image + 2;
927 matchInfo.dstBuf[2] = (UInt8*)dstMap->image + 4;
928 matchInfo.dstBuf[3] = NULL;
929 matchInfo.dstChanBits = 16;
930 matchInfo.dstColBytes = 6;
931 break;
932
933 case cmCMYK32Space:
934 dstSpace = cmCMYKData;
935 matchInfo.dstBuf[0] = (UInt8*)dstMap->image + 0;
936 matchInfo.dstBuf[1] = (UInt8*)dstMap->image + 1;
937 matchInfo.dstBuf[2] = (UInt8*)dstMap->image + 2;
938 matchInfo.dstBuf[3] = (UInt8*)dstMap->image + 3;
939 matchInfo.dstChanBits = 8;
940 matchInfo.dstColBytes = 4;
941 break;
942
943 case cmCMYK64Space:
944 case cmCMYK64LSpace:
945 dstSpace = cmCMYKData;
946 matchInfo.dstBuf[0] = (UInt8*)dstMap->image + 0;
947 matchInfo.dstBuf[1] = (UInt8*)dstMap->image + 2;
948 matchInfo.dstBuf[2] = (UInt8*)dstMap->image + 4;
949 matchInfo.dstBuf[3] = (UInt8*)dstMap->image + 6;
950 matchInfo.dstChanBits = 16;
951 matchInfo.dstColBytes = 8;
952 break;
953
954 case cmLAB24Space:
955 dstSpace = cmLabData;
956 matchInfo.dstBuf[0] = (UInt8*)dstMap->image + 0;
957 matchInfo.dstBuf[1] = (UInt8*)dstMap->image + 1;
958 matchInfo.dstBuf[2] = (UInt8*)dstMap->image + 2;
959 matchInfo.dstBuf[3] = NULL;
960 matchInfo.dstChanBits = 8;
961 matchInfo.dstColBytes = 3;
962 break;
963
964 case cmLAB48Space:
965 case cmLAB48LSpace:
966 dstSpace = cmLabData;
967 matchInfo.dstBuf[0] = (UInt8*)dstMap->image + 0;
968 matchInfo.dstBuf[1] = (UInt8*)dstMap->image + 2;
969 matchInfo.dstBuf[2] = (UInt8*)dstMap->image + 4;
970 matchInfo.dstBuf[3] = NULL;
971 matchInfo.dstChanBits = 16;
972 matchInfo.dstColBytes = 6;
973 break;
974
975 case cmXYZ24Space:
976 dstSpace = cmXYZData;
977 matchInfo.dstBuf[0] = (UInt8*)dstMap->image + 0;
978 matchInfo.dstBuf[1] = (UInt8*)dstMap->image + 1;
979 matchInfo.dstBuf[2] = (UInt8*)dstMap->image + 2;
980 matchInfo.dstBuf[3] = NULL;
981 matchInfo.dstChanBits = 8;
982 matchInfo.dstColBytes = 3;
983 break;
984
985 case cmXYZ48Space:
986 case cmXYZ48LSpace:
987 dstSpace = cmXYZData;
988 matchInfo.dstBuf[0] = (UInt8*)dstMap->image + 0;
989 matchInfo.dstBuf[1] = (UInt8*)dstMap->image + 2;
990 matchInfo.dstBuf[2] = (UInt8*)dstMap->image + 4;
991 matchInfo.dstBuf[3] = NULL;
992 matchInfo.dstChanBits = 16;
993 matchInfo.dstColBytes = 6;
994 break;
995
996 default:
997 return cmInvalidSrcMap;
998 break;
999 }
1000
1001 #if TARGET_RT_LITTLE_ENDIAN
1002 matchInfo.srcSwap = ((srcMap->space & cmLittleEndianPacking) == 0);
1003 matchInfo.dstSwap = ((dstMap->space & cmLittleEndianPacking) == 0);
1004 #else
1005 matchInfo.srcSwap = ((srcMap->space & cmLittleEndianPacking) == cmLittleEndianPacking);
1006 matchInfo.dstSwap = ((dstMap->space & cmLittleEndianPacking) == cmLittleEndianPacking);
1007 #endif
1008
1009 DoMatch((CMMStoragePtr)*cmmRefcon, &matchInfo);
1010 return noErr;
1011}
UInt32 width
Definition RefIccMAXCmm.cpp:93
UInt32 srcChanBits
Definition RefIccMAXCmm.cpp:96
UInt32 dstRowBytes
Definition RefIccMAXCmm.cpp:103
UInt32 height
Definition RefIccMAXCmm.cpp:92
UInt32 srcColBytes
Definition RefIccMAXCmm.cpp:98
UInt32 srcRowBytes
Definition RefIccMAXCmm.cpp:97
static void DoMatch(CMMStoragePtr storage, CMMMatchRec *pMatchInfo)
Definition RefIccMAXCmm.cpp:151
UInt8 * srcBuf[4]
Definition RefIccMAXCmm.cpp:95
Definition RefIccMAXCmm.cpp:91

References DoMatch().

+ Here is the call graph for this function:

◆ CMMMatchColors()

CMError CMMMatchColors ( uintptr_t *  cmmRefcon,
CMColor *  colorBuf,
UInt32  count 
)
706{
707 CMMMatchRec matchInfo;
708
709 matchInfo.height = count;
710 matchInfo.width = 1;
711
712 matchInfo.srcBuf[0] = ((UInt8*)colorBuf) + 0;
713 matchInfo.srcBuf[1] = ((UInt8*)colorBuf) + 2;
714 matchInfo.srcBuf[2] = ((UInt8*)colorBuf) + 4;
715 matchInfo.srcBuf[3] = ((UInt8*)colorBuf) + 6;
716 matchInfo.srcChanBits = 16;
717 matchInfo.srcRowBytes = sizeof(CMColor);
718 matchInfo.srcColBytes = sizeof(CMColor);
719 matchInfo.srcSwap = false;
720
721 matchInfo.dstBuf[0] = ((UInt8*)colorBuf) + 0;
722 matchInfo.dstBuf[1] = ((UInt8*)colorBuf) + 2;
723 matchInfo.dstBuf[2] = ((UInt8*)colorBuf) + 4;
724 matchInfo.dstBuf[3] = ((UInt8*)colorBuf) + 6;
725 matchInfo.dstChanBits = 16;
726 matchInfo.dstRowBytes = sizeof(CMColor);
727 matchInfo.dstColBytes = sizeof(CMColor);
728 matchInfo.dstSwap = false;
729
730 DoMatch((CMMStoragePtr)*cmmRefcon, &matchInfo);
731
732 return noErr;
733}
UInt32 dstColBytes
Definition RefIccMAXCmm.cpp:104
UInt32 dstChanBits
Definition RefIccMAXCmm.cpp:102
UInt8 * dstBuf[4]
Definition RefIccMAXCmm.cpp:101
Boolean srcSwap
Definition RefIccMAXCmm.cpp:99
Boolean dstSwap
Definition RefIccMAXCmm.cpp:105

References DoMatch().

+ Here is the call graph for this function:

◆ CMMOpen()

CMError CMMOpen ( uintptr_t *  cmmRefcon,
void *  hInstance 
)
641{
642 #pragma unused (hInstance)
643 *cmmRefcon = (uintptr_t)calloc(1,sizeof(CMMStorageRec));
644 //{
645 // CFBundleRef ref = NULL;
646 // ref = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.ColorSync.DemoCMM"));
647 //}
648
649 CMMStorageRec* storage = (CMMStorageRec*)*cmmRefcon;
650
651 storage->cmm = new CIccCmm;
652
653 if (*cmmRefcon)
654 return noErr;
655 else
656 return memFullErr;
657}

References CMMStorageRec::cmm.

◆ cmmreallocate()

static void * cmmreallocate ( void *  ptr,
CFIndex  size,
CFOptionFlags  hint,
void *  info 
)
static
1173{
1174 return realloc(ptr, size);
1175}

◆ create_allocator()

static void create_allocator ( void  )
static
1202{
1203 cmmAllocator = CFAllocatorCreate(kCFAllocatorUseContext, (CFAllocatorContext *)&context);
1204}
static const CFAllocatorContext context
Definition RefIccMAXCmm.cpp:1188

Referenced by CMMBytesDeallocator().

+ Here is the caller graph for this function:

◆ DoInit()

static CMError DoInit ( CMMStoragePtr  storage,
CMProfileRef  srcProf,
CMProfileRef  dstProf,
UInt32  srcTransform,
UInt32  dstTransform 
)
static
539{
540 CMError err = noErr;
541 CMAppleProfileHeader srcHdr;
542 CMAppleProfileHeader dstHdr;
543 OSType srcSpace;
544 OSType dstSpace;
545
546 err = CMGetProfileHeader(srcProf, &srcHdr);
547 require_noerr(err, bail);
548
549 err = CMGetProfileHeader(dstProf, &dstHdr);
550 require_noerr(err, bail);
551
552 storage->srcSpace = (kDeviceToPCS) ? srcHdr.cm2.dataColorSpace : srcHdr.cm2.profileConnectionSpace;
553 storage->srcClass = srcHdr.cm2.profileClass;
554
555 storage->dstSpace = (kPCSToDevice) ? dstHdr.cm2.dataColorSpace : dstHdr.cm2.profileConnectionSpace;
556 storage->dstClass = dstHdr.cm2.profileClass;
557
558 srcSpace = storage->srcSpace;
559 dstSpace = storage->dstSpace;
560
561 if (srcSpace == dstSpace) storage->proc = NULL;
562 else if (srcSpace==cmRGBData && dstSpace==cmCMYKData) storage->proc = &MatchOne_RGB_CMYK;
563 else if (srcSpace==cmRGBData && dstSpace==cmXYZData) storage->proc = &MatchOne_RGB_XYZ;
564 else if (srcSpace==cmRGBData && dstSpace==cmLabData) storage->proc = &MatchOne_RGB_LAB;
565 else if (srcSpace==cmRGBData && dstSpace==cmGrayData) storage->proc = &MatchOne_RGB_Gray;
566 else if (srcSpace==cmCMYKData && dstSpace==cmRGBData) storage->proc = &MatchOne_CMYK_RGB;
567 else if (srcSpace==cmCMYKData && dstSpace==cmLabData) storage->proc = &MatchOne_CMYK_LAB;
568 else if (srcSpace==cmCMYKData && dstSpace==cmXYZData) storage->proc = &MatchOne_CMYK_XYZ;
569 else if (srcSpace==cmCMYKData && dstSpace==cmGrayData) storage->proc = &MatchOne_CMYK_Gray;
570 else if (srcSpace==cmXYZData && dstSpace==cmRGBData) storage->proc = &MatchOne_XYZ_RGB;
571 else if (srcSpace==cmXYZData && dstSpace==cmLabData) storage->proc = &MatchOne_XYZ_LAB;
572 else if (srcSpace==cmXYZData && dstSpace==cmCMYKData) storage->proc = &MatchOne_XYZ_CMYK;
573 else if (srcSpace==cmXYZData && dstSpace==cmGrayData) storage->proc = &MatchOne_XYZ_Gray;
574 else if (srcSpace==cmLabData && dstSpace==cmRGBData) storage->proc = &MatchOne_LAB_RGB;
575 else if (srcSpace==cmLabData && dstSpace==cmXYZData) storage->proc = &MatchOne_LAB_XYZ;
576 else if (srcSpace==cmLabData && dstSpace==cmCMYKData) storage->proc = &MatchOne_LAB_CMYK;
577 else if (srcSpace==cmLabData && dstSpace==cmGrayData) storage->proc = &MatchOne_LAB_Gray;
578 else if (srcSpace==cmGrayData && dstSpace==cmRGBData) storage->proc = &MatchOne_Gray_RGB;
579 else if (srcSpace==cmGrayData && dstSpace==cmCMYKData) storage->proc = &MatchOne_Gray_CMYK;
580 else if (srcSpace==cmGrayData && dstSpace==cmXYZData) storage->proc = &MatchOne_Gray_XYZ;
581 else if (srcSpace==cmGrayData && dstSpace==cmLabData) storage->proc = &MatchOne_Gray_LAB;
582 else
583 err = cmInvalidProfile;
584
585 require_noerr(err, bail);
586
587bail:
588
589 return err;
590}
static void MatchOne_Gray_CMYK(UInt16 *chan)
Definition RefIccMAXCmm.cpp:527
static void MatchOne_LAB_Gray(UInt16 *chan)
Definition RefIccMAXCmm.cpp:448
static void MatchOne_CMYK_LAB(UInt16 *chan)
Definition RefIccMAXCmm.cpp:475
static void MatchOne_Gray_XYZ(UInt16 *chan)
Definition RefIccMAXCmm.cpp:434
static void MatchOne_RGB_CMYK(UInt16 *chan)
Definition RefIccMAXCmm.cpp:352
OSType srcSpace
Definition RefIccMAXCmm.cpp:80
OSType srcClass
Definition RefIccMAXCmm.cpp:81
MatchOneProc proc
Definition RefIccMAXCmm.cpp:84
static void MatchOne_XYZ_Gray(UInt16 *chan)
Definition RefIccMAXCmm.cpp:428
static void MatchOne_LAB_CMYK(UInt16 *chan)
Definition RefIccMAXCmm.cpp:482
static void MatchOne_RGB_LAB(UInt16 *chan)
Definition RefIccMAXCmm.cpp:461
static void MatchOne_Gray_LAB(UInt16 *chan)
Definition RefIccMAXCmm.cpp:455
static void MatchOne_RGB_XYZ(UInt16 *chan)
Definition RefIccMAXCmm.cpp:378
static void MatchOne_XYZ_RGB(UInt16 *chan)
Definition RefIccMAXCmm.cpp:403
static void MatchOne_CMYK_Gray(UInt16 *chan)
Definition RefIccMAXCmm.cpp:520
static void MatchOne_LAB_XYZ(UInt16 *chan)
Definition RefIccMAXCmm.cpp:306
static void MatchOne_CMYK_XYZ(UInt16 *chan)
Definition RefIccMAXCmm.cpp:489
static void MatchOne_Gray_RGB(UInt16 *chan)
Definition RefIccMAXCmm.cpp:513
OSType dstClass
Definition RefIccMAXCmm.cpp:83
static void MatchOne_CMYK_RGB(UInt16 *chan)
Definition RefIccMAXCmm.cpp:366
static void MatchOne_XYZ_CMYK(UInt16 *chan)
Definition RefIccMAXCmm.cpp:496
OSType dstSpace
Definition RefIccMAXCmm.cpp:82
static void MatchOne_LAB_RGB(UInt16 *chan)
Definition RefIccMAXCmm.cpp:468
static void MatchOne_RGB_Gray(UInt16 *chan)
Definition RefIccMAXCmm.cpp:503
static void MatchOne_XYZ_LAB(UInt16 *chan)
Definition RefIccMAXCmm.cpp:255

References CMMStorageRec::proc.

◆ DoInitSampleICC()

static CMError DoInitSampleICC ( CMMStoragePtr  storage,
NCMConcatProfileSet *  profileSet 
)
static
595{
596 CMError err = noErr;
597 CMAppleProfileHeader srcHdr;
598 CMAppleProfileHeader dstHdr;
599 OSType srcSpace;
600 OSType dstSpace;
601
602 err = CMGetProfileHeader(profileSet->profileSpecs[0].profile, &srcHdr);
603 require_noerr(err, bail);
604
605 err = CMGetProfileHeader(profileSet->profileSpecs[profileSet->profileCount-1].profile, &dstHdr);
606 require_noerr(err, bail);
607
608 storage->srcSpace = (kDeviceToPCS) ? srcHdr.cm2.dataColorSpace : srcHdr.cm2.profileConnectionSpace;
609 storage->srcClass = srcHdr.cm2.profileClass;
610
611 storage->dstSpace = (kPCSToDevice) ? dstHdr.cm2.dataColorSpace : dstHdr.cm2.profileConnectionSpace;
612 storage->dstClass = dstHdr.cm2.profileClass;
613
614 srcSpace = storage->srcSpace;
615 dstSpace = storage->dstSpace;
616
617 for (int i=0; i<profileSet->profileCount; i++)
618 {
619 CIccProfile* prof = getIccProfLibProfileFromColorsyncProfile(profileSet->profileSpecs[i].profile);
620 storage->cmm->AddXform(prof,(icRenderingIntent)profileSet->profileSpecs[i].renderingIntent);
621 }
622
623 if (storage->cmm->Begin() != icCmmStatOk)
624 {
625 err = cmInvalidProfile;
626 require_noerr(err, bail);
627 }
628
629
630bail:
631
632 return err;
633}
icRenderingIntent
Definition icProfileHeader.h:1142
@ icCmmStatOk
Definition IccCmm.h:92
class ICCPROFLIB_API CIccProfile
Definition IccPcc.h:80
CIccProfile * getIccProfLibProfileFromColorsyncProfile(CMProfileRef pref)
Definition RefIccMAXCmm.cpp:1282

References CIccProfile, CMMStorageRec::cmm, and icCmmStatOk.

◆ DoMatch()

static void DoMatch ( CMMStoragePtr  storage,
CMMMatchRec pMatchInfo 
)
static
152{
153 UInt32 r,c;
154 float chanIn[16];
155 float chanOut[16];
156 UInt8** sBuf;
157 UInt8** dBuf;
158
159 sBuf = pMatchInfo->srcBuf;
160 dBuf = pMatchInfo->dstBuf;
161 int numIn = storage->cmm->GetSourceSamples();
162 int numOut = storage->cmm->GetDestSamples();
163
164 for (r=0; r < pMatchInfo->height; r++)
165 {
166 for (c=0; c < pMatchInfo->width; c++)
167 {
168 // read color in from source buffer
169
170 if (pMatchInfo->srcSwap)
171 {
172 if (pMatchInfo->srcChanBits==16)
173 {
174 for (int i=0; i<numIn; i++)
175 {
176 UInt16 temp;
177 if (sBuf[i]) temp = *(UInt16*)(sBuf[i] + (r * pMatchInfo->srcRowBytes) + (c * pMatchInfo->srcColBytes));
178 chanIn[i] = (float)Endian16_Swap(temp)*0.000015259;
179 }
180
181 }
182 else
183 {
184 for (int i=0; i<numIn; i++)
185 {
186 if (sBuf[i]) chanIn[i] = (*(UInt8*)(sBuf[0] + (r * pMatchInfo->srcRowBytes) + (c * pMatchInfo->srcColBytes)))*0.00392157;
187 }
188 }
189 }
190 else {
191 if (pMatchInfo->srcChanBits==16)
192 {
193 for (int i=0; i<numIn; i++)
194 if (sBuf[i]) chanIn[i] = (*(UInt16*)(sBuf[i] + (r * pMatchInfo->srcRowBytes) + (c * pMatchInfo->srcColBytes)))*0.000015259;;
195 }
196 else
197 {
198 for (int i=0; i<numIn; i++)
199 {
200 if (sBuf[i]) chanIn[i] = (*(UInt8*)(sBuf[0] + (r * pMatchInfo->srcRowBytes) + (c * pMatchInfo->srcColBytes)))*0.00392157;;
201 }
202 }
203 }
204
205 // Match the color
206 storage->cmm->Apply(chanOut, chanIn);
207
208 //chanOut[0] = 0.5*chanOut[0]+0.5;
209
210 if (pMatchInfo->dstSwap)
211 {
212 if (pMatchInfo->dstChanBits==16)
213 {
214 for (int i=0; i<numOut; i++)
215 {
216 UInt16 temp = (UInt16)(chanOut[i]*65535.0+0.5);
217 temp = Endian16_Swap(temp);
218 if (dBuf[i]) *(UInt16*)(dBuf[i] + (r * pMatchInfo->dstRowBytes) + (c * pMatchInfo->dstColBytes)) = temp;
219 }
220 }
221 else
222 {
223 for (int i=0; i<numOut; i++)
224 {
225 if (dBuf[i]) *(UInt16*)(dBuf[i] + (r * pMatchInfo->dstRowBytes) + (c * pMatchInfo->dstColBytes)) = (UInt8)(chanOut[i]*255.0+0.5);
226 }
227 }
228 }
229 else {
230 if (pMatchInfo->dstChanBits==16)
231 {
232 for (int i=0; i<numOut; i++)
233 {
234 if (dBuf[i]) *(UInt16*)(dBuf[i] + (r * pMatchInfo->dstRowBytes) + (c * pMatchInfo->dstColBytes)) = (UInt16)(chanOut[i]*65535.0+0.5);
235 }
236 }
237 else
238 {
239 for (int i=0; i<numOut; i++)
240 {
241 if (dBuf[i]) *(UInt16*)(dBuf[i] + (r * pMatchInfo->dstRowBytes) + (c * pMatchInfo->dstColBytes)) = (UInt8)(chanOut[i]*255.0+0.5);
242 }
243 }
244 }
245 }
246 }
247}

References CMMStorageRec::cmm.

Referenced by CMMMatchBitmap(), and CMMMatchColors().

+ Here is the caller graph for this function:

◆ GetCMMStorage()

static uintptr_t GetCMMStorage ( CMWorldRef  cw)
static
1043{
1044 uintptr_t cmmStorage = (uintptr_t) NULL;
1045
1046 if (cw)
1047 {
1048 CFDataRef data = (CFDataRef) CWColorWorldGetProperty (cw, kCMMSTORAGE);
1049
1050 if (data)
1051 {
1052 cmmStorage = (uintptr_t) CFDataGetBytePtr (data);
1053 }
1054 }
1055
1056 return cmmStorage;
1057}

◆ getIccProfLibProfileFromColorsyncProfile()

CIccProfile * getIccProfLibProfileFromColorsyncProfile ( CMProfileRef  pref)
1283{
1284
1285
1286 CFDataRef data = CMProfileCopyICCData(NULL,pref);
1287
1288 CIccProfile* prof = ReadIccProfile(CFDataGetBytePtr(data),CFDataGetLength(data));
1289
1290 CFRelease(data);
1291
1292 return prof;
1293}
CIccProfile * ReadIccProfile(const icChar *szFilename, bool bUseSubProfile)
Definition IccProfile.cpp:3274

References CIccProfile.

◆ MatchOne_CMYK_Gray()

static void MatchOne_CMYK_Gray ( UInt16 *  chan)
static
521{
522 MatchOne_CMYK_XYZ(chan);
523 MatchOne_XYZ_Gray(chan);
524}

◆ MatchOne_CMYK_LAB()

static void MatchOne_CMYK_LAB ( UInt16 *  chan)
static
476{
477 MatchOne_CMYK_RGB(chan);
478 MatchOne_RGB_LAB(chan);
479}

◆ MatchOne_CMYK_RGB()

static void MatchOne_CMYK_RGB ( UInt16 *  chan)
static
367{
368 chan[0] = 0xFFFF - chan[0];
369 chan[1] = 0xFFFF - chan[1];
370 chan[2] = 0xFFFF - chan[2];
371 chan[0] = (chan[0] > chan[3]) ? (chan[0] - chan[3]) : 0;
372 chan[1] = (chan[1] > chan[3]) ? (chan[1] - chan[3]) : 0;
373 chan[2] = (chan[2] > chan[3]) ? (chan[2] - chan[3]) : 0;
374 chan[3] = 0;
375}

◆ MatchOne_CMYK_XYZ()

static void MatchOne_CMYK_XYZ ( UInt16 *  chan)
static
490{
491 MatchOne_CMYK_RGB(chan);
492 MatchOne_RGB_XYZ(chan);
493}

◆ MatchOne_Gray_CMYK()

static void MatchOne_Gray_CMYK ( UInt16 *  chan)
static
528{
529 chan[3] = chan[0]; // K = gray
530 chan[0] = chan[1] = chan[2] = 0; // CMY = 0
531}

◆ MatchOne_Gray_LAB()

static void MatchOne_Gray_LAB ( UInt16 *  chan)
static
456{
457 chan[1] = chan[2] = 0;
458}

◆ MatchOne_Gray_RGB()

static void MatchOne_Gray_RGB ( UInt16 *  chan)
static
514{
515 chan[3] = chan[1]; // preserve alpha
516 chan[1] = chan[2] = chan[0];
517}

◆ MatchOne_Gray_XYZ()

static void MatchOne_Gray_XYZ ( UInt16 *  chan)
static
435{
436 double X,Y,Z;
437
438 Y = UInt16ToDoub(chan[0]);
439 X = Y * 0.96417;
440 Z = Y * 0.82489;
441
442 chan[0] = DoubToFract(X);
443 chan[1] = DoubToFract(Y);
444 chan[2] = DoubToFract(Z);
445}
#define DoubToFract(x)
Definition RefIccMAXCmm.cpp:116
#define UInt16ToDoub(x)
Definition RefIccMAXCmm.cpp:115

◆ MatchOne_LAB_CMYK()

static void MatchOne_LAB_CMYK ( UInt16 *  chan)
static
483{
484 MatchOne_LAB_RGB(chan);
485 MatchOne_RGB_CMYK(chan);
486}

◆ MatchOne_LAB_Gray()

static void MatchOne_LAB_Gray ( UInt16 *  chan)
static
449{
450#pragma unused (chan)
451 // nothing to do gray = L
452}

◆ MatchOne_LAB_RGB()

static void MatchOne_LAB_RGB ( UInt16 *  chan)
static
469{
470 MatchOne_LAB_XYZ(chan);
471 MatchOne_XYZ_RGB(chan);
472}

◆ MatchOne_LAB_XYZ()

static void MatchOne_LAB_XYZ ( UInt16 *  chan)
static
307{
308#if 0
309 CMXYZColor white;
310 white.X = 31594;
311 white.Y = 32768;
312 white.Z = 27030;
313 CMConvertLabToXYZ( (CMColor*)chan, &white, (CMColor*)chan,1);
314#else
315 double X, Y, Z;
316 double L, a, b;
317 double fx, fy, fz;
318
319 L = UInt16ToDoub(chan[0]) * 100.0;
320 a = UInt16ToDoub(chan[1]) * 256.0 - 128.0;
321 b = UInt16ToDoub(chan[2]) * 256.0 - 128.0;
322
323 fy = (L + 16.0) / 116.0;
324 fx = a / 500.0 + fy;
325 fz = fy - b / 200.0;
326
327 if (fx > 0.20696)
328 X = pow(fx, 3);
329 else
330 X = (fx - 16.0 / 116.0) / 7.787;
331
332 if (fy > 0.20696)
333 Y = pow(fy, 3);
334 else
335 Y = (fy - 16.0 / 116.0) / 7.787;
336
337 if (fz > 0.20696)
338 Z = pow(fz, 3);
339 else
340 Z = (fz - 16.0 / 116.0) / 7.787;
341
342 X *= 0.9642;
343 Z *= 0.8249;
344
345 chan[0] = DoubToFract(X);
346 chan[1] = DoubToFract(Y);
347 chan[2] = DoubToFract(Z);
348#endif
349}

◆ MatchOne_RGB_CMYK()

static void MatchOne_RGB_CMYK ( UInt16 *  chan)
static
353{
354 chan[0] = 0xFFFF - chan[0];
355 chan[1] = 0xFFFF - chan[1];
356 chan[2] = 0xFFFF - chan[2];
357 chan[3] = (chan[0] < chan[1]) ?
358 ( (chan[0] < chan[2]) ? (chan[0]) : (chan[2]) ) :
359 ( (chan[1] < chan[2]) ? (chan[1]) : (chan[2]) );
360 chan[0] -= chan[3];
361 chan[1] -= chan[3];
362 chan[2] -= chan[3];
363}

◆ MatchOne_RGB_Gray()

static void MatchOne_RGB_Gray ( UInt16 *  chan)
static
504{
505 UInt16 alpha;
506 alpha = chan[3]; // preserve alpha
507 MatchOne_RGB_XYZ(chan);
508 MatchOne_XYZ_Gray(chan);
509 chan[1] = alpha; // preserve alpha
510}

◆ MatchOne_RGB_LAB()

static void MatchOne_RGB_LAB ( UInt16 *  chan)
static
462{
463 MatchOne_RGB_XYZ(chan);
464 MatchOne_XYZ_LAB(chan);
465}

◆ MatchOne_RGB_XYZ()

static void MatchOne_RGB_XYZ ( UInt16 *  chan)
static
379{
380 double r,g,b;
381 double X,Y,Z;
382
383 r = UInt16ToDoub(chan[0]);
384 g = UInt16ToDoub(chan[1]);
385 b = UInt16ToDoub(chan[2]);
386
387 // map through 2.2 gamma
388 // r = pow( r, 2.2)
389 // g = pow( g, 2.2)
390 // b = pow( b, 2.2)
391
392 // sRGB phosphors matrix
393 X = (0.418 * r) + (0.363 * g) + (0.183 * b);
394 Y = (0.213 * r) + (0.715 * g) + (0.072 * b);
395 Z = (0.015 * r) + (0.090 * g) + (0.720 * b);
396
397 chan[0] = DoubToFract(X);
398 chan[1] = DoubToFract(Y);
399 chan[2] = DoubToFract(Z);
400}

◆ MatchOne_XYZ_CMYK()

static void MatchOne_XYZ_CMYK ( UInt16 *  chan)
static
497{
498 MatchOne_XYZ_RGB(chan);
499 MatchOne_RGB_CMYK(chan);
500}

◆ MatchOne_XYZ_Gray()

static void MatchOne_XYZ_Gray ( UInt16 *  chan)
static
429{
430 chan[0] = FractToUInt16(chan[1]); // gray = Y
431}
#define FractToUInt16(x)
Definition RefIccMAXCmm.cpp:119

◆ MatchOne_XYZ_LAB()

static void MatchOne_XYZ_LAB ( UInt16 *  chan)
static
256{
257#if 0
258 CMXYZColor white;
259 white.X = 31594;
260 white.Y = 32768;
261 white.Z = 27030;
262 CMConvertXYZToLab( (CMColor*)chan, &white, (CMColor*)chan,1);
263#else
264 double X, Y, Z;
265 double L, a, b;
266 double fx, fy, fz;
267
268 X = FractToDoub(chan[0]);
269 Y = FractToDoub(chan[1]);
270 Z = FractToDoub(chan[2]);
271
272 // Assume XYZ white is D50
273 X /= 0.9642;
274 Z /= 0.8249;
275
276 if (X > 0.008856)
277 fx = pow(X, 0.3333);
278 else
279 fx = 7.787 * X + 16.0 / 116.0;
280
281 if (Y > 0.008856)
282 fy = pow(Y, 0.3333);
283 else
284 fy = 7.787 * Y + 16.0 / 116.0;
285
286 if (Z > 0.008856)
287 fz = pow(Z, 0.3333);
288 else
289 fz = 7.787 * Z + 16.0 / 116.0;
290
291 L = 116.0 * fy - 16;
292 a = 500.0 * (fx - fy);
293 b = 200.0 * (fy - fz);
294
295 L = L / 100.0;
296 a = (a + 128.0) / 256.0;
297 b = (b + 128.0) / 256.0;
298
299 chan[0] = DoubToUInt16(L);
300 chan[1] = DoubToUInt16(a);
301 chan[2] = DoubToUInt16(b);
302#endif
303}
#define DoubToUInt16(x)
Definition RefIccMAXCmm.cpp:114
#define FractToDoub(x)
Definition RefIccMAXCmm.cpp:117

◆ MatchOne_XYZ_RGB()

static void MatchOne_XYZ_RGB ( UInt16 *  chan)
static
404{
405 double r,g,b;
406 double X,Y,Z;
407
408 X = FractToDoub(chan[0]);
409 Y = FractToDoub(chan[1]);
410 Z = FractToDoub(chan[2]);
411
412 // sRGB phosphors inverse matrix
413 r = ( 3.202 * X) + (-1.543 * Y) + (-0.660 * Z);
414 g = (-0.959 * X) + ( 1.879 * Y) + ( 0.056 * Z);
415 b = ( 0.053 * X) + (-0.203 * Y) + ( 1.396 * Z);
416
417 // map through inverse of 2.2 gamma
418 // r = pow( r, 1.0 / 2.2)
419 // g = pow( g, 1.0 / 2.2)
420 // b = pow( b, 1.0 / 2.2)
421
422 chan[0] = DoubToUInt16(r);
423 chan[1] = DoubToUInt16(g);
424 chan[2] = DoubToUInt16(b);
425}

◆ NCMMConcatInit()

CMError NCMMConcatInit ( uintptr_t *  cmmRefcon,
NCMConcatProfileSet *  profileSet,
CMConcatCallBackUPP  proc,
void *  refCon 
)
693{
694 CMProfileRef srcProf = profileSet->profileSpecs[0].profile;
695 CMProfileRef dstProf = profileSet->profileSpecs[profileSet->profileCount-1].profile;
696
697 UInt32 srcTransform = profileSet->profileSpecs[0].transformTag;
698 UInt32 dstTransform = profileSet->profileSpecs[profileSet->profileCount-1].transformTag;
699
700 return DoInitSampleICC((CMMStoragePtr)*cmmRefcon, profileSet);
701}
static CMError DoInitSampleICC(CMMStoragePtr storage, NCMConcatProfileSet *profileSet)
Definition RefIccMAXCmm.cpp:594

◆ NCMMInit()

CMError NCMMInit ( uintptr_t *  cmmRefcon,
CMProfileRef  srcProf,
CMProfileRef  dstProf 
)
676{
677 return DoInit((CMMStoragePtr)*cmmRefcon, srcProf, dstProf, kDeviceToPCS, kPCSToDevice);
678}

Variable Documentation

◆ cmmAllocator

CFAllocatorRef cmmAllocator = NULL
static

Referenced by CMMBytesDeallocator().

◆ context

const CFAllocatorContext context
static
Initial value:
= {
0,
NULL,
NULL,
NULL,
NULL,
NULL
}
static void cmmdeallocate(void *ptr, void *info)
Definition RefIccMAXCmm.cpp:1178
static void * cmmallocate(CFIndex size, CFOptionFlags hint, void *info)
Definition RefIccMAXCmm.cpp:1166
static void * cmmreallocate(void *ptr, CFIndex size, CFOptionFlags hint, void *info)
Definition RefIccMAXCmm.cpp:1172
1188 {
1189 0,
1190 NULL,
1191 NULL,
1192 NULL,
1193 NULL,
1197 NULL
1198};