Emulation Tables (Visual Basic)

The LEAD Color Conversion toolkit provides emulation tables as one of its conversion methods. This method however is provided only for the following conversions:

The Emulation tables' method supports both built-in and custom options. For built-in emulation tables, use the USE_ET option. The custom emulation tables' option, USE_CUSTOM_ET, provides custom conversion using user-supplied images, converted from the source images distributed with the library by any tool, as follows:

Conversion Source Convert to
CMYK to RGB src_cmyk_image.tif RGB image (i.e. dst_cmyk2rgb_image.tif)
RGB to Lab src_rgb_image.tif Lab image ( i.e. dst_rgb2lab_image.tif)
Lab to RGB src_lab_image.tif RGB image (i.e. dst_lab2rgb_image.tif)

A set of images, already converted and ready for use (dst_cmyk2rgb_image.tif, dst_rgb2lab_image.tif, and dst_lab2rgb_image.tif), is provided. However, using the provided set of converted images will produce the same results as the built-in emulation tables.

The code below shows how a conversion can be done using the built-in tables:

Function Tables_Convert_CMYKToRGB(RGBData() As Byte, LABData() As Byte, nWidth As Integer, nHeight As Integer, nInAlign As Integer, nOutAlign As Integer) As Integer 
    'This function converts an RGB24 image to LAB using built-in emulation tables. 
    '-RGBData: pointer to the input RGB data. 
    '-LABData: pointer to the output LAB beffer 
    '-nWidth: width of the passed image. 
    '-nHeight: height of the passed image. 
    '-nInAlign: input buffer alignment. 
    '-nOutAlign: output buffer alignment. 
    Dim ClrHandle As Long 'color handle 
    Dim cnvParam As CONVERSION_PARAMS 'conversion params 
    Dim ret As Integer 'return value 
    'initialize the conversion structure 
    cnvParam.uStructSize = Len(cnvParam) 
    cnvParam.nQuantization = 8 
    cnvParam.nMethod = USE_ET 
    cnvParam.nActiveMethod = USE_ET 
    cnvParam.pCmykParams = 0 
    cnvParam.pLabParams = 0 
    cnvParam.pYuvParams = 0 
    cnvParam.sDstInputTable(0) = 0 
    cnvParam.sInputProfile(0) = 0 
    cnvParam.sOutputProfile(0) = 0 
    'initialize the conversion engine 
    ret = L_ClrInit (ClrHandle, CCS_RGB, CCS_LAB, cnvParam) 
    'do we have a valid handle 
    If (ret = SUCCESS) Then 
       'do the conversion from RGB to CIELab 
       ret = L_ClrConvert (ClrHandle, RGBData(0), LABData(0), nWidth, nHeight, nInAlign, nOutAlign) 
       If (ret <> SUCCESS) Then 
          MsgBox "Failed to convert from RGB to LAB" 
          Tables_Convert_CMYKToRGB = ret 
       End If 
       'do not forget to free every thing 
       L_ClrFree (ClrHandle) 
    Else 
       MsgBox "Failed to initialize LTCLR" 
       Tables_Convert_CMYKToRGB = ret 
    End If 
 End Function 

The code below shows how a conversion can be done using user-defined tables:

Function Tables_Convert_CMYKToRGB(RGBData() As Byte, LABData() As Byte, nWidth As Integer, nHeight As Integer, nInAlign As Integer, nOutAlign As Integer, strDst As String) As Integer 
    'This function converts an RGB24 image to LAB using built-in emulation tables. 
    '-RGBData: pointer to the input RGB data. 
    '-LABData: pointer to the output LAB beffer 
    '-nWidth: width of the passed image. 
    '-nHeight: height of the passed image. 
    '-nInAlign: input buffer alignment. 
    '-nOutAlign: output buffer alignment. 
    '-strDst: destination custom table. 
    Dim ClrHandle As Long 'color handle 
    Dim cnvParam As CONVERSION_PARAMS 'conversion params 
    Dim ret As Integer 'return value 
    Dim i As Integer 
    'initialize the conversion structure 
    cnvParam.uStructSize = Len(cnvParam) 
    cnvParam.nQuantization = 8 
    cnvParam.nMethod = USE_CUSTOM_ET 
    cnvParam.nActiveMethod = USE_CUSTOM_ET 
    cnvParam.pCmykParams = 0 
    cnvParam.pLabParams = 0 
    cnvParam.pYuvParams = 0 
    cnvParam.sDstInputTable(0) = 0 
    cnvParam.sInputProfile(0) = 0 
    cnvParam.sOutputProfile(0) = 0 
    For i = 0 To Len(strDst) - 1 
       cnvParam.sDstInputTable(i) = Asc(Right(strDst, Len(strDst) - i)) 
    Next i 
    'initialize the conversion engine 
    ret = L_ClrInit (ClrHandle, CCS_RGB, CCS_LAB, cnvParam) 
    'do we have a valid handle 
    If (ret = SUCCESS) Then 
       'do the conversion from RGB to CIELab 
       ret = L_ClrConvert (ClrHandle, RGBData(0), LABData(0), nWidth, nHeight, nInAlign, nOutAlign) 
       If (ret <> SUCCESS) Then 
          MsgBox "Failed to convert from RGB to LAB" 
          Tables_Convert_CMYKToRGB = ret 
       End If 
       'do not forget to free every thing 
       L_ClrFree (ClrHandle) 
    Else 
       MsgBox "Failed to initialize LTCLR" 
       Tables_Convert_CMYKToRGB = ret 
    End If 
 End Function 

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

LEADTOOLS Color Conversion C API Help