←Select platform

RasterImageViewer Class

Summary

Represents a scrollable control that displays a LEADTOOLS Leadtools.RasterImage in WPF/Silverlight with interactive UI operations.

Syntax

C#
VB
C++
public class RasterImageViewer : ImageViewer 
  
Public Class RasterImageViewer  
   Inherits Leadtools.Windows.Controls.ImageViewer 
   Implements System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable  
public ref class RasterImageViewer : public Leadtools.Windows.Controls.ImageViewer, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable   

Remarks

The RasterImageViewer class derives from ImageViewer and adds functionality to display a LEADTOOLS Leadtools.RasterImage object in WPF/Silverlight applications. To display a System.Windows.Media.ImageSource or one of its derived classes, use the ImageViewer control.

In addition to all the features supported by the ImageViewer class, RasterImageViewer adds the following:

Example

C#
VB
Silverlight C#
Silverlight VB
using Leadtools.Help; 
using Leadtools.Windows.Controls; 
using Leadtools.ImageProcessing; 
using Leadtools.Codecs; 
 
class MyWindow1 : Window 
{ 
   RasterImageViewer theViewer; 
 
   public MyWindow1() 
   { 
      // Create the viewer 
      theViewer = new RasterImageViewer(); 
 
      // Create Dock Panel 
 
      DockPanel panel = new DockPanel(); 
      Content = panel; 
 
      DockPanel.SetDock(theViewer, Dock.Bottom); 
 
      theViewer.HorizontalAlignment = HorizontalAlignment.Center; 
      theViewer.VerticalAlignment = VerticalAlignment.Bottom; 
      theViewer.UseDpi = true; 
 
      panel.Children.Add(theViewer); 
 
      // Load an image into the viewer 
 
      using (RasterCodecs codecs = new RasterCodecs()) 
      { 
         theViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 1, Leadtools.Codecs.CodecsLoadByteOrder.Bgr, 1, 1); 
      } 
 
      FlipCommand flip = new FlipCommand(); 
      flip.Run(theViewer.Image); 
 
      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
      theViewer.MouseDoubleClick += new MouseButtonEventHandler(theViewer_MouseDoubleClick); 
   } 
 
   void theViewer_MouseDoubleClick(object sender, MouseButtonEventArgs e) 
   { 
      switch (theViewer.SizeMode) 
      { 
         case SizeMode.Normal: 
            theViewer.SizeMode = SizeMode.Stretch; 
            break; 
 
         case SizeMode.Stretch: 
            theViewer.SizeMode = SizeMode.Fit; 
            break; 
 
         case SizeMode.Fit: 
            theViewer.SizeMode = SizeMode.FitAlways; 
            break; 
 
         case SizeMode.FitAlways: 
            theViewer.SizeMode = SizeMode.FitWidth; 
            break; 
 
         case SizeMode.FitWidth: 
            theViewer.SizeMode = SizeMode.Normal; 
            break; 
      } 
 
      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools.Windows.Controls 
Imports Leadtools.ImageProcessing 
Imports Leadtools.Codecs 
Imports Leadtools 
 
Private Class MyWindow1 : Inherits Window 
   Private theViewer As RasterImageViewer 
 
   Public Sub New() 
      ' Create the viewer 
      theViewer = New RasterImageViewer() 
 
      ' Create Dock Panel 
 
      Dim panel As DockPanel = New DockPanel() 
      Content = panel 
 
      DockPanel.SetDock(theViewer, Dock.Bottom) 
 
      theViewer.HorizontalAlignment = HorizontalAlignment.Center 
      theViewer.VerticalAlignment = VerticalAlignment.Bottom 
      theViewer.UseDpi = True 
 
      panel.Children.Add(theViewer) 
 
      ' Load an image into the viewer 
 
      Using codecs As RasterCodecs = New RasterCodecs() 
         theViewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"), 1, CodecsLoadByteOrder.Bgr, 1, 1) 
      End Using 
 
      Dim flip As FlipCommand = New FlipCommand() 
      flip.Run(theViewer.Image) 
 
      Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode) 
 
      AddHandler theViewer.MouseDoubleClick, AddressOf theViewer_MouseDoubleClick 
   End Sub 
 
   Private Sub theViewer_MouseDoubleClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs) 
      Select Case theViewer.SizeMode 
         Case SizeMode.Normal 
            theViewer.SizeMode = SizeMode.Stretch 
 
         Case SizeMode.Stretch 
            theViewer.SizeMode = SizeMode.Fit 
 
         Case SizeMode.Fit 
            theViewer.SizeMode = SizeMode.FitAlways 
 
         Case SizeMode.FitAlways 
            theViewer.SizeMode = SizeMode.FitWidth 
 
         Case SizeMode.FitWidth 
            theViewer.SizeMode = SizeMode.Normal 
      End Select 
 
      Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode) 
 
   End Sub 
End Class 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 
using Leadtools.Help; 
using Leadtools.Windows.Controls; 
using Leadtools.ImageProcessing; 
using Leadtools.Codecs; 
 
class MyWindow1 : ChildWindow 
{ 
   RasterImageViewer theViewer; 
 
   public MyWindow1() 
   { 
      // Create the viewer 
      theViewer = new RasterImageViewer(); 
 
      // Create Dock Panel 
 
      StackPanel panel = new StackPanel(); 
      Content = panel; 
 
      theViewer.HorizontalAlignment = HorizontalAlignment.Center; 
      theViewer.VerticalAlignment = VerticalAlignment.Bottom; 
      theViewer.UseDpi = true; 
 
      panel.Children.Add(theViewer); 
 
      // Load an image into the viewer 
 
      RasterCodecs codecs = new RasterCodecs(); 
      theViewer.Image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp", 1, Leadtools.Codecs.CodecsLoadByteOrder.Bgr, 1, 1); 
 
      FlipCommand flip = new FlipCommand(); 
      flip.Run(theViewer.Image); 
 
      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
      theViewer.MouseLeftButtonDown += new MouseButtonEventHandler(theViewer_MouseLeftButtonDown); 
   } 
 
   void theViewer_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) 
   { 
      switch (theViewer.SizeMode) 
      { 
         case SizeMode.Normal: 
            theViewer.SizeMode = SizeMode.Stretch; 
            break; 
 
         case SizeMode.Stretch: 
            theViewer.SizeMode = SizeMode.Fit; 
            break; 
 
         case SizeMode.Fit: 
            theViewer.SizeMode = SizeMode.FitAlways; 
            break; 
 
         case SizeMode.FitAlways: 
            theViewer.SizeMode = SizeMode.FitWidth; 
            break; 
 
         case SizeMode.FitWidth: 
            theViewer.SizeMode = SizeMode.Normal; 
            break; 
      } 
 
      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
   } 
} 
Imports Leadtools 
Imports Leadtools.Windows.Controls 
Imports Leadtools.ImageProcessing 
Imports Leadtools.Codecs 
 
Private Class MyWindow1 : Inherits ChildWindow 
   Private theViewer As RasterImageViewer 
 
   Public Sub New() 
      ' Create the viewer 
      theViewer = New RasterImageViewer() 
 
      ' Create Dock Panel 
 
      Dim panel As StackPanel = New StackPanel() 
      Content = panel 
 
      theViewer.HorizontalAlignment = HorizontalAlignment.Center 
      theViewer.VerticalAlignment = VerticalAlignment.Bottom 
      theViewer.UseDpi = True 
 
      panel.Children.Add(theViewer) 
 
      ' Load an image into the viewer 
 
      Dim codecs As RasterCodecs = New RasterCodecs() 
      theViewer.Image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path & "Image1.cmp", 1, CodecsLoadByteOrder.Bgr, 1, 1) 
 
      Dim flip As FlipCommand = New FlipCommand() 
      flip.Run(theViewer.Image) 
 
      Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode) 
 
      AddHandler theViewer.MouseLeftButtonDown, AddressOf theViewer_MouseLeftButtonDown 
   End Sub 
 
   Private Sub theViewer_MouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs) 
      Select Case theViewer.SizeMode 
         Case SizeMode.Normal 
            theViewer.SizeMode = SizeMode.Stretch 
 
         Case SizeMode.Stretch 
            theViewer.SizeMode = SizeMode.Fit 
 
         Case SizeMode.Fit 
            theViewer.SizeMode = SizeMode.FitAlways 
 
         Case SizeMode.FitAlways 
            theViewer.SizeMode = SizeMode.FitWidth 
 
         Case SizeMode.FitWidth 
            theViewer.SizeMode = SizeMode.Normal 
      End Select 
 
      Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode) 
   End Sub 
End Class 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Windows.Controls Assembly