LColor::SetConversionParams

#include "ltwrappr.h"

L_INT LColor::SetConversionParams(pParams);

Sets new conversion parameters.

Parameters

LPCONVERSION_PARAMS pParams

Pointer to a CONVERSION_PARAMS structure that specifies the conversion parameters to set.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

If pParams is NULL, this function will fail. A valid color conversion class object is needed. To check the object validity, use LColor::IsValid.

Required DLLs and Libraries

See Also

Functions

Topics

Example

L_INT LColor_SetConversionParamsExample() 
{ 
   L_INT nRet = 0 ;  
   LColor clr; /*Color Conversion object*/ 
   CONVERSION_PARAMS params;   /*conversion options*/ 
   /* Conversion with options. The conversion will be done with the options specified in the params variable*/ 
   memset(&params,0,sizeof(params));  
   /* set the params size */ 
   params.uStructSize = sizeof(params);  
   /* we want to use the built in ICC conversion method and built in conversion */ 
   params.nMethod = USE_BUILTIN | USE_ICC /* use built in conversion and LEAD ICC Engine*/; 
   /* set the active conversion method */ 
   params.nActiveMethod = USE_BUILTIN;  
   /* allocate a D50 white point option */ 
   params.pWpoint = (LPWHITEPOINT)malloc(sizeof(WHITEPOINT));  
   params.pWpoint->nWhitePoint = CIELAB_D50; /* D50 white point */ 
   /* allocate a cmyk option */ 
   params.pCmykParams = (LPCMYK_PARAMS)malloc(sizeof(CMYK_PARAMS));  
   params.pCmykParams->uStructSize = sizeof(CMYK_PARAMS);  
   params.pCmykParams->nMask = CMYK_GCR;  
   params.pCmykParams->nGcr_level = 175; /* 17.5 % GCR value */ 
 
   LBitmapBase LeadBitmap;   /* Bitmap handle to hold the loaded image. */ 
 
   /* Load the bitmap, keeping the bits per pixel of the file */ 
   nRet = LeadBitmap.Load(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), 0, ORDER_BGR); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   LBuffer Input(sizeof(L_UCHAR) * (LeadBitmap.GetMemSize())); 
   LBuffer Output(sizeof(L_UCHAR) * (LeadBitmap.GetMemSize())); 
 
   LeadBitmap.GetRowCol(&Input, 0, 0); 
 
   L_UCHAR* pInput = (L_UCHAR*)(Input.Lock());     /*input buffer*/ 
   L_UCHAR* pOutput= (L_UCHAR*)(Output.Lock());    /*output buffer*/ 
   L_INT nWidth = LeadBitmap.GetWidth();           /*pixels width*/ 
   L_INT nHeight = LeadBitmap.GetHeight();         /*pixels height*/ 
 
   /* initialize the color conversion */ 
   nRet = clr.Initialize (CCS_CMYK,CCS_RGB,NULL);  
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* convert the image buffer */ 
   nRet = clr.Convert (pInput, /* input buffer */ 
      pOutput, /* output buffer */ 
      nWidth, /*pixels width*/ 
      nHeight, /*pixels height*/ 
      0, /* 0 bytes align*/ 
      0); /*0 bytes align*/ 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* change the active method for conversion */ 
   params.nMethod = CHANGE_ACTIVE_METHOD;  
   /* switch to ICC conversion method */ 
   params.nActiveMethod = USE_ICC;  
 
   /* update the conversion state */ 
   nRet = clr.SetConversionParams(&params);  
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* convert the image buffer */ 
   nRet = clr.Convert (pInput, /* input buffer */ 
      pOutput, /* 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 = clr.Free (); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /* save the image */ 
   nRet = LeadBitmap.Save (MAKE_IMAGE_PATH(TEXT("Result.BMP")), FILE_BMP, 24, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   //free bitmap  
   if(LeadBitmap.IsAllocated())   
      LeadBitmap.Free(); 
 
   free(params.pWpoint);  
   free(params.pCmykParams);  
 
   return SUCCESS; 
} 
Help Version 22.0.2021.8.20
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Color Conversion C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.