Converts the information in an ICC_CLUT8 or ICC_CLUT16 structure into one buffer of sequential data.
#include "l_bitmap.h"
L_LTCLR_API L_INT L_ConvertCLUTToBuffer(pData, pIccCLUT, nPrecision, znDataSize)
Pointer to a buffer to be updated with the converted information as one buffer of sequential bytes.
Pointer to an ICC_CLUT8 or ICC_CLUT16 structure that contains the information to be converted into one buffer of sequential data.
Value that represents the number of bytes for each element of the data pointed to by pData member of the pIccCLUT parameter. Possible values are:
Value | Meaning |
---|---|
1 | Used if the pIccCLUT parameter is of type ICC_CLUT8 structure. |
2 | Used if the pIccCLUT parameter is of type ICC_CLUT16 structure. |
Size in bytes, of the structure pointed to by pIccCLUT, for versioning. Use either sizeof(ICC_CLUT8) or sizeof(ICC_CLUT16).
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
The pData pointer must be allocated by the user. Its size must be equal to the size, in bytes, of the structure pointed to by the pIccCLUT parameter.
The size of pData buffer can be calculated as follows: 16 + 1 + 3 + znDataSize. For more information on how to calculate the znDataSize, refer to the ICC.1:2004-10 specification pages 48 or 51 in the (https://www.color.org/index.xalter) website.
Win32, x64.
This example fills an ICC_CLUT16 structure and then converts it into a buffer.
L_UCHAR* ConvertCLUTToBufferExample(L_INT* pnRet)
{
L_UCHAR* dstBuffer;
ICC_CLUT16 iccCLUT16;
L_INT nCntr;
L_SSIZE_T nDataSize;
memset(&iccCLUT16, 0, sizeof(ICC_CLUT16));
// the precision is 2 because we are using ICC_CLUT16
// and 2 denotes to 2 bytes (i.e. each data element in
// the pData pointer is 2 bytes in size
iccCLUT16.uPrecision = 2;
// the number of items in the grid points array is
// the number of input channels, lets assume that
// the number of channels is 2
iccCLUT16.NumOfGridPoints[0] = 0;
iccCLUT16.NumOfGridPoints[1] = 1;
// the size of the data buffer is the multiplication of
// all the data in the NumOfGridPoints array multiplied by
// the number of output channels multiplied by the precision
nDataSize = 1;
for (nCntr = 0; nCntr < 2; nCntr++)
nDataSize = iccCLUT16.NumOfGridPoints[nCntr];
// lets assume we have 3 output channels
nDataSize *= 3 * iccCLUT16.uPrecision;
// allocate the data pointer
iccCLUT16.pData = (L_IccUInt16Number*) calloc (nDataSize, sizeof(L_IccUInt16Number));
if (iccCLUT16.pData == NULL)
{
*pnRet = ERROR_NO_MEMORY;
return NULL;
}
// and fill it with the needed information, in this example I'll just clear it
memset(iccCLUT16.pData, 0, nDataSize);
// then add the byte count for the NumOfGridPoints and Precision and Pad bytes
nDataSize += 16 + 1 + 3;
// now allocate the distination buffer
dstBuffer = (L_UCHAR*) calloc(nDataSize, sizeof(L_UCHAR));
if (dstBuffer == NULL)
{
*pnRet = ERROR_NO_MEMORY;
return NULL;
}
// after that call the conversion function
*pnRet = L_ConvertCLUTToBuffer (dstBuffer, (L_VOID *) &iccCLUT16, iccCLUT16.uPrecision, nDataSize);
if(*pnRet != SUCCESS)
return NULL;
return dstBuffer;
}