Initializes the color conversion engine.
#include "ltkrn.h"
#include "ltclr.h"
L_LTCLR_API L_INT L_ClrInit(pClrHandle, nSrcFormat, nDstFormat, pParams)
Pointer to a color conversion handle. This handle is needed in the conversion process and for setting the process options.
Format of the source data. Possible values are:
Value | Meaning |
---|---|
CCS_RGB | [0x00] Color space is RGB. |
CCS_YUV | [0x01] Color space is YUV. |
CCS_CMYK | [0x02] Color space is CMYK. |
CCS_HSV | [0x03] Color space is HSV. |
CCS_HLS | [0x04] Color space is HLS. |
CCS_YIQ | [0x05] Color space is YIQ. |
CCS_CMY | [0x06] Color space is CMY. |
CCS_LAB | [0x07] Color space is CIELAB. |
CCS_XYZ | [0x08] Color space is CIEXYZ. |
CCS_YCCK | [0x0B] Color space is YCCK. |
CCS_BGR | [0x0C] Color space is BGR. |
CCS_UYVY | [0x0E] Color space is UYVY. |
CCS_YUY2 | [0x09] Color space is YUY2. |
CCS_YVU9 | [0x0A] Color space is YVU9. |
CCS_YCC | [0x0F] Color space is YCC. |
CCS_Y41P | [0x0D] Color space is Y41P. |
CCS_IHS | [0x80] Color space is IHS. |
CCS_ARGB4 | [0x90] Color space is ARGB4444. |
Format of the output data. Possible values are:
Value | Meaning |
---|---|
CCS_RGB | [0x00] Color space is RGB. |
CCS_YUV | [0x01] Color space is YUV. |
CCS_CMYK | [0x02] Color space is CMYK. |
CCS_HSV | [0x03] Color space is HSV. |
CCS_HLS | [0x04] Color space is HLS. |
CCS_YIQ | [0x05] Color space is YIQ. |
CCS_CMY | [0x06] Color space is CMY. |
CCS_LAB | [0x07] Color space is CIELAB. |
CCS_XYZ | [0x08] Color space is CIEXYZ. |
CCS_YCCK | [0x0B] Color space is YCCK. |
CCS_BGR | [0x0C] Color space is BGR. |
CCS_UYVY | [0x0E] Color space is UYVY. |
CCS_YUY2 | [0x09] Color space is YUY2. |
CCS_YVU9 | [0x0A] Color space is YVU9. |
CCS_YCC | [0x0F] Color space is YCC. |
CCS_Y41P | [0x0D] Color space is Y41P |
CCS_IHS | [0x80] Color space is IHS |
CCS_ARGB4 | [0x90] Color space is ARGB4444. |
Pointer to a CONVERSION_PARAMS structure that contains the conversion properties used in the initialization.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
L_ClrInit must be called before calling any other LEADTOOLS Color Space toolkit functions in case of indirect conversion.
When the handle to the color conversion is no longer needed, it should be freed by calling L_ClrFree. For every call to L_ClrInit there must be a call to L_ClrFree.
If pParams is NULL, the default built in conversion is assumed, and any subsequent calls to L_ClrSetConversionParams will only affect CMYK conversion parameters.
When you choose the conversion method, be sure not to combine the Profiles option (USE_ICC) with the Custom Profiles option (USE_CUSTOM_ICC), or the Emulation Tables method (USE_ET) with the custom Emulation Tables method (USE_CUSTOM_ET).
Supports conversion using ICC Devicelink profiles with option (USE_CUSTOM_ICC) and using it as input profile.
Win32, x64.
L_INT ClrInitExample(
L_UCHAR* pInput,
L_INT nWidth,
L_INT nHeight)
{
L_INT nRet;
HANDLE ClrHandle; /* Conversion color handle */
CONVERSION_PARAMS params = { sizeof(CONVERSION_PARAMS) };
params.nActiveMethod = USE_AUTO;
params.nMethod = USE_AUTO;
params.nQuantization = 8;
/* Initialize the color conversion to use the simplest conversion
that gives good results for all conversions.
The USE_AUTO method uses the built-in ICC profiles to do the CMYK->RGB conversion.
Other conversions might use built-in conversion formulas.
*/
nRet = L_ClrInit(&ClrHandle, CCS_CMYK, CCS_RGB, ¶ms);
if (nRet != SUCCESS)
return nRet;
/* convert the image buffer */
nRet = L_ClrConvert(ClrHandle, /* conversion handle */
pInput, /* input buffer */
pInput, /* output buffer */
nWidth, /* pixels width */
nHeight, /* pixels height */
0, /* 0 bytes align */
0); /* 0 bytes align */
if (nRet != SUCCESS)
return nRet;
/* free the conversion */
nRet = L_ClrFree(ClrHandle);
return nRet;
}