Available in LEADTOOLS Medical Imaging toolkits. |
WindowLevelBitmap example for Visual Basic
'This example loads a 16-bit grayscale, fills the window level lookup table,
' and window levels the bitmap for display only
Private Sub Command2_Click()
Dim i As Long
'Load a 16-bit grayscale image
LEAD1.Load App.Path & "\gray16.tif", 0, 0, 1
LEAD1.AutoRepaint = False
'Use all bits
LEAD1.LevelLowBit = 0
LEAD1.LevelHighBit = LEAD1.BitmapBits - 1
LEAD1.GetMinMaxBits
LEAD1.GetMinMaxVal
'Set LUT so the range is from pure blue to pure red
For i = LEAD1.MinVal To LEAD1.MaxVal
LEAD1.LevelLUT(i) = RGB(i Mod 256, 0, 256 - i Mod 256)
Next I
'Window level for display only--leave the bitmap data unchanged
LEAD1.WindowLevelBitmap = True
LEAD1.WindowLevel
LEAD1.ForceRepaint
End Sub