RasterWindowLevelDialog Class

Summary

Displays the Window Level dialog box.

Syntax
C#
VB
C++
public class RasterWindowLevelDialog : Form 
  
Public Class RasterWindowLevelDialog  
   Inherits System.Windows.Forms.Form 
   Implements System.ComponentModel.IComponent, System.ComponentModel.ISynchronizeInvoke, System.IDisposable, System.Windows.Forms.IBindableComponent, System.Windows.Forms.IContainerControl, System.Windows.Forms.IDropTarget, System.Windows.Forms.IWin32Window  
public ref class RasterWindowLevelDialog : public System.Windows.Forms.Form, System.ComponentModel.IComponent, System.ComponentModel.ISynchronizeInvoke, System.IDisposable, System.Windows.Forms.IBindableComponent, System.Windows.Forms.IContainerControl, System.Windows.Forms.IDropTarget, System.Windows.Forms.IWin32Window   

Remarks

The Window Level dialog can be seen below:

windowleveldialog.jpg

Example
C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
using Leadtools.WinForms.CommonDialogs.Color; 
 
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, "ImageProcessingDemo\\Beauty16.jpg")); 
 
   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"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing.Core 
Imports Leadtools.WinForms.CommonDialogs.Color 
 
Public Sub windowLevelDlg_Help(sender As Object, e As RasterColorDialogHelpEventArgs) 
   If e.Dialog = RasterColorDialogHelpName.WindowLevel Then 
      MessageBox.Show("Window Level dialog Help") 
   End If 
End Sub 
 
WithEvents _windowLevleDlg As New RasterWindowLevelDialog 
Public Sub WindowLevelDialogExample() 
   ' initialize the RasterCodecs 
   Dim codecs As New RasterCodecs() 
 
   ' load an image 
   Dim rasterImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "ImageProcessingDemo\Beauty16.jpg")) 
 
   Dim size As Integer 
   Dim windowLevelDlg As New RasterWindowLevelDialog() 
   Dim minMaxBitsCmd As New MinMaxBitsCommand() 
   Dim minMaxValuesCmd As 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 - 1) {} 
   windowLevelDlg.StartColor = New Leadtools.RasterColor(0, 0, 0) 
   windowLevelDlg.EndColor = New Leadtools.RasterColor(255, 255, 255) 
   windowLevelDlg.WindowLevelFlags = Leadtools.RasterPaletteWindowLevelFlags.Inside Or Leadtools.RasterPaletteWindowLevelFlags.Linear 
   AddHandler windowLevelDlg.Help, AddressOf windowLevelDlg_Help 
 
 
   If DialogResult.OK = windowLevelDlg.ShowDialog(Nothing) Then 
      Dim command As New WindowLevelCommand() 
 
      command.HighBit = windowLevelDlg.HighBit 
      command.LowBit = windowLevelDlg.LowBit 
      command.LookupTable = windowLevelDlg.LookupTable 
      command.Order = Leadtools.RasterByteOrder.Bgr 
 
      command.Run(rasterImage) 
   End If 
 
   ' save the resulted image 
   codecs.Save(rasterImage, 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 

Requirements

Target Platforms

Help Version 20.0.2020.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.