LEADTOOLS Windows Forms (Leadtools.WinForms.CommonDialogs.Color assembly)
LEAD Technologies, Inc

RasterWindowLevelDialog Class

Example 





Members 
Displays the Window Level dialog box.
Object Model
RasterWindowLevelDialog Class
Syntax
'Usage
 
Dim instance As RasterWindowLevelDialog
function Leadtools.WinForms.CommonDialogs.Color.RasterWindowLevelDialog()
Remarks

The Window Level dialog can be seen below:

Example
 
Public Sub _windowLevleDlg_Help(ByVal sender As Object, ByVal e As RasterColorDialogHelpEventArgs) Handles _windowLevleDlg.Help
   If e.Dialog = RasterColorDialogHelpName.WindowLevel Then
      MessageBox.Show("Window Level dialog Help")
   End If
End Sub
WithEvents _windowLevleDlg As New RasterWindowLevelDialog

Public Sub WindowLevelDialogExample()
   ' Prepare RasterCodecs
   Dim codecs As New RasterCodecs()

   ' load an image
   Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"))

   Dim size As Integer
   Dim minMaxBitsCmd As MinMaxBitsCommand = New MinMaxBitsCommand
   Dim minMaxValuesCmd As MinMaxValuesCommand = New MinMaxValuesCommand

   size = (1 << (leadImage.HighBit - leadImage.LowBit + 1))

   minMaxBitsCmd.Run(leadImage)
   _windowLevleDlg.LowBit = minMaxBitsCmd.MinimumBit
   _windowLevleDlg.HighBit = minMaxBitsCmd.MaximumBit

   minMaxValuesCmd.Run(leadImage)
   _windowLevleDlg.Low = minMaxValuesCmd.MinimumValue
   _windowLevleDlg.High = minMaxValuesCmd.MaximumValue

   ReDim _windowLevleDlg.LookupTable(size)
   _windowLevleDlg.AutoProcess = False
   _windowLevleDlg.Factor = 0
   _windowLevleDlg.Image = leadImage
   _windowLevleDlg.ZoomToFit = True
   _windowLevleDlg.ShowPreview = True
   _windowLevleDlg.ShowZoomLevel = True
   _windowLevleDlg.ShowHelp = False
   _windowLevleDlg.ShowRange = True
   _windowLevleDlg.Signed = leadImage.Signed
   _windowLevleDlg.StartColor = New Leadtools.RasterColor(0, 0, 0)
   _windowLevleDlg.EndColor = New Leadtools.RasterColor(255, 255, 255)
   _windowLevleDlg.WindowLevelFlags = Leadtools.RasterPaletteWindowLevelFlags.Inside Or Leadtools.RasterPaletteWindowLevelFlags.Linear

   If DialogResult.OK = _windowLevleDlg.ShowDialog(Nothing) Then

      Dim command As WindowLevelCommand = New WindowLevelCommand

      command.HighBit = _windowLevleDlg.HighBit
      command.LowBit = _windowLevleDlg.LowBit
      command.LookupTable = _windowLevleDlg.LookupTable
      command.Order = Leadtools.RasterByteOrder.Bgr

      command.Run(leadImage)
   End If

   ' save the resulted image
   codecs.Save(leadImage, Path.Combine(LEAD_VARS.ImagesDir, "WindowLevelDialogResult.bmp"), RasterImageFormat.Bmp, 24)
End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
public void windowLevelDlg_Help(object sender, RasterColorDialogHelpEventArgs e)
   {
      if(e.Dialog == RasterColorDialogHelpName.WindowLevel)
      {
         MessageBox.Show ( "Window Level dialog Help" );
      }
   }

   public void WindowLevelDialogExample()
   {
      // initialize the RasterCodecs
      RasterCodecs codecs = new RasterCodecs();

      // load an image
      RasterImage rasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"));

      int size ;
      RasterWindowLevelDialog windowLevelDlg = new RasterWindowLevelDialog();
      MinMaxBitsCommand minMaxBitsCmd= new MinMaxBitsCommand ( );
      MinMaxValuesCommand minMaxValuesCmd= new MinMaxValuesCommand ( );

      size= (1 << (rasterImage.HighBit - rasterImage.LowBit + 1));

      minMaxBitsCmd.Run ( rasterImage );
      windowLevelDlg.LowBit  = minMaxBitsCmd.MinimumBit ; 
      windowLevelDlg.HighBit = minMaxBitsCmd.MaximumBit ; 

      minMaxValuesCmd.Run ( rasterImage );
      windowLevelDlg.Low  = minMaxValuesCmd.MinimumValue ;
      windowLevelDlg.High = minMaxValuesCmd.MaximumValue ; 

      windowLevelDlg.AutoProcess    = false ;
      windowLevelDlg.Factor         = 0 ;
      windowLevelDlg.Image          = rasterImage ;
      windowLevelDlg.ZoomToFit      = true ;
      windowLevelDlg.ShowPreview    = true ;
      windowLevelDlg.ShowZoomLevel  = true ;
      windowLevelDlg.ShowHelp       = false ;
      windowLevelDlg.ShowRange      = true ;
      windowLevelDlg.Signed         = rasterImage.Signed;
      windowLevelDlg.LookupTable    = new Leadtools.RasterColor [size];
      windowLevelDlg.StartColor     = new Leadtools.RasterColor ( 0, 0 , 0 ) ; 
      windowLevelDlg.EndColor       = new Leadtools.RasterColor ( 255, 255, 255 ) ; 
      windowLevelDlg.WindowLevelFlags = Leadtools.RasterPaletteWindowLevelFlags.Inside | Leadtools.RasterPaletteWindowLevelFlags.Linear;
      windowLevelDlg.Help           += new EventHandler<RasterColorDialogHelpEventArgs>(windowLevelDlg_Help);


      if ( DialogResult.OK == windowLevelDlg.ShowDialog ( null ) )
      {
         WindowLevelCommand command = new WindowLevelCommand();

         command.HighBit     = windowLevelDlg.HighBit;
         command.LowBit      = windowLevelDlg.LowBit;
         command.LookupTable = windowLevelDlg.LookupTable;
         command.Order       = Leadtools.RasterByteOrder.Bgr;

         command.Run(rasterImage);
      }

      // save the resulted image
      codecs.Save(rasterImage, Path.Combine(LEAD_VARS.ImagesDir,"WindowLevelDialogResult.bmp"), RasterImageFormat.Bmp, 24);
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterWindowLevelDialog Members
Leadtools.WinForms.CommonDialogs.Color Namespace
Leadtools.RasterPalette.WindowLevelFillLookupTable(Leadtools.RasterColor[],Leadtools.RasterColor,Leadtools.RasterColor,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,Leadtools.RasterPaletteWindowLevelFlags)
Leadtools.ImageProcessing.Core.WindowLevelCommand

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.