WindowLevelBitmap example for Delphi
//This example loads a 16-bit grayscale, fills the window level lookup table,
//and window levels the bitmap for display only
procedure TForm1.WndLvlBmpClick(Sender: TObject);
var
min: integer;
max: integer;
i : integer;
begin
// Load a 16-bit grayscale image
Lead1.Load('test.tif', 0, 0, 1);
Lead1.AutoRepaint := False;
// Use all bits
Lead1.LevelLowBit := 0;
Lead1.LevelHighBit := Lead1.BitmapBits - 1;
Lead1.GetMinMaxBits;
Lead1.GetMinMaxVal;
max := Lead1.MaxVal;
min := Lead1.MinVal;
// Set LUT so it ranges from pure blue to pure red
for i:=min to max-1 do
Lead1.LevelLUT[i] := RGB(i mod 256, 0, 256 - i mod 256);
//Window level for display only -- leave the bitmap data unchanged
Lead1.WindowLevelBitmap := True;
Lead1.WindowLevel();
Lead1.ForceRepaint;
end;