Creating an ICC profile

The following steps create a new ICC profile, and add to it three tags. The first tag will be created from scratch; the second one will be taken from another existing ICC profile, modified, and then added to the new ICC profile. The final tag will be taken from another ICC profile and added without modifications to the new ICC profile.

1.

Define the following variables:

   SYSTEMTIME            sysTime;
   ICCTAG_DATE_TIME_TYPE iccDateTimeTagType; 
   ICCTAG_XYZ_TYPE       iccXyzTagType; 
   ICCTAG_SIGNATURE_TYPE iccSignatureTagType; 

   LICCProfile oldIccProfile; 
   LICCProfile newIccProfile;

 

2.

Initialize both the new ICC profile to be created (newIccProfile), and the already existing one (oldIccProfile):

 

   LBase :: LoadLibraries(LT_CLR); 
   oldIccProfile.Initialize();
   newIccProfile.Initialize();

3.

Fill the oldIccProfile structure as an existing ICC profile from a specific file:

   oldIccProfile.Fill(TEXT("d:\\ICCv42.icc"));

4.

Initialize the header of the new ICC Profile:

   newIccProfile.InitHeader();

5.

Copy the header of the existing ICC profile as it is in the header of the new ICC profile:

   newIccProfile.SetCMMType(oldIccProfile.GetProfile()->pIccHeader->nCmmID); 
   newIccProfile.SetDeviceClass((tagICCPROFILECLASS)oldIccProfile.GetProfile()->pIccHeader->uDeviceClass); 
   newIccProfile.SetColorSpace((tagICCCOLORSPACE)oldIccProfile.GetProfile()->pIccHeader->uColorSpace); 
   newIccProfile.SetConnectionSpace((tagICCCOLORSPACE)oldIccProfile.GetProfile()->pIccHeader->uPCS); 
   newIccProfile.SetDateTime(&oldIccProfile.GetProfile()->pIccHeader->DateTime); 
   newIccProfile.SetPrimaryPlatform((tagICCPLATFORMSIGNATURE)oldIccProfile.GetProfile()->pIccHeader->uPlatform); 
   newIccProfile.SetFlags(oldIccProfile.GetProfile()->pIccHeader->uFlags); 
   newIccProfile.SetDevManufacturer(oldIccProfile.GetProfile()->pIccHeader->nManufacturer); 
   newIccProfile.SetDevModel(oldIccProfile.GetProfile()->pIccHeader->uModel); 
   newIccProfile.SetDeviceAttributes(oldIccProfile.GetProfile()->pIccHeader->uAttributes); 
   newIccProfile.SetRenderingIntent((ICCRENDERINGINTENT)oldIccProfile.GetProfile()->pIccHeader->uRenderingIntent); 
   newIccProfile.SetCreator(oldIccProfile.GetProfile()->pIccHeader->nCreator); 

   newIccProfile.GetProfile()->pIccHeader->uVersion = oldIccProfile.GetProfile()->pIccHeader->uVersion; 

6.

Create the first tag from scratch and call it calibrationDateTimeTag, fill it with the current system time, then insert it into the new ICC profile:

 

   memset(&iccDateTimeTagType, 0, sizeof(ICCTAG_DATE_TIME_TYPE)); 
   GetSystemTime(&sysTime); 
   iccDateTimeTagType.DateTime.uYear    = sysTime.wYear; 
   iccDateTimeTagType.DateTime.uMonth   = sysTime.wMonth; 
   iccDateTimeTagType.DateTime.uDay     = sysTime.wDay; 
   iccDateTimeTagType.DateTime.uHours   = sysTime.wHour; 
   iccDateTimeTagType.DateTime.uMinutes = sysTime.wMinute; 
   iccDateTimeTagType.DateTime.uSeconds = sysTime.wSecond; 

   newIccProfile.SetTagData((L_UCHAR L_FAR *) &iccDateTimeTagType, CalibrationDateTimeTag, DateTimeTypeSig);

 

7.

The second tag is called the mediaWhitePointTag, and it will be gotten from the already existing ICC profile, then change its values into random values that don't have to have a useful meaning, and finally insert it into the new ICC profile:

 

   // get mediaWhitePointTag tag from the excising ICC profile 
   oldIccProfile.GetTagData((L_UCHAR L_FAR *) &iccXyzTagType,  MediaWhitePointTag); 

   // change it's values
   iccXyzTagType.pXYZNumData[0].nX = LICCProfile :: ConvertDoubleTo2bFixed2bNumber(0.123); 
   iccXyzTagType.pXYZNumData[0].nY = LICCProfile :: ConvertDoubleTo2bFixed2bNumber(0.456); 
   iccXyzTagType.pXYZNumData[0].nZ = LICCProfile :: ConvertDoubleTo2bFixed2bNumber(0.789); 

   // insert it in the new ICC profile
   newIccProfile.SetTagData((L_UCHAR L_FAR *) &iccXyzTagType, MediaWhitePointTag, XYZTypeSig); 

8.

The third tag is called the technologyTag, and it will be gotten from the already existing ICC profile, then insert it into the new ICC profile without modifying its values.

 

   // get the technologyTag
   oldIccProfile.GetTagData((L_UCHAR L_FAR *) &iccSignatureTagType, TechnologyTag); 

   // insert it in the new ICC profile
   newIccProfile.SetTagData((L_UCHAR L_FAR *) &iccSignatureTagType, TechnologyTag, SignatureTypeSig); 

9.

Generate the pData pointer of the new ICC profile and create the new ICC profile:

 

   // Generate the pData Pointer
   newIccProfile.GeneratePointer();

   // Create the ICC file
   newIccProfile.GenerateFile(TEXT("d:\\NewICCv42.icc"));

10.

Finally, free the handles of the existing and newly created ICC profiles:

   oldIccProfile.Free();
   newIccProfile.Free();

   LBase :: UnloadLibraries(LT_CLR);