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.
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 "C:\LEADTOOLS 20\Bin\Dotnet\Win32" folder and select the following DLLs:
and then click the OK button to add the above DLLs to the application.
Make sure Form1 is in design view. From the toolbox (View->Toolbox), add a Button control (Text = "ICC").
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:
Imports LeadtoolsImports Leadtools.CodecsImports Leadtools.ColorConversion
using Leadtools;using Leadtools.Codecs;using Leadtools.ColorConversion;
double-click the button1 Button on the form to add the event handler for it and add the following code:
'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.Emptyheader.CmmID = oldIccProfile.Header.CmmIDheader.Version = oldIccProfile.Header.Versionheader.DeviceClass = oldIccProfile.Header.DeviceClassheader.ColorSpace = oldIccProfile.Header.ColorSpaceheader.Pcs = oldIccProfile.Header.Pcsheader.DateTime = oldIccProfile.Header.DateTimeheader.ProfileSignature = oldIccProfile.Header.ProfileSignatureheader.Platform = oldIccProfile.Header.Platformheader.Flags = oldIccProfile.Header.Flagsheader.Manufacturer = oldIccProfile.Header.Manufacturerheader.Model = oldIccProfile.Header.Modelheader.Attributes = oldIccProfile.Header.Attributesheader.RenderingIntent = oldIccProfile.Header.RenderingIntentheader.Illuminant = oldIccProfile.Header.Illuminantheader.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 timeDim systemDateTime As System.DateTime = System.DateTime.NowDim 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 headerheader.DateTime = dateTimeType' create the new ICC Profile, and add the header to itDim newIccProfile As New IccProfileExtended()newIccProfile.Header = header' Now insert the tag into the new ICC profilenewIccProfile.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 itDim 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 profilenewIccProfile.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 isDim 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 filenewIccProfile.GenerateProfileId()newIccProfile.UpdateDataArray()newIccProfile.GenerateIccFile("C:\Users\Public\Documents\LEADTOOLS Images\NewICCv42VB.icc")
//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 timeSystem.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 headerheader.DateTime = dateTimeType;// create the new ICC Profile, and add the header to itIccProfileExtended newIccProfile = new IccProfileExtended();newIccProfile.Header = header;// Now insert the tag into the new ICC profilenewIccProfile.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 itIccXyzTagType 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 profilenewIccProfile.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 isIccSignatureTagType 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 filenewIccProfile.GenerateProfileId();newIccProfile.UpdateDataArray();newIccProfile.GenerateIccFile(@"C:\Users\Public\Documents\LEADTOOLS Images\NewICCv42CS.icc");