#include "ltwrappr.h"

L_INT LICCProfile::ConvertCLUTToBuffer(pData, pIccCLUT, nPrecision, nDataSize)

Converts the information in an ICC_CLUT8 or ICC_CLUT16 structure into one buffer of sequential data.


L_UCHAR * pData

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.

L_INT nPrecision

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 ICC_CLUT8 structure.
2 Used if the pIccCLUT parameter is of ICC_CLUT16 structure.

L_SSIZE_T nDataSize

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; otherwise an error may occur and corrupted data will return.

The size of pData buffer can be calculated as follows: 16 + 1 + 3 + nDataSize. For more information on how to calculate the nDataSize, refer to the ICC.1:2004-10 specification pages 48 or 51 in the website.

Required DLLs and Libraries

See Also




This example fills an ICC_CLUT16 structure and then converts it into a buffer

L_INT LICCProfile_ConvertCLUTToBufferExample() 
   LICCProfile ICCProfile;  
   L_UCHAR * dstBuffer;  
   ICC_CLUT16 iccCLUT16;  
   L_INT nCntr, nRet = FAILURE; 
   L_SSIZE_T nDataSize; 
   memset(&iccCLUT16, 0, sizeof(ICC_CLUT16));  
   // 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. If assume that 
   // the number of channels is 2 
   iccCLUT16.NumOfGridPoints[0] = 0;  
   iccCLUT16.NumOfGridPoints[1] = 1;  
   // the size of the data buffer is  
   // 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];  
   // assume 3 output channels 
   nDataSize *= 3 * iccCLUT16.uPrecision;  
   // allocate the data pointer 
   iccCLUT16.pData = (L_IccUInt16Number *) GlobalAlloc(GHND, nDataSize *sizeof(L_IccUInt16Number));  
   if (iccCLUT16.pData == NULL)  
      return FAILURE;  
   // fill it with the needed information. For example, to 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 destination buffer 
   dstBuffer = (L_UCHAR *) GlobalAlloc(GHND, nDataSize * sizeof(L_UCHAR));  
   if (dstBuffer == NULL) 
      return nRet; 
   // after that call the conversion function 
   nRet = ICCProfile.ConvertCLUTToBuffer(dstBuffer, (L_VOID *) &iccCLUT16, iccCLUT16.uPrecision, nDataSize); 
   return nRet; 

Help Version 21.0.2021.5.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Color Conversion C++ Class Library Help