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




Represents a Leadtools ImageViewer control for displaying an image.

Object Model



Syntax

Visual Basic (Declaration) 
<ToolboxBitmapAttribute()>
<DesignerAttribute(DesignerBaseTypeName="System.ComponentModel.Design.IDesigner", DesignerTypeName="Leadtools.WinForms.RasterImageViewerDesigner, Leadtools.WinForms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")>
Public Class RasterImageViewer 
   Inherits Control
Visual Basic (Usage)Copy Code
Dim instance As RasterImageViewer
C# 
[ToolboxBitmapAttribute()]
[DesignerAttribute(DesignerBaseTypeName="System.ComponentModel.Design.IDesigner", DesignerTypeName="Leadtools.WinForms.RasterImageViewerDesigner, Leadtools.WinForms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")]
public class RasterImageViewer : Control 
Managed Extensions for C++ 
[ToolboxBitmapAttribute()]
[DesignerAttribute(DesignerBaseTypeName="System.ComponentModel.Design.IDesigner", DesignerTypeName="Leadtools.WinForms.RasterImageViewerDesigner, Leadtools.WinForms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")]
public __gc class RasterImageViewer : public Control 
C++/CLI 
[ToolboxBitmapAttribute()]
[DesignerAttribute(DesignerBaseTypeName="System.ComponentModel.Design.IDesigner", DesignerTypeName="Leadtools.WinForms.RasterImageViewerDesigner, Leadtools.WinForms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null")]
public ref class RasterImageViewer : public Control 

Example

This example will create an instance of the RasterImageViewer control and adds it to a form

Visual BasicCopy Code
Public Sub RasterImageViewer_RasterImageViewer()
   Dim form As MyForm1 = New MyForm1()
   form.ShowDialog()
End Sub

Private Class MyForm1 : Inherits Form
   Private theViewer As RasterImageViewer

   Public Sub New()
      ' Create the raster viewer
      theViewer = New RasterImageViewer()
      theViewer.Dock = DockStyle.Fill
      theViewer.DoubleBuffer = True
      theViewer.BorderStyle = BorderStyle.Fixed3D
      theViewer.AutoResetScaleFactor = True
      theViewer.AutoResetScrollPosition = True
      theViewer.HorizontalAlignMode = RasterPaintAlignMode.Center
      theViewer.VerticalAlignMode = RasterPaintAlignMode.Far
      theViewer.FrameSize = New SizeF(10, 5)
      theViewer.FrameColor = Color.Red
      theViewer.FramesIsPartOfImage = True
      theViewer.FrameShadowSize = New SizeF(5, 5)
      theViewer.FrameShadowColor = Color.Blue
      theViewer.AutoScroll = True
      theViewer.UseDpi = True

      ' Set the paint properties
      Dim p As RasterPaintProperties = New RasterPaintProperties()
      p.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic
      p.PaintEngine = RasterPaintEngine.GdiPlus
      p.UsePaintPalette = True
      theViewer.PaintProperties = p

      theViewer.AnimateRegion = True
      theViewer.EnableScrollingInterface = True

      Controls.Add(theViewer)
      theViewer.BringToFront()

      ' load an image into the viewer
      RasterCodecs.Startup()
      Dim codecs As RasterCodecs = New RasterCodecs()
      theViewer.Image = codecs.Load("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Sample1.cmp")
      codecs.Dispose()
      RasterCodecs.Shutdown()

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

      AddHandler theViewer.DoubleClick, AddressOf theViewer_DoubleClick
   End Sub

   Private Sub theViewer_DoubleClick(ByVal sender As Object, ByVal e As EventArgs)
      Select Case theViewer.SizeMode
         Case RasterPaintSizeMode.Normal
            theViewer.SizeMode = RasterPaintSizeMode.Stretch

         Case RasterPaintSizeMode.Stretch
            theViewer.SizeMode = RasterPaintSizeMode.Fit

         Case RasterPaintSizeMode.Fit
            theViewer.SizeMode = RasterPaintSizeMode.FitAlways

         Case RasterPaintSizeMode.FitAlways
            theViewer.SizeMode = RasterPaintSizeMode.FitWidth

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

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

      MyBase.OnDoubleClick(e)
   End Sub
End Class
C#Copy Code
public void RasterImageViewer_RasterImageViewer() 

   MyForm1 form = new MyForm1(); 
   form.ShowDialog(); 

 
class MyForm1 : Form 

   RasterImageViewer theViewer; 
 
   public MyForm1() 
   { 
      // Create the raster viewer 
      theViewer = new RasterImageViewer(); 
      theViewer.Dock = DockStyle.Fill; 
      theViewer.DoubleBuffer = true; 
      theViewer.BorderStyle = BorderStyle.Fixed3D; 
      theViewer.AutoResetScaleFactor = true; 
      theViewer.AutoResetScrollPosition= true; 
      theViewer.HorizontalAlignMode = RasterPaintAlignMode.Center; 
      theViewer.VerticalAlignMode = RasterPaintAlignMode.Far; 
      theViewer.FrameSize = new SizeF(10,5); 
      theViewer.FrameColor = Color.Red; 
      theViewer.FramesIsPartOfImage = true; 
      theViewer.FrameShadowSize = new SizeF(5, 5); 
      theViewer.FrameShadowColor = Color.Blue; 
      theViewer.AutoScroll = true; 
      theViewer.UseDpi = true; 
 
      // Set the paint properties 
      RasterPaintProperties p = new RasterPaintProperties(); 
      p.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic; 
      p.PaintEngine = RasterPaintEngine.GdiPlus; 
      p.UsePaintPalette = true; 
      theViewer.PaintProperties = p; 
 
      theViewer.AnimateRegion = true; 
      theViewer.EnableScrollingInterface = true; 
 
      Controls.Add(theViewer); 
      theViewer.BringToFront(); 
 
      // load an image into the viewer 
      RasterCodecs.Startup(); 
      RasterCodecs codecs = new RasterCodecs(); 
      theViewer.Image = codecs.Load(@"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Sample1.cmp"); 
      codecs.Dispose(); 
      RasterCodecs.Shutdown(); 
 
      Text = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
      theViewer.DoubleClick += new EventHandler(theViewer_DoubleClick); 
   } 
 
   void theViewer_DoubleClick(object sender, EventArgs e) 
   { 
      switch (theViewer.SizeMode) 
      { 
         case RasterPaintSizeMode.Normal: 
            theViewer.SizeMode = RasterPaintSizeMode.Stretch; 
            break; 
 
         case RasterPaintSizeMode.Stretch: 
            theViewer.SizeMode = RasterPaintSizeMode.Fit; 
            break; 
 
         case RasterPaintSizeMode.Fit: 
            theViewer.SizeMode = RasterPaintSizeMode.FitAlways; 
            break; 
 
         case RasterPaintSizeMode.FitAlways: 
            theViewer.SizeMode = RasterPaintSizeMode.FitWidth; 
            break; 
 
         case RasterPaintSizeMode.FitWidth: 
            theViewer.SizeMode = RasterPaintSizeMode.Normal; 
            break; 
      } 
 
      Text = string.Format("Size mode = {0}, double click to change", theViewer.SizeMode); 
 
      base.OnDoubleClick(e); 
   } 
}

Remarks

The RasterImageViewer 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 an RasterImage object to be displayed.
The RasterImageViewer control can automatically handle zooming and scrolling.
For information on using Annotations with the RasterImageViewer, refer to Implementing Annotations.

For information about 16bpp grayscale images, refer to The RasterPaintEngine Property and 16bpp Grayscale Images.

Inheritance Hierarchy

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.Control
            Leadtools.WinForms.RasterImageViewer

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