Leadtools.WinForms.CommonDialogs.Color Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
RasterWindowLevelDialog Class
See Also  Members   Example 
Leadtools.WinForms.CommonDialogs.Color Namespace : RasterWindowLevelDialog Class



Displays the Window Level dialog box.

Syntax

Visual Basic (Declaration) 
Public Class RasterWindowLevelDialog 
   Inherits Form
Visual Basic (Usage)Copy Code
Dim instance As RasterWindowLevelDialog
C# 
public class RasterWindowLevelDialog : Form 
C++/CLI 
public ref class RasterWindowLevelDialog : public Form 

Example

Visual BasicCopy Code
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
   RasterCodecs.Startup()
   Dim codecs As New RasterCodecs()

   ' load an image
     Dim leadImage As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "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, LeadtoolsExamples.Common.ImagesPath.Path + "WindowLevelDialogResult.bmp", RasterImageFormat.Bmp, 24)
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
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.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // load an image 
   RasterImage rasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "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, LeadtoolsExamples.Common.ImagesPath.Path + "WindowLevelDialogResult.bmp", RasterImageFormat.Bmp, 24); 
   RasterCodecs.Shutdown(); 
}

Remarks

The Window Level dialog can be seen below:

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.Control
            System.Windows.Forms.ScrollableControl
               System.Windows.Forms.ContainerControl
                  System.Windows.Forms.Form
                     Leadtools.WinForms.CommonDialogs.Color.RasterWindowLevelDialog

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also