WindowLevelFillLUT example for Visual Basic

   Dim nHigh As Long
   Dim nLow As Long
   Dim RasterProc As New LEADRasterProcess
   Dim fSigned As Long

   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 = 2 ^ (LEADRasterView1.Raster.MaxBit - LEADRasterView1.Raster.MinBit + 1)

   'allocate the LUT
   LEADRasterView1.Raster.LevelLUT(nHigh - 1) = 0

  'set the FILLLUT_SIGNED flag for signed images
  fSigned = FILLLUT_UNSIGNED
  If (LEADRasterView1.Raster.IsSigned) Then fSigned = FILLLUT_SIGNED

   '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, _
                             0, _
                             FILLLUT_INSIDE Or FILLLUT_LINEAR Or fSigned

   'now use it
   RasterProc.WindowLevel LEADRasterView1.Raster