Built-in Conversion (Delphi 4.0)

The Color Conversion C API provides built-in conversion. To do a built-in conversion, follow the steps below:

1.

At the beginning of the Unit1 file, add LTDLLUNT, LTDLLTYP, and LTDLLDEF to the uses section.

2.

Use the following code to perform the built-in conversion:

function TForm1.Builtin_RGBToLAB({in}pSrcRGB, {out}pDstLAB: Pointer; {in}nWidth, {in}nHeight: Integer) : {ret}Integer; 
var 
ClrHandle : THandle;           (* color handle           *) 
params    : CONVERSION_PARAMS; (* conversion params      *) 
WPoint    : WHITEPOINT ;       (* white point definition *) 
ret       : Integer;           (* return value           *) 
begin 
(* 
****************************************************************** 
* Simple conversion from RGB to CIELab using built-in conversion * 
* Parameters :                                                   * 
* pSrcRGB : 24 bit RGB data, this is the input image data        * 
* pDstLAB : 24 bit CIELab data, this is the output image data    * 
* nWidth  : Width of the image                                   * 
* nHeight : Height of the image                                  * 
* Returns SUCCESS when successful or error code else             * 
****************************************************************** 
*) 
(* initialize the conversion structure *) 
ZeroMemory(Pointer(@params), SizeOf(CONVERSION_PARAMS)); 
(* set the whitepoint *) 
params.pWpoint := @WPoint; 
(* set up default conversion data *) 
params.uStructSize  := sizeof(CONVERSION_PARAMS); 
params.pWpoint.nWhitePoint     := CIELAB_D50; 
params.nQuantization  := 8; 
params.nMethod  := USE_BUILTIN; 
params.nActiveMethod  := USE_BUILTIN; 
params.pWpoint.xWhite  := 0.0; 
params.pWpoint.yWhite  := 0.0; 
(* initialize the conversion engine *) 
ret := L_ClrInit(@ClrHandle, 
CCS_RGB, 
CCS_LAB, 
@params); 
(* do we have a valid handle *) 
if ret <> SUCCESS then 
   Result := ret 
else 
   begin 
(* do the conversion from RGB to CIELab *) 
ret := L_ClrConvert (ClrHandle, 
pSrcRGB, 
pDstLAB, 
nWidth, 
nHeight, 
0, 
0); 
if ret <> SUCCESS then 
   begin 
(* free before leaving *) 
L_ClrFree (ClrHandle); 
Result := ret; 
end 
else 
   begin 
(* do not forget to free every thing *) 
ret := L_ClrFree (ClrHandle); 
Result := ret; 
end; 
end; 
end; 

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 API Help