WindowLevel example for Visual Basic
Note: Also works with Access 95 and 97.
These examples convert a bitmap to 12-bit grayscale and then perform window leveling on the four most significant bits of the image.
Dim RasterProc As New LEADRasterProcess
'WindowLevel for Display
RasterProc.Grayscale LEADRasterView1.Raster, 12 'Grayscale image to 12-bit
LEADRasterView1.Raster.LevelLowBit = 8 ' use 4 most significant bits
LEADRasterView1.Raster.LevelHighBit = 11
LEADRasterView1.WindowLevel
Dim RasterProc As New LEADRasterProcess
'WindowLevel image processing
RasterProc.Grayscale LEADRasterView1.Raster, 12 'Grayscale image to 12-bit
LEADRasterView1.Raster.LevelLowBit = 8 ' use 4 most significant bits
LEADRasterView1.Raster.LevelHighBit = 11
RasterProc.WindowLevel LEADRasterView1.Raster
'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
Dim RasterProc As New LEADRasterProcess
Dim RasterIO As New LEADRasterIO
'Load a 16-bit grayscale image
RasterIO.Load LEADRasterView1.Raster, "d:\lead14\dist\images\dicom\image2.dic", 0, 0, 1
LEADRasterView1.AutoRepaint = False
'Use all bits
LEADRasterView1.Raster.LevelLowBit = 0
LEADRasterView1.Raster.LevelHighBit = LEADRasterView1.Raster.BitmapBits - 1
LEADRasterView1.Raster.GetMinMaxBits
LEADRasterView1.Raster.GetMinMaxVal
'Set LUT so the range is from pure blue to pure red
For i = LEADRasterView1.Raster.MinVal To LEADRasterView1.Raster.MaxVal
LEADRasterView1.Raster.LevelLUT(i) = RGB(i Mod 256, 0, 256 - i Mod 256)
Next i
'Window level for display only--leave the bitmap data unchanged
LEADRasterView1.WindowLevel
LEADRasterView1.ForceRepaint
End Sub