L_ConvertCLUTToBuffer

#include "l_bitmap.h"

L_LTCLR_API L_INT L_ConvertCLUTToBuffer(pData, pIccCLUT, nPrecision, znDataSize)

L_UCHAR * pData;

/* pointer to a buffer */

L_VOID * pIccCLUT;

/* pointer to a structure */

L_INT nPrecision;

/* precision of the data */

L_SSIZE_T znDataSize;

/* size of the data */

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

Parameter

Description

pData

Pointer to a buffer to be updated with the converted information as one buffer of sequential bytes.

pIccCLUT

Pointer to an ICC_CLUT8 or ICC_CLUT16 structure that contains the information to be converted into one buffer of sequential data.

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 type ICC_CLUT8 structure.

 

2

Used if the pIccCLUT parameter is of type ICC_CLUT16 structure.

znDataSize

Size in bytes, of the structure pointed to by pIccCLUT, for versioning. Use either sizeof(ICC_CLUT8) or sizeof(ICC_CLUT16).

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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 (www.color.org) website.

Required DLLs and Libraries

LTCLR

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 95 / 98 / Me, Windows 2000 / XP, Windows CE.

See Also

Functions:

L_SaveICCProfile, L_FillICCProfileFromICCFile, L_InitICCHeader, L_SetICCCMMType, L_SetICCDeviceClass, L_SetICCColorSpace, L_SetICCConnectionSpace, L_SetICCPrimaryPlatform, L_SetICCFlags, L_SetICCDevManufacturer, L_SetICCDevModel, L_SetICCDeviceAttributes, L_SetICCRenderingIntent, L_SetICCCreator, L_SetICCDateTime, L_SetICCProfileId, L_2bFixed2bNumberToDouble, L_U8Fixed8NumberToDouble, L_DoubleToU8Fixed8Number, L_DoubleTo2bFixed2bNumber, L_SetICCTagData, L_GetICCTagData, L_CreateICCTagData, L_DeleteICCTag, L_GenerateICCFile, L_GenerateICCPointer, L_GetICCTagTypeSig, L_FreeICCTagType, L_ConvertParametricCurveTypeToBuffer, L_ConvertCurveTypeToBuffer, L_ConvertCLUTToBuffer, L_GetParametricCurveNumberOfParameters, L_ConvertParametricCurveTypeToBuffer, L_ConvertCurveTypeToBuffer, L_GetParametricCurveNumberOfParameters

Topics:

Using ICC Profile Functions

ICC Profile Functions: Creating an ICC Profile

Example

/* 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; 
}