The Color Conversion C API provides built-in conversion. To do a built-in conversion, follow the steps below:
1. |
Define the following global variables: |
Dim RGBData(100) As Byte
Dim LABData(100) As Byte
Dim nWidth As Integer
Dim nHeight As Integer
Dim nInAlign As Integer
Dim nOutAlign As Integer
Dim ClrHandle As Long 'color handle
Dim cnvParam As CONVERSION_PARAMS 'conversion params
Dim wtPoint As WHITEPOINT 'white point definition
2. |
Set the conversion options by filling a CONVERSION_PARAMS structure: |
'set the whitepoint
wtPoint.nWhitePoint = CIELAB_D50
wtPoint.xWhite = 0
wtPoint.yWhite = 0
'initialize the conversion structure
cnvParam.uStructSize = Len(cnvParam)
cnvParam.nQuantization = 8
cnvParam.nMethod = USE_BUILTIN
cnvParam.nActiveMethod = USE_BUILTIN
cnvParam.pCmykParams = 0
cnvParam.pLabParams = 0
cnvParam.pYuvParams = 0
cnvParam.sDstInputTable(0) = 0
cnvParam.sInputProfile(0) = 0
cnvParam.sOutputProfile(0) = 0
cnvParam.pWpoint = VarPtr(wtPoint)
3. |
Initialize the color conversion handle with L_ClrInit (): |
L_ClrInit ClrHandle, CCS_RGB, CCS_LAB, cnvParam
4. |
Convert from RGB to CIELab: |
L_ClrConvert ClrHandle, RGBData(0), LABData(0), nWidth, nHeight, nInAlign, nOutAlign
5. |
At the end, free the color conversion handle: |
L_ClrFree ClrHandle