Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
Creating an ICC Profile
The following steps create a new ICC profile, and add to it 3 tags. The first tag will be created from scratch. The second one will be taken from an existing ICC profile, modified and then added to the new ICC profile. The final tag will be taken from an existing ICC profile and added to the new ICC profile without modifications.
  1. Start Microsoft Visual Studio 2005.
  2. Choose File->New->Project… from the menu.
  3. In the New Project dialog box, choose Other Languages from the Project Types list, then choose either "Visual C#" or "Visual Basic" in the, and then choose "Windows Application" in the Templates List.
  4. Type the project name as "Creating an ICC Profile" in the Name field, and then choose OK. If desired, type a new location for your project or select a directory using the Browse button, and then choose OK.
  5. In the "Solution Explorer" window, right-click on "Creating an ICC Profile" project, and select "Add Reference…" from the context menu. In the "Add Reference" dialog box, select the "Browse" tab and browse to the "LEAD Technologies\LEADTOOLS 16.5\Bin\Dotnet\Win32" folder and select the following DLLs:
    • Leadtools.dll
    • Leadtools.Codecs.dll
    • Leadtools.ColorConversion.dll
    and then click the OK button to add the above DLLs to the application.
  6. Make sure Form1 is in design view. From the toolbox (View->Toolbox), add a Button control (Text = "ICC").
  7. Switch to Form1 code view (right-click Form1 in the solution explorer then select View Code ) and add the following lines at the beginning of the file:

    [Visual Basic]

    
    Imports Leadtools
    Imports Leadtools.Codecs
    Imports Leadtools.ColorConversion
    
    [C#]
    
    using Leadtools;
    using Leadtools.Codecs;
    using Leadtools.ColorConversion;
    
  8. double-click the button1 Button on the form to add the event handler for it and add the following code:

    [Visual Basic]

    
    'Fill the oldIccProfile structure as an existing ICC profile from a specific file:
    Dim oldIccProfile As New IccProfileExtended("C:\Users\Public\Documents\LEADTOOLS Images\ICCv42.icc")
    
    'Copy the header of the existing ICC profile as it is in the header of the new ICC profile:
    Dim header As IccHeader = IccHeader.Empty
    header.CmmID = oldIccProfile.Header.CmmID
    header.Version = oldIccProfile.Header.Version
    header.DeviceClass = oldIccProfile.Header.DeviceClass
    header.ColorSpace = oldIccProfile.Header.ColorSpace
    header.Pcs = oldIccProfile.Header.Pcs
    header.DateTime = oldIccProfile.Header.DateTime
    header.ProfileSignature = oldIccProfile.Header.ProfileSignature
    header.Platform = oldIccProfile.Header.Platform
    header.Flags = oldIccProfile.Header.Flags
    header.Manufacturer = oldIccProfile.Header.Manufacturer
    header.Model = oldIccProfile.Header.Model
    header.Attributes = oldIccProfile.Header.Attributes
    header.RenderingIntent = oldIccProfile.Header.RenderingIntent
    header.Illuminant = oldIccProfile.Header.Illuminant
    header.Creator = oldIccProfile.Header.Creator
    
    'Create tag #1 and call it calibrationDateTimeTag, fill it with the current system time, then insert
    'it into the new ICC profile:
    
    ' define the systemDateTime class and get the current date and time
    Dim systemDateTime As System.DateTime = System.DateTime.Now
    
    Dim dateTimeType As New IccDateTime(CShort(systemDateTime.Year), CShort(systemDateTime.Month), CShort(systemDateTime.Day), CShort(systemDateTime.Hour), CShort(systemDateTime.Minute), CShort(systemDateTime.Second))
    Dim dateTimeTagType As New IccDateTimeTagType(dateTimeType)
    
    ' add the date/time to the header
    header.DateTime = dateTimeType
    
    ' create the new ICC Profile, and add the header to it
    Dim newIccProfile As New IccProfileExtended()
    newIccProfile.Header = header
    
    ' Now insert the tag into the new ICC profile   
    newIccProfile.AddTag(dateTimeTagType, IccTag.CalibrationDateTimeTag, IccTagTypeBase.DateTimeTypeSignature)
    
    'Tag #2 is called the mediaWhitePointTag, and it will be copied from the existing ICC profile, then
    'modified with random values that have no useful meaning, and finally inserted into the new ICC profile:
    
    ' get mediaWhitePoint tag from the old ICC profile and modify it
    Dim xyzTagType As New IccXyzTagType()
    xyzTagType = CType(oldIccProfile.GetTag(IccTag.MediaWhitePointTag), IccXyzTagType)
    
    xyzTagType.Data(0).X = IccTools.FromDoubleTo2bFixed2bNumber(0.123)
    xyzTagType.Data(0).Y = IccTools.FromDoubleTo2bFixed2bNumber(0.456)
    xyzTagType.Data(0).Z = IccTools.FromDoubleTo2bFixed2bNumber(0.789)
    
    ' insert it in the new ICC profile
    newIccProfile.AddTag(xyzTagType, IccTag.MediaWhitePointTag, IccTagTypeBase.XyzTypeSignature)
    
    ' Tag #3 is called the technologyTag, and it will be copied from the existing ICC profile, and inserted
    ' into the new ICC profile without modifying its values.
    
    ' get the technologyTag and keep it as it is
    Dim signatureTagType As IccSignatureTagType = CType(oldIccProfile.GetTag(IccTag.TechnologyTag), IccSignatureTagType)
    newIccProfile.AddTag(signatureTagType, IccTag.TechnologyTag, IccTagTypeBase.SignatureTypeSignature)
    
    ' Generate the Data member of the new ICC profile and create the new ICC profile:
    ' finally generate the new ICC file
    newIccProfile.GenerateProfileId()
    newIccProfile.UpdateDataArray()
    newIccProfile.GenerateIccFile("C:\Users\Public\Documents\LEADTOOLS Images\NewICCv42VB.icc")
    
    [C#]
    
    //Fill the oldIccProfile structure as an existing ICC profile from a specific file:
    IccProfileExtended oldIccProfile = new IccProfileExtended(@"C:\Users\Public\Documents\LEADTOOLS Images\ICCv42.icc");
    
    //Copy the header of the existing ICC profile as it is in the header of the new ICC profile:
    IccHeader header = IccHeader.Empty;
    header.CmmID = oldIccProfile.Header.CmmID;
    header.Version = oldIccProfile.Header.Version;
    header.DeviceClass = oldIccProfile.Header.DeviceClass;
    header.ColorSpace = oldIccProfile.Header.ColorSpace;
    header.Pcs = oldIccProfile.Header.Pcs;
    header.DateTime = oldIccProfile.Header.DateTime;
    header.ProfileSignature = oldIccProfile.Header.ProfileSignature;
    header.Platform = oldIccProfile.Header.Platform;
    header.Flags = oldIccProfile.Header.Flags;
    header.Manufacturer = oldIccProfile.Header.Manufacturer;
    header.Model = oldIccProfile.Header.Model;
    header.Attributes = oldIccProfile.Header.Attributes;
    header.RenderingIntent = oldIccProfile.Header.RenderingIntent;
    header.Illuminant = oldIccProfile.Header.Illuminant;
    header.Creator = oldIccProfile.Header.Creator;
    
    //Create tag #1 and call it calibrationDateTimeTag, fill it with the current system time, then insert
    //it into the new ICC profile:
    
    // define the systemDateTime class and get the current date and time
    System.DateTime systemDateTime = System.DateTime.Now;
    
    IccDateTime dateTimeType = new IccDateTime((ushort)systemDateTime.Year, (ushort)systemDateTime.Month, (ushort)systemDateTime.Day, (ushort)systemDateTime.Hour, (ushort)systemDateTime.Minute, (ushort)systemDateTime.Second);
    IccDateTimeTagType dateTimeTagType = new IccDateTimeTagType(dateTimeType);
    
    // add the date/time to the header
    header.DateTime = dateTimeType;
    
    // create the new ICC Profile, and add the header to it
    IccProfileExtended newIccProfile = new IccProfileExtended();
    newIccProfile.Header = header;
    
    // Now insert the tag into the new ICC profile   
    newIccProfile.AddTag(dateTimeTagType, IccTag.CalibrationDateTimeTag, IccTagTypeBase.DateTimeTypeSignature);
    
    //Tag #2 is called the mediaWhitePointTag, and it will be copied from the existing ICC profile, then
    //modified with random values that have no useful meaning, and finally inserted into the new ICC profile:
    
    // get mediaWhitePoint tag from the old ICC profile and modify it
    IccXyzTagType xyzTagType = new IccXyzTagType();
    xyzTagType = (IccXyzTagType)oldIccProfile.GetTag(IccTag.MediaWhitePointTag);
    
    xyzTagType.Data[0].X = IccTools.FromDoubleTo2bFixed2bNumber(0.123);
    xyzTagType.Data[0].Y = IccTools.FromDoubleTo2bFixed2bNumber(0.456);
    xyzTagType.Data[0].Z = IccTools.FromDoubleTo2bFixed2bNumber(0.789);
    
    // insert it in the new ICC profile
    newIccProfile.AddTag(xyzTagType, IccTag.MediaWhitePointTag, IccTagTypeBase.XyzTypeSignature);
    
    //Tag #3 is called the technologyTag, and it will be copied from the existing ICC profile, and inserted
    //into the new ICC profile without modifying its values.
    
    // get the technologyTag and keep it as it is
    IccSignatureTagType signatureTagType = (IccSignatureTagType)oldIccProfile.GetTag(IccTag.TechnologyTag);
    newIccProfile.AddTag(signatureTagType, IccTag.TechnologyTag, IccTagTypeBase.SignatureTypeSignature);
    
    //Generate the Data member of the new ICC profile and create the new ICC profile:
    // finally generate the new ICC file
    newIccProfile.GenerateProfileId();
    newIccProfile.UpdateDataArray();
    newIccProfile.GenerateIccFile(@"C:\Users\Public\Documents\LEADTOOLS Images\NewICCv42CS.icc");
    
  9. Build, and Run the program to test it.