Color Conversion to an Image (Delphi 4.0)

The Color Conversion API provides color conversion to an image. To do a 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 direct color conversion to an image:

function TForm1.LABToLEADBitmap({in}pSrcLAB: Pointer; {out}var pBitmap: BITMAPHANDLE; {in}nWidth, {in}nHeight: Integer) : {ret}Integer;
var
   ret : Integer; (* return value *)
begin
   (*
    ******************************************************************
    * Simple conversion from CIELab to RGB24 LEAD bitmap             *
    * Parameters :                                                   *
    * pSrcLAB : 24 bit CIELab data, this is the input image data     *
    * pBitmap : Handle to the resulting LEAD bitmap                  *
    * nWidth  : Width of the image                                   *
    * nHeight : Height of the image                                  *
    * Returns SUCCESS when successful or an error code otherwise             *
    ******************************************************************
    *)
   ret := L_ClrConvertDirectToBitmap(CCS_LAB,
      CCS_RGB,
      pSrcLAB,
      @pBitmap,
      SizeOf(BITMAPHANDLE),
      nWidth,
      nHeight,
      0,
      0);

   Result := ret;
end;