The Color Conversion C API provides a color space dialog that can be used to initialize a conversion. To do a dialog based initialization 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 implement using the color space dialog for initializing: |
function TForm1.ColorDlg_RGBToLAB({in}pSrcRGB, {out}pDstLAB: Pointer; {in}nWidth, {out}nHeight: Integer) : {ret}Integer;
var
ClrHandle : THandle; (* color handle *)
ret: Integer; (* return value *)
begin
(*
******************************************************************
* Simple conversion from RGB to CIELab using the LEAD color dialog *
* 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 an error code otherwise *
******************************************************************
*)
(*
* when the dialog appears choose RGB to LAB conversion from
* the Miscellaneous options
*)
ret := L_ClrDlg(DLG_LAB, (* CIELAb color dialog *)
Handle, (* Handle to parent window *)
@ClrHandle, (* I need a color handle *)
nil (* no need for a CONVERSION_PARAMS data *)
);
(* 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;