WindowLevelFillLUT example for Delphi

var
   RasterProc: LEADRasterProcess;
   nHigh: Longint;
   nLow: Longint;
begin

    RasterProc:= CreateComObject (CLASS_LEADRasterProcess) as LEADRasterProcess;

    RasterProc.Grayscale (LEADRasterView1.Raster, 16);

    LEADRasterView1.Raster.GetMinMaxBits () ;
    LEADRasterView1.Raster.GetMinMaxVal () ;

    LEADRasterView1.Raster.LevelLowBit := 0;
    LEADRasterView1.Raster.LevelHighBit := LEADRasterView1.Raster.BitmapBits - 1;

    nLow := LEADRasterView1.Raster.MinBit;
    nHigh := Trunc(Power (2, (LEADRasterView1.Raster.MaxBit - LEADRasterView1.Raster.MinBit + 1)));

    //allocate the LUT
    LEADRasterView1.Raster.LevelLUT [nHigh - 1] := 0;

    //fill the entire LUT with gradient from RED to BLUE
    LEADRasterView1.Raster.WindowLevelFillLUT (RGB (255, 0, 0), RGB (0, 0, 255),
                             nLow, nHigh,
                             LEADRasterView1.Raster.MinBit,
                             LEADRasterView1.Raster.MaxBit,
                             LEADRasterView1.Raster.MinVal,
                             LEADRasterView1.Raster.MaxVal,
                             True);

    //now use it
    RasterProc.WindowLevel (LEADRasterView1.Raster);
end;