The Color Conversion C API provides built-in conversion. To do a built-in conversion, follow the steps below:
Define the following global variables:
HANDLE ClrHandle;CONVERSION_PARAMS params;WHITEPOINT WPoint;L_UCHAR *pRGBData;L_UCHAR *pLABData;L_INT nWidth;L_INT nHeight;L_INT nInAlign;L_INT nOutAlign;
Set the conversion options by filling a CONVERSION_PARAMS structure:
ZeroMemory(¶ms, sizeof(CONVERSION_PARAMS));params.pWpoint = &WPoint;params.uStructSize = sizeof(CONVERSION_PARAMS);params.pWpoint->nWhitePoint = CIELAB_D50;params.nQuantization = 8;params.nMethod = USE_BUILTIN;params.nActiveMethod = USE_BUILTIN;params.pWpoint->xWhite = 0.0;params.pWpoint->yWhite = 0.0;
Initialize the color conversion handle with L_ClrInit():
L_ClrInit(&ClrHandle, CCS_RGB, CCS_LAB, ¶ms);
Convert from RGB to CIELab:
L_ClrConvert(ClrHandle, pRGBData, pLABData, nWidth, nHeight, nInAlign, nOutAlign);
At the end, free the color conversion handle:
L_ClrFree(ClrHandle);