Emulation Tables (Delphi 4.0)

Note:

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

The LEAD Color Conversion toolkit provides emulation tables as one of its conversion methods. This method however is provided only for the following conversions:

image\sqrblit.gif CMYK to RGB.

image\sqrblit.gif CIELab to RGB

image\sqrblit.gif and RGB to CIELab

The Emulation tables' method supports both built-in and custom options. For built-in emulation tables, use the USE_ET option. The custom emulation tables' option, USE_CUSTOM_ET, provides custom conversion using user-supplied images converted from the source images distributed with the library by any tool, as follows:

 

Conversion

Source

Convert to

CMYK to RGB

src_cmyk_image.tif

RGB image (i.e. dst_cmyk2rgb_image.tif)

RGB to Lab

src_rgb_image.tif

Lab image ( i.e. dst_rgb2lab_image.tif)

Lab to RGB

src_lab_image.tif

RGB image (i.e. dst_lab2rgb_image.tif)

A set of images, already converted and ready for use (dst_cmyk2rgb_image.tif, dst_rgb2lab_image.tif, and dst_lab2rgb_image.tif), is provided. However, using the provided set of converted images will produce the same results as the built-in emulation tables.

The code below shows how a conversion can be done using the built-in tables:

procedure Tables_Convert_CMYKToRGB({in}pInput: Pointer; {out}pOutput: Pointer; {in}nWidth: Integer; {in}nHeight: Integer);
var
   ClrHandle : THandle (*Color Handle*);
   params : CONVERSION_PARAMS (*Conversion options*);
begin

   (* Zero initialize, this step is important*)
   ZeroMemory (@params, SizeOf (CONVERSION_PARAMS));

   (*
    * Conversion with options.
    * The conversion will be done with the options specified in the
    * params variable.
   *)

   (* Set the params size *)
   params.uStructSize := SizeOf (CONVERSION_PARAMS);

   (* We want to use built-in emulation tables *)
   params.nMethod := USE_ET;

   (* set the active conversion method *)
   params.nActiveMethod := USE_ET;

   (* initialize the color conversion *)
   L_ClrInitL_ClrInit (@ClrHandle, (* pointer to color handle to be returned*)
             CCS_CMYK,    (* input color space *)
             CCS_RGB,     (* output color space *)
             @params      (* pointer to the initialization options *)
            );

   (* Convert the image buffer *)
   L_ClrConvert (ClrHandle, (* conversion handle *)
                 pInput,    (* input buffer *)
                 pOutput,   (* output buffer *)
                 nWidth,     (* pixels width *)
                 nHeight,   (* pixels height *)
                 0,         (* 0 bytes align *)
                 0);        (* 0 bytes align *)

   (* free the conversion *)
   L_ClrFree (ClrHandle);
end;

The code below shows how a conversion can be done using user-defined tables:

procedure Tables_Convert_CMYKToRGB({in}pInput: Pointer; {out}pOutput: Pointer; {in}nWidth: Integer; {in}nHeight: Integer);
var
   ClrHandle : THandle (*Color Handle*);
   params : CONVERSION_PARAMS (*Conversion options*);
begin

   (* Zero initialize, this step is important*)
   ZeroMemory (@params, SizeOf (CONVERSION_PARAMS));

   (*
    * Conversion with options.
    * The conversion will be done with the options specified in the
    * params variable.
   *)

   (* Set the params size *)
   params.uStructSize := SizeOf (CONVERSION_PARAMS);

   (* We want to use built-in emulation tables *)
   params.nMethod := USE_CUSTOM_ET;

   (* set the active conversion method *)
   params.nActiveMethod := USE_CUSTOM_ET;

   (* set the emulation tables *)
   StrCopy(params.sInputProfile, 'C:\RGBImage.tif');

   (* initialize the color conversion *)
   L_ClrInit (@ClrHandle, (* pointer to color handle to be returned*)
             CCS_CMYK,    (* input color space *)
             CCS_RGB,     (* output color space *)
             @params      (* pointer to the initialization options *)
            );

   (* Convert the image buffer *)
   L_ClrConvert (ClrHandle, (* conversion handle *)
                 pInput,    (* input buffer *)
                 pOutput,   (* output buffer *)
                 nWidth,     (* pixels width *)
                 nHeight,   (* pixels height *)
                 0,         (* 0 bytes align *)
                 0);        (* 0 bytes align *)

   (* free the conversion *)
   L_ClrFree (ClrHandle);
end;

See Also:

Introduction

Programming with Color Conversion

Raster Image Functions: Color Conversion

Visual C++ Tutorials

Delphi Tutorials

Visual Basic Tutorials