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 handleDim cnvParam As CONVERSION_PARAMS 'conversion paramsDim ret As Integer 'return value'initialize the conversion structurecnvParam.uStructSize = Len(cnvParam)cnvParam.nQuantization = 8cnvParam.nMethod = USE_ETcnvParam.nActiveMethod = USE_ETcnvParam.pCmykParams = 0cnvParam.pLabParams = 0cnvParam.pYuvParams = 0cnvParam.sDstInputTable(0) = 0cnvParam.sInputProfile(0) = 0cnvParam.sOutputProfile(0) = 0'initialize the conversion engineret = L_ClrInit (ClrHandle, CCS_RGB, CCS_LAB, cnvParam)'do we have a valid handleIf (ret = SUCCESS) Then'do the conversion from RGB to CIELabret = L_ClrConvert (ClrHandle, RGBData(0), LABData(0), nWidth, nHeight, nInAlign, nOutAlign)If (ret <> SUCCESS) ThenMsgBox "Failed to convert from RGB to LAB"Tables_Convert_CMYKToRGB = retEnd If'do not forget to free every thingL_ClrFree (ClrHandle)ElseMsgBox "Failed to initialize LTCLR"Tables_Convert_CMYKToRGB = retEnd IfEnd 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 handleDim cnvParam As CONVERSION_PARAMS 'conversion paramsDim ret As Integer 'return valueDim i As Integer'initialize the conversion structurecnvParam.uStructSize = Len(cnvParam)cnvParam.nQuantization = 8cnvParam.nMethod = USE_CUSTOM_ETcnvParam.nActiveMethod = USE_CUSTOM_ETcnvParam.pCmykParams = 0cnvParam.pLabParams = 0cnvParam.pYuvParams = 0cnvParam.sDstInputTable(0) = 0cnvParam.sInputProfile(0) = 0cnvParam.sOutputProfile(0) = 0For i = 0 To Len(strDst) - 1cnvParam.sDstInputTable(i) = Asc(Right(strDst, Len(strDst) - i))Next i'initialize the conversion engineret = L_ClrInit (ClrHandle, CCS_RGB, CCS_LAB, cnvParam)'do we have a valid handleIf (ret = SUCCESS) Then'do the conversion from RGB to CIELabret = L_ClrConvert (ClrHandle, RGBData(0), LABData(0), nWidth, nHeight, nInAlign, nOutAlign)If (ret <> SUCCESS) ThenMsgBox "Failed to convert from RGB to LAB"Tables_Convert_CMYKToRGB = retEnd If'do not forget to free every thingL_ClrFree (ClrHandle)ElseMsgBox "Failed to initialize LTCLR"Tables_Convert_CMYKToRGB = retEnd IfEnd Function