LICCProfile::ConvertCLUTToBuffer

#include "ltwrappr.h"

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

L_UCHAR L_FAR * pData;

/* pointer to a buffer */

L_VOID * pIccCLUT;

/* pointer to a structure */

L_INT nPrecision;

/* precision of the data */

L_INT nDataSize;

/* size of the data */

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

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

 

2

Used if the pIccCLUT parameter is of ICC_CLUT16 structure.

nDataSize

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

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The user must allocate the pData parameter. 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 + nDataSize. For more information on how to calculate the nDataSize, refer to the ICC.1:2004-10 specification pages 48 or 51.

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.

See Also

Functions:

LICCProfile::GetParametricCurveNumberOfParameters, LICCProfile::DoubleToU8Fixed8Number, LICCProfile::U8Fixed8NumberToDouble, LICCProfile::ConvertCurveTypeToBuffer, LICCProfile::ConvertParametricCurveTypeToBuffer, LICCProfile::SetProfileId

Topics:

ICC Profile Functions: Tags

 

Using ICC Profile Functions

Example

/* This example fills an ICC_CLUT16 structure and then converts it into a buffer */
void CICCProfileDlg::OnConvertCLUTToBuffer()
{
   LICCProfile ICCProfile; 

   L_UCHAR * dstBuffer; 

   ICC_CLUT16 iccCLUT16; 
   L_INT nDataSize, nCntr, nRet; 
   
   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 *) GlobalAllocPtr(GHND, nDataSize *sizeof(L_IccUInt16Number)); 
   if (iccCLUT16.pData == NULL) 
      return; 

   // 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 *) GlobalAllocPtr(GHND, nDataSize * sizeof(L_UCHAR)); 
   if (dstBuffer == NULL) 
      return; 
   
   // after that call the conversion function
   nRet = ICCProfile.ConvertCLUTToBuffer(dstBuffer, (L_VOID *) &iccCLUT16, iccCLUT16.uPrecision, nDataSize); 
}