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



Represents a LEADTOOLS PictureBox control for displaying an image.

Syntax

Visual Basic (Declaration) 
<DefaultPropertyAttribute("Image")>
<DockingAttribute(DockingBehavior.Ask)>
<ToolboxBitmapAttribute()>
Public Class RasterPictureBox 
   Inherits Control
Visual Basic (Usage)Copy Code
Dim instance As RasterPictureBox
C# 
[DefaultPropertyAttribute("Image")]
[DockingAttribute(DockingBehavior.Ask)]
[ToolboxBitmapAttribute()]
public class RasterPictureBox : Control 
C++/CLI 
[DefaultPropertyAttribute("Image")]
[DockingAttribute(DockingBehavior.Ask)]
[ToolboxBitmapAttribute()]
public ref class RasterPictureBox : public Control 

Example

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

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

Private Class MyForm1 : Inherits Form
   Private thePictureBox As RasterPictureBox

   Public Sub New()
      ' Create the raster PictureBox
      thePictureBox = New RasterPictureBox()
      thePictureBox.Dock = DockStyle.Fill
      thePictureBox.BorderStyle = BorderStyle.Fixed3D
      thePictureBox.UseDpi = False

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

      Controls.Add(thePictureBox)
      thePictureBox.BringToFront()

      ' load an image into the viewer
      RasterCodecs.Startup()
      Dim codecs As RasterCodecs = New RasterCodecs()
          thePictureBox.Image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "eye.gif")
          codecs.Dispose()
          RasterCodecs.Shutdown()

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

          AddHandler thePictureBox.DoubleClick, AddressOf thePictureBox_DoubleClick
      End Sub

      Private Sub thePictureBox_DoubleClick(ByVal sender As Object, ByVal e As EventArgs)
          Select Case thePictureBox.SizeMode
              Case RasterPictureBoxSizeMode.Normal
                  thePictureBox.SizeMode = RasterPictureBoxSizeMode.StretchImage

              Case RasterPictureBoxSizeMode.StretchImage
                  thePictureBox.SizeMode = RasterPictureBoxSizeMode.Fit

              Case RasterPictureBoxSizeMode.Fit
                  thePictureBox.SizeMode = RasterPictureBoxSizeMode.AutoSize

              Case RasterPictureBoxSizeMode.AutoSize
                  thePictureBox.SizeMode = RasterPictureBoxSizeMode.CenterImage

              Case RasterPictureBoxSizeMode.CenterImage
                  thePictureBox.SizeMode = RasterPictureBoxSizeMode.Normal
          End Select

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

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

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

 
class MyForm1 : Form 

   RasterPictureBox thePictureBox; 
 
   public MyForm1() 
   { 
      // Create the raster PictureBox 
      thePictureBox = new RasterPictureBox(); 
      thePictureBox.Dock = DockStyle.Fill; 
      thePictureBox.BorderStyle = BorderStyle.Fixed3D; 
      thePictureBox.UseDpi = false; 
 
      // Set the paint properties 
      RasterPaintProperties p = new RasterPaintProperties(); 
      p.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic; 
      p.PaintEngine = RasterPaintEngine.GdiPlus; 
      p.UsePaintPalette = true; 
      thePictureBox.PaintProperties = p; 
 
      Controls.Add(thePictureBox); 
      thePictureBox.BringToFront(); 
 
      // load an image into the viewer 
      RasterCodecs.Startup(); 
      RasterCodecs codecs = new RasterCodecs(); 
      thePictureBox.Image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "eye.gif"); 
      codecs.Dispose(); 
      RasterCodecs.Shutdown(); 
 
      Text = string.Format("Size mode = {0}, double click to change", thePictureBox.SizeMode); 
 
      thePictureBox.DoubleClick += new EventHandler(thePictureBox_DoubleClick); 
   } 
 
   void thePictureBox_DoubleClick(object sender, EventArgs e) 
   { 
      switch (thePictureBox.SizeMode) 
      { 
         case RasterPictureBoxSizeMode.Normal: 
            thePictureBox.SizeMode = RasterPictureBoxSizeMode.StretchImage; 
            break; 
 
         case RasterPictureBoxSizeMode.StretchImage: 
            thePictureBox.SizeMode = RasterPictureBoxSizeMode.Fit; 
            break; 
 
         case RasterPictureBoxSizeMode.Fit: 
            thePictureBox.SizeMode = RasterPictureBoxSizeMode.AutoSize; 
            break; 
 
         case RasterPictureBoxSizeMode.AutoSize: 
            thePictureBox.SizeMode = RasterPictureBoxSizeMode.CenterImage; 
            break; 
 
         case RasterPictureBoxSizeMode.CenterImage: 
            thePictureBox.SizeMode = RasterPictureBoxSizeMode.Normal; 
            break; 
      } 
 
      Text = string.Format("Size mode = {0}, double click to change", thePictureBox.SizeMode); 
 
      base.OnDoubleClick(e); 
   } 
}

Remarks

The RasterPictureBox 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 RasterPictureBox control can automatically animate Multi-Page file formats.

Inheritance Hierarchy

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

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