UseLUT example for Delphi

procedure TForm1.Button1Click(Sender: TObject);
var
   nRet: Integer;
   nLow: Integer;
   nHigh: Integer;
begin
   LEADImage1.UnlockSupport(L_SUPPORT_MEDICAL, 'TestKey');
   nRet:= LEADImage1.Load('c:\16.jpg', 16, 0, 1);
   if(nRet = SUCCESS)then
   begin
      LEADImage1.GetMinMaxBits();
      LEADImage1.GetMinMaxVal();

      LEADImage1.LevelLowBit:= 0;
      LEADImage1.LevelHighBit:= LEADImage1.BitmapBits - 1;

      nLow:= LEADImage1.MinBit;
      nHigh:= 1 Shl (LEADImage1.MaxBit - LEADImage1.MinBit + 1);
      //allocate the LUT
      LEADImage1.LevelLUT[nHigh - 1]:= 0;

      //fill the entire LUT with gradient from RED to BLUE
      LEADImage1.WindowLevelFillLUT(clRed,
                                    clBlue,
                                    nLow,
                                    nHigh,
                                    LEADImage1.MinBit,
                                    LEADImage1.MaxBit,
                                    LEADImage1.MinVal,
                                    LEADImage1.MaxVal,
                                    0,
                                    FILLLUT_INSIDE Or FILLLUT_LINEAR);
   end
   else
      ShowMessage('Unable to load file');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   LEADImage1.UseLUT:= False;
   LEADImage1.ColorRes(24, CRF_BYTEORDERBGR, CRF_NODITHERING, 0);
end;