Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.11.10
|
Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.ColorConversion[C#]
using Leadtools; using Leadtools.Codecs; using Leadtools.ColorConversion;
'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");