Leadtools.Windows.Controls.Pro Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
RasterImageViewerElement Class
See Also  Members   Example 
Leadtools.Windows.Controls Namespace : RasterImageViewerElement Class





Represents a LEADTOOLS RasterImageViewerElement control for displaying an image.

Syntax

Visual Basic (Declaration) 
Public Class RasterImageViewerElement 
   Inherits BitmapSourceViewerElement
Visual Basic (Usage)Copy Code
Dim instance As RasterImageViewerElement
C# 
public class RasterImageViewerElement : BitmapSourceViewerElement 
C++/CLI 
public ref class RasterImageViewerElement : public BitmapSourceViewerElement 
XAML Object Element Usage 

<RasterImageViewerElement .../>

XAML Object Element Usage 

<RasterImageViewerElement .../>

Example

This example will create an instance of the RasterImageViewerElement control and add it to a form.

Visual BasicCopy Code
Private Class MyWindow1 : Inherits Window
   Private theViewer As RasterImageViewerElement
   Public Sub New()
      ' Create the viewer
      theViewer = New RasterImageViewerElement()

      ' 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.Frame = New Size(10, 5)
      theViewer.FrameBackground = Brushes.Red
      theViewer.FrameShadow = New Size(5, 5)
      theViewer.FrameShadowBackground = Brushes.Blue
      theViewer.UseDpi = True

      panel.Children.Add(theViewer)

          ' Load an image into the viewer

          theViewer.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp", 1, CodecsLoadByteOrder.Bgr, 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.MouseDown, AddressOf theViewer_MouseClick
      End Sub

      Private Sub theViewer_MouseClick(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
          Select Case theViewer.SizeMode
              Case PaintSizeMode.Normal
                  theViewer.SizeMode = PaintSizeMode.Stretch

              Case PaintSizeMode.Stretch
                  theViewer.SizeMode = PaintSizeMode.Fit

              Case PaintSizeMode.Fit
                  theViewer.SizeMode = PaintSizeMode.FitAlways

              Case PaintSizeMode.FitAlways
                  theViewer.SizeMode = PaintSizeMode.FitWidth

              Case PaintSizeMode.FitWidth
                  theViewer.SizeMode = PaintSizeMode.Normal
          End Select

          Title = String.Format("Size mode = {0}, double click to change", theViewer.SizeMode)

      End Sub
  End Class
C#Copy Code
class MyWindow1 : Window 

   RasterImageViewerElement theViewer; 
   public MyWindow1() 
   { 
      // Create the  viewer 
      theViewer = new RasterImageViewerElement(); 
 
      // Create Dock Panel 
 
      DockPanel panel = new DockPanel(); 
      Content = panel; 
 
      DockPanel.SetDock(theViewer, Dock.Bottom); 
 
      theViewer.HorizontalAlignment = HorizontalAlignment.Center; 
      theViewer.VerticalAlignment = VerticalAlignment.Bottom; 
      theViewer.Frame = new Size(10, 5); 
      theViewer.FrameBackground = Brushes.Red; 
      theViewer.FrameShadow = new Size(5, 5); 
      theViewer.FrameShadowBackground = Brushes.Blue; 
      theViewer.UseDpi = true; 
 
      panel.Children.Add(theViewer); 
 
      // Load an image into the viewer 
 
      theViewer.Load(LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp", 1, Leadtools.Codecs.CodecsLoadByteOrder.Bgr, 1); 
      FlipCommand flip = new FlipCommand(); 
      flip.Run(theViewer.Image); 
 
      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
      theViewer.MouseDown += new MouseButtonEventHandler(theViewer_MouseClick); 
   } 
 
   void theViewer_MouseClick(object sender, MouseButtonEventArgs e) 
   { 
      switch (theViewer.SizeMode) 
      { 
         case PaintSizeMode.Normal: 
            theViewer.SizeMode = PaintSizeMode.Stretch; 
            break; 
 
         case PaintSizeMode.Stretch: 
            theViewer.SizeMode = PaintSizeMode.Fit; 
            break; 
 
         case PaintSizeMode.Fit: 
            theViewer.SizeMode = PaintSizeMode.FitAlways; 
            break; 
 
         case PaintSizeMode.FitAlways: 
            theViewer.SizeMode = PaintSizeMode.FitWidth; 
            break; 
 
         case PaintSizeMode.FitWidth: 
            theViewer.SizeMode = PaintSizeMode.Normal; 
            break; 
      } 
 
      Title = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
   } 
}
XAMLCopy Code
<Window x:Class="WPFSamples.RasterImageViewerElement" Height="600" Width="800" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls.Pro"> 
  <DockPanel> 
    <Leadtools_Windows_Controls:RasterImageViewerElement Name="theViewer" Image="file:///C:\Program Files\LEAD Technologies\LEADTOOLS 16\Images\image1.jpg" DockPanel.Dock="Bottom" HorizontalAlignment="Center" VerticalAlignment="Bottom" Frame="10,5" FrameBackground="Red" FrameShadow="5,5" FrameShadowBackground="Blue" UseDpi="False" /> 
  </DockPanel> 
  <Window.Title> 
                "Size mode =Normal, double click to change" 
            </Window.Title> 
</Window>

Remarks

The RasterImageViewerElement is used to display graphics from a bitmap, metafile, icon, JPEG, GIF or PNG (or any other image file format supported by LEADTOOLS) file.
Set the Image property to the RasterImage object to be displayed.

Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.Media.Visual
            System.Windows.UIElement
               System.Windows.FrameworkElement
                  Leadtools.Windows.Controls.BitmapSourceViewerElement
                     Leadtools.Windows.Controls.RasterImageViewerElement

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family

See Also