←Select platform

RasterPictureBox Class

Summary

Represents a LEADTOOLS PictureBox control for displaying an image.

Syntax

C#
VB
C++
[DefaultPropertyAttribute("Image")] 
[DefaultEventAttribute("FrameChanged")] 
[DockingAttribute(System.Windows.Forms.DockingBehavior)] 
public class RasterPictureBox : INotifyPropertyChanged, Control 
<DefaultEventAttribute("FrameChanged"),  
 DockingAttribute(System.Windows.Forms.DockingBehavior),  
 DefaultPropertyAttribute("Image")>  
Public Class RasterPictureBox 
   Inherits System.Windows.Forms.Control 
public [DefaultEventAttribute(L"FrameChanged"),  
   DockingAttribute(System::Windows::Forms::DockingBehavior),  
   DefaultPropertyAttribute(L"Image")] 
   ref class RasterPictureBox : System::Windows::Forms::Control 

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.

Example

C#
VB
using Leadtools; 
using Leadtools.Controls; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using LeadtoolsExamples.Common; 
 
public void RasterPictureBox_RasterPictureBox() 
{ 
   MyForm1 form = new MyForm1(); 
   form.ShowDialog(); 
} 
 
class MyForm1 : Form 
{ 
   private RasterPictureBox pictureBoxInstance; 
 
   public MyForm1() 
   { 
      // Create the raster PictureBox 
      pictureBoxInstance = new RasterPictureBox(); 
      pictureBoxInstance.Dock = DockStyle.Fill; 
      pictureBoxInstance.BorderStyle = BorderStyle.FixedSingle; 
      pictureBoxInstance.UseDpi = false; 
 
      // Set the paint properties 
      RasterPaintProperties paintProperties = RasterPaintProperties.Default; 
      paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic; 
      paintProperties.PaintEngine = RasterPaintEngine.GdiPlus; 
      paintProperties.UsePaintPalette = true; 
      pictureBoxInstance.PaintProperties = paintProperties; 
 
      this.Controls.Add(pictureBoxInstance); 
      pictureBoxInstance.BringToFront(); 
 
      // load an image into the viewer 
      using (RasterCodecs codecs = new RasterCodecs()) 
         pictureBoxInstance.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "eye.gif")); 
 
 
      Text = string.Format("Size mode = {0}, double click to change", pictureBoxInstance.SizeMode); 
 
      pictureBoxInstance.DoubleClick += new EventHandler(pictureBoxInstance_DoubleClick); 
   } 
 
   void pictureBoxInstance_DoubleClick(object sender, EventArgs e) 
   { 
      switch (pictureBoxInstance.SizeMode) 
      { 
         case RasterPictureBoxSizeMode.Normal: 
            pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.StretchImage; 
            break; 
 
         case RasterPictureBoxSizeMode.StretchImage: 
            pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.Fit; 
            break; 
 
         case RasterPictureBoxSizeMode.Fit: 
            pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.AutoSize; 
            break; 
 
         case RasterPictureBoxSizeMode.AutoSize: 
            pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.CenterImage; 
            break; 
 
         case RasterPictureBoxSizeMode.CenterImage: 
            pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.Normal; 
            break; 
      } 
 
      Text = string.Format("Size mode = {0}, double click to change", pictureBoxInstance.SizeMode); 
 
      base.OnDoubleClick(e); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools 
Imports Leadtools.Controls 
Imports Leadtools.Codecs 
Imports Leadtools.Drawing 
 
Public Sub RasterPictureBox_RasterPictureBox() 
   Dim form As MyForm1 = New MyForm1() 
   form.ShowDialog() 
End Sub 
 
Private Class MyForm1 : Inherits Form 
   Private pictureBoxInstance As RasterPictureBox 
 
   Public Sub New() 
      ' Create the raster PictureBox 
      pictureBoxInstance = New RasterPictureBox() 
      pictureBoxInstance.Dock = DockStyle.Fill 
      pictureBoxInstance.BorderStyle = BorderStyle.FixedSingle 
      pictureBoxInstance.UseDpi = False 
 
      ' Set the paint properties 
      Dim paintProperties As RasterPaintProperties = RasterPaintProperties.Default 
      paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic 
      paintProperties.PaintEngine = RasterPaintEngine.GdiPlus 
      paintProperties.UsePaintPalette = True 
      pictureBoxInstance.PaintProperties = paintProperties 
 
      Me.Controls.Add(pictureBoxInstance) 
      pictureBoxInstance.BringToFront() 
 
      ' load an image into the viewer 
      Using codecs As RasterCodecs = New RasterCodecs() 
         pictureBoxInstance.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "eye.gif")) 
      End Using 
 
 
      Text = String.Format("Size mode = {0}, double click to change", pictureBoxInstance.SizeMode) 
 
      AddHandler pictureBoxInstance.DoubleClick, AddressOf pictureBoxInstance_DoubleClick 
   End Sub 
 
   Private Sub pictureBoxInstance_DoubleClick(ByVal sender As Object, ByVal e As EventArgs) 
      Select Case pictureBoxInstance.SizeMode 
         Case RasterPictureBoxSizeMode.Normal 
            pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.StretchImage 
 
         Case RasterPictureBoxSizeMode.StretchImage 
            pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.Fit 
 
         Case RasterPictureBoxSizeMode.Fit 
            pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.AutoSize 
 
         Case RasterPictureBoxSizeMode.AutoSize 
            pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.CenterImage 
 
         Case RasterPictureBoxSizeMode.CenterImage 
            pictureBoxInstance.SizeMode = RasterPictureBoxSizeMode.Normal 
      End Select 
 
      Text = String.Format("Size mode = {0}, double click to change", pictureBoxInstance.SizeMode) 
 
      MyBase.OnDoubleClick(e) 
   End Sub 
End Class 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
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.Controls.WinForms Assembly