LColor::SetConversionParams

#include "ltwrappr.h"

L_INT LColor::SetConversionParams(pParams);

LPCONVERSION_PARAMS pParams;

pointer to a structure

Sets new conversion parameters.

Parameter

Description

pParams

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

Returns

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

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:

LColor::Convert, LColor::Free, LColor::Initialize, Class Members

Topics:

Conversion Process

 

Raster Image Functions: Color Conversion

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
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(¶ms,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(¶ms); 
   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 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Color Conversion C++ Class Library Help