Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.29
LEADTOOLS Color Conversion C DLL Help

Built-in Conversion (Delphi 4.0)

Show in webframe

The Color Conversion C DLL 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;

See Also:

Introduction

Programming with Color Conversion

Color Conversion C DLL Function Groups

Visual C++ Tutorials

Delphi Tutorials

Visual Basic Tutorials

Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.