←Select platform

IccLookupTableAToBTagType Class

Summary
Contains the lutAToBType tag type data.
Syntax
C#
VB
C++
public class IccLookupTableAToBTagType : IccTagTypeBase 
  
Public Class IccLookupTableAToBTagType  
   Inherits IccTagTypeBase 
public ref class IccLookupTableAToBTagType : public IccTagTypeBase  
Remarks
Example

This example method can be used in creating an "lutAtoBType" mentioned in the ICC.1:2004-10 specification. The following information is used: input channels = 3, output channels = 1.

C#
VB
using Leadtools; 
using Leadtools.ColorConversion; 
 
 
public IccCurveTagType FillIccCurveTagType() 
{ 
   ushort[] curveData = new ushort[1]; 
 
   curveData[0] = IccTools.FromDoubleToU8Fixed8Number(1.5); 
   IccCurve iccCurve = new IccCurve(curveData); 
   IccCurveTagType iccCurveTagType = new IccCurveTagType(iccCurve); 
 
   return iccCurveTagType; 
} 
 
public IccParametricCurveTagType FillIccParametricCurveTagType() 
{ 
   int[] parameters = new int[1]; 
 
   parameters[0] = IccTools.FromDoubleTo2bFixed2bNumber(5.0); 
   IccParametricCurve parametricCurve = new IccParametricCurve(IccFunctionsType.Function4Bytes, parameters); 
   IccParametricCurveTagType parametricCurveTagType = new IccParametricCurveTagType(parametricCurve); 
 
   return parametricCurveTagType; 
} 
 
 
public void IccLookupTableAToBTagTypeExample() 
{ 
   // load an Icc Profile 
   string fileName = Path.Combine(LEAD_VARS.ImagesDir, "EmptyIcc.icc"); 
   IccProfileExtended iccProfile = new IccProfileExtended(fileName); 
 
   // "B Curves" should be of the same number as Output Channels 
   // They can be either IccTagCurveType or IccTagResponseCurveType 
   // fill the tag 
   IccCurveTagType[] iccCurveType = new IccCurveTagType[1]; 
   iccCurveType[0] = FillIccCurveTagType(); 
 
   // define the "Matrix" 
   int[] element = new int[12] {IccTools.FromDoubleTo2bFixed2bNumber(1.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(2.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(3.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(4.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(5.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(6.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(7.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(8.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(9.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(10.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(11.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(12.0)}; 
 
   IccMatrix iccMatrix = new IccMatrix(element); 
 
   // "M Curves" should be of the same number as Output Channels 
   // They can be either IccCurve or IccResponseCurve 
   // fill the tag 
   IccParametricCurveTagType[] iccParametricCurveType = new IccParametricCurveTagType[1]; 
   iccParametricCurveType[0] = FillIccParametricCurveTagType(); 
 
   // define the CLUT 
   IccColorLookupTable8Bit iccCLUT8 = new IccColorLookupTable8Bit(); 
   // only the first i entries are used, where i is the number of input channels 
   iccCLUT8.NumberOfGridPoints[0] = 1; 
   iccCLUT8.NumberOfGridPoints[1] = 2; 
   iccCLUT8.NumberOfGridPoints[2] = 3; 
   // the percision that determins if we are using IccColorLookupTable  
   // 8Bit or 16Bit, 1 for 8-bit, and 2 for 16-bit 
   iccCLUT8.Precision = 1; 
   // and then the padding bytes 
   iccCLUT8.Pad[0] = 0; 
   iccCLUT8.Pad[1] = 0; 
   iccCLUT8.Pad[2] = 0; 
   // and finally the CLUT data points (arranged as described in the text in  
   // ICC.1:2004-10 specification, page 48 
   // The size of the data array is: multiplication of all the cells in the numberOfGridPoints array 
   // 1 * 2 * 3 * 1 (number of output channel) * 1 (Percision) = 6 
   iccCLUT8.Data = new Byte[6]; 
   iccCLUT8.Data[0] = 3; 
   iccCLUT8.Data[1] = 4; 
   iccCLUT8.Data[2] = 5; 
   iccCLUT8.Data[3] = 6; 
   iccCLUT8.Data[4] = 7; 
   iccCLUT8.Data[5] = 8; 
 
   // "A Curves" should be of the same number as Input Channels 
   // They can be either IccCurve or IccResponseCurve 
   // fill the tags 
   IccCurveTagType[] iccCurveTypeA = new IccCurveTagType[3]; 
   iccCurveTypeA[0] = FillIccCurveTagType(); 
   iccCurveTypeA[1] = FillIccCurveTagType(); 
   iccCurveTypeA[2] = FillIccCurveTagType(); 
 
   // The data pointer will contain all the curve buffers in a sequential order,  
   // the offset of the start of each curve buffer will be saved into the  
   // appropriate offset variable in the class 
   // the data pointer will be created automatically inside the toolkit when 
   // the IccProfile.SetICCTagData() method is called 
 
   // define the tag type 
   IccLookupTableAToBTagType iccLUTAtoB = new IccLookupTableAToBTagType( 
      3,    // input channels 
      1,    // output channels 
      iccCurveType, 
      iccParametricCurveType, 
      iccCurveTypeA, 
      iccCLUT8, 
      iccMatrix); 
 
   // add the new tag to the ICC Profile 
   iccProfile.AddTag(iccLUTAtoB, IccTag.AToB2Tag, IccTagTypeBase.LutAtoBTypeSignature); 
 
   // generate the new profile id 
   iccProfile.GenerateProfileId(); 
 
   // update the icc array with the new changes 
   iccProfile.UpdateDataArray(); 
 
   // write the Icc Profile into a new file 
   string IccfileName = Path.Combine(LEAD_VARS.ImagesDir, "IccLookupTableAToBTagTypeCS.icc"); 
   iccProfile.GenerateIccFile(IccfileName); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Imports Leadtools 
Imports Leadtools.ColorConversion 
 
Public Function FillIccCurveTagType() As IccCurveTagType 
   Dim myDoubleValue As Double = 1.5 
 
   Dim curveData(0) As UShort 
   curveData(0) = New UShort() 
   curveData(0) = IccTools.FromDoubleToU8Fixed8Number(myDoubleValue) 
 
   myDoubleValue = IccTools.FromU8Fixed8NumberToDouble(curveData(0)) 
   Dim iccCurve As New IccCurve(curveData) 
   Dim iccCurveTagType As New IccCurveTagType(iccCurve) 
 
   Return iccCurveTagType 
End Function 
 
Public Function FillIccParametricCurveTagType() As IccParametricCurveTagType 
   Dim parameters() As Integer = {IccTools.FromDoubleTo2bFixed2bNumber(5.0)} 
   Dim parametricCurve As New IccParametricCurve(IccFunctionsType.Function4Bytes, parameters) 
   Dim parametricCurveTagType As New IccParametricCurveTagType(parametricCurve) 
 
   Return parametricCurveTagType 
End Function 
 
Public Sub IccLookupTableAToBTagTypeExample() 
   ' load an Icc Profile 
   Dim iccProfile As New IccProfileExtended(Path.Combine(LEAD_VARS.ImagesDir, "EmptyIcc.icc")) 
 
   ' "B Curves" should be of the same number as Output Channels 
   ' They can be either IccTagCurveType or IccTagResponseCurveType fill the tag 
   Dim iccCurveType() As IccCurveTagType = {FillIccCurveTagType()} 
 
   ' define the "Matrix" 
   Dim element() As Integer = {IccTools.FromDoubleTo2bFixed2bNumber(1.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(2.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(3.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(4.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(5.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(6.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(7.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(8.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(9.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(10.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(11.0), 
      IccTools.FromDoubleTo2bFixed2bNumber(12.0)} 
 
   Dim iccMatrix As New IccMatrix(element) 
 
   ' "M Curves" should be of the same number as Output Channels 
   ' They can be either IccCurve or IccResponseCurve 
   ' fill the tag 
   Dim iccParametricCurveType() As IccParametricCurveTagType = {FillIccParametricCurveTagType()} 
 
   ' define the CLUT 
   Dim iccCLUT8 As New IccColorLookupTable8Bit() 
   ' only the first i entries are used, where i is the number of input channels 
   iccCLUT8.NumberOfGridPoints(0) = 1 
   iccCLUT8.NumberOfGridPoints(1) = 2 
   iccCLUT8.NumberOfGridPoints(2) = 3 
   ' the percision that determins if we are using IccColorLookupTable  
   ' 8Bit or 16Bit, 1 for 8-bit, and 2 for 16-bit 
   iccCLUT8.Precision = 1 
   ' and then the padding bytes 
   iccCLUT8.Pad(0) = 0 
   iccCLUT8.Pad(1) = 0 
   iccCLUT8.Pad(2) = 0 
   ' and finally the CLUT data points (arranged as described in the text in  
   ' ICC.1:2004-10 specification, page 48 
   ' The size of the data array is: multiplication of all the cells in the numberOfGridPoints array 
   ' 1 * 2 * 3 * 1 (number of output channel) * 1 (Percision) = 6 
   ReDim iccCLUT8.Data(5) 
   iccCLUT8.Data(0) = 3 
   iccCLUT8.Data(1) = 4 
   iccCLUT8.Data(2) = 5 
   iccCLUT8.Data(3) = 6 
   iccCLUT8.Data(4) = 7 
   iccCLUT8.Data(5) = 8 
 
   ' "A Curves" should be of the same number as Input Channels 
   ' They can be either IccCurve or IccResponseCurve 
   ' fill the tags 
   Dim iccCurveTypeA() As IccCurveTagType = {FillIccCurveTagType(), 
      FillIccCurveTagType(), 
      FillIccCurveTagType()} 
 
   ' The data pointer will contain all the curve buffers in a sequential order,  
   ' the offset of the start of each curve buffer will be saved into the  
   ' appropriate offset variable in the class 
   ' the data pointer will be created automatically inside the toolkit when 
   ' the IccProfile.SetICCTagData() method is called 
 
   ' define the tag type 
   Dim iccLUTAtoB As New IccLookupTableAToBTagType(3, 
         1, 
         iccCurveType, 
         iccParametricCurveType, 
         iccCurveTypeA, 
         iccCLUT8, 
         iccMatrix) 
 
   ' add the new tag to the ICC Profile 
   iccProfile.AddTag(iccLUTAtoB, IccTag.AToB2Tag, IccTagTypeBase.LutAtoBTypeSignature) 
 
   ' generate the new profile id 
   iccProfile.GenerateProfileId() 
 
   ' update the icc array with the new changes 
   iccProfile.UpdateDataArray() 
 
   ' write the Icc Profile into a new file 
   iccProfile.GenerateIccFile(Path.Combine(LEAD_VARS.ImagesDir, "IccLookupTableAToBTagTypeVB.icc")) 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images" 
End Class 
Requirements

Target Platforms

Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ColorConversion Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.