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



Controls the speed, quality, and style used when painting a RasterImage object.

Syntax

Visual Basic (Declaration)  
Public Structure RasterPaintProperties 
   Inherits ValueType
Visual Basic (Usage) Copy Code
Dim instance As RasterPaintProperties
C#  
public struct RasterPaintProperties : ValueType 
C++/CLI  
public value class RasterPaintProperties : public ValueType 

Example

This example creates a windows form with various controls to shows the different RasterPaintProperties options

Visual Basic Copy Code
Public Sub RasterPaintPropertiesExample()
 ' Create the form
 Dim form As PaintPropertiesForm = New PaintPropertiesForm()
 form.ShowDialog()
      End Sub

      Private Class PaintPropertiesForm : Inherits Form
 Private index As Integer = 0
 Private image As RasterImage
 Private paintProperties As RasterPaintProperties

 Public Sub New()
    Text = "Double click to show next RasterPaintProperties options"
    SetStyle(ControlStyles.ResizeRedraw, True)
    SetStyle(ControlStyles.AllPaintingInWmPaint, True)
    SetStyle(ControlStyles.OptimizedDoubleBuffer, True)
    SetStyle(ControlStyles.UserPaint, True)

    ' Load an image
    Dim fileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"

    RasterCodecs.Startup()
    Dim codecs As RasterCodecs = New RasterCodecs()
    Try
       codecs.ThrowExceptionsOnInvalidImages = True
       Image = codecs.Load(fileName)
    Finally
       CType(codecs, IDisposable).Dispose()
    End Try
    RasterCodecs.Shutdown()

    paintProperties = RasterPaintProperties.Default
 End Sub

 Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
       If Not Image Is Nothing Then
          Image.Dispose()
       End If
    End If

    MyBase.Dispose(disposing)
 End Sub

 Protected Overrides Sub OnDoubleClick(ByVal e As EventArgs)
    Select Case index
       Case 0
          Text = "SourceAnd ROP - Double click to show next RasterPaintProperties options"
          paintProperties.RasterOperation = RasterPaintProperties.SourceAnd

       Case 1
          Text = "Scale to gray - Double click to show next RasterPaintProperties options"
          paintProperties.RasterOperation = RasterPaintProperties.SourceCopy
          paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.ScaleToGray

       Case 2
          Text = "GDI+ paint engine - Done"
          paintProperties.PaintEngine = RasterPaintEngine.GdiPlus

       Case Else
    End Select

    index += 1
    Invalidate()
    MyBase.OnDoubleClick(e)
 End Sub

 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    ' Paint the image
    Dim destRect As Rectangle = RasterImage.CalculatePaintModeRectangle(image.ImageWidth, image.ImageHeight, ClientRectangle, RasterPaintSizeMode.Fit, RasterPaintAlignMode.Center, RasterPaintAlignMode.Center)

    Image.Paint(e.Graphics, destRect, paintProperties)

    MyBase.OnPaint(e)
 End Sub
      End Class
C# Copy Code
public void RasterPaintPropertiesExample() 

   // Create the form 
   PaintPropertiesForm form = new PaintPropertiesForm(); 
   form.ShowDialog(); 

 
class PaintPropertiesForm : Form 

   int index = 0; 
   RasterImage rasterImage; 
   RasterPaintProperties paintProperties; 
 
   public PaintPropertiesForm() 
   { 
      Text = "Double click to show next RasterPaintProperties options"; 
      SetStyle(ControlStyles.ResizeRedraw, true); 
      SetStyle(ControlStyles.AllPaintingInWmPaint, true); 
      SetStyle(ControlStyles.OptimizedDoubleBuffer, true); 
      SetStyle(ControlStyles.UserPaint, true); 
 
      // Load an image 
      string fileName = LeadtoolsExamples.Common.ImagesPath.Path + "Ocr1.tif"; 
 
      RasterCodecs.Startup(); 
      using(RasterCodecs codecs = new RasterCodecs()) 
      { 
         codecs.ThrowExceptionsOnInvalidImages = true; 
         rasterImage = codecs.Load(fileName); 
      } 
      RasterCodecs.Shutdown(); 
 
      paintProperties = RasterPaintProperties.Default; 
   } 
 
   protected override void Dispose(bool disposing) 
   { 
      if(disposing) 
      { 
         if(rasterImage != null) 
            rasterImage.Dispose(); 
      } 
 
      base.Dispose(disposing); 
   } 
 
   protected override void OnDoubleClick(EventArgs e) 
   { 
      switch(index) 
      { 
         case 0: 
            Text = "SourceAnd ROP - Double click to show next RasterPaintProperties options"; 
            paintProperties.RasterOperation = RasterPaintProperties.SourceAnd; 
            break; 
 
         case 1: 
            Text = "Scale to gray - Double click to show next RasterPaintProperties options"; 
            paintProperties.RasterOperation = RasterPaintProperties.SourceCopy; 
            paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.ScaleToGray; 
            break; 
 
         case 2: 
            Text = "GDI+ paint engine - Done"; 
            paintProperties.PaintEngine = RasterPaintEngine.GdiPlus; 
            break; 
 
         default: 
            break; 
      } 
 
      index++; 
      Invalidate(); 
      base.OnDoubleClick(e); 
   } 
 
   protected override void OnPaint(PaintEventArgs e) 
   { 
      // Paint the image 
      Rectangle destRect = RasterImage.CalculatePaintModeRectangle( 
         rasterImage.ImageWidth, 
         rasterImage.ImageHeight, 
         ClientRectangle, 
         RasterPaintSizeMode.Fit, 
         RasterPaintAlignMode.Center, 
         RasterPaintAlignMode.Center); 
 
      rasterImage.Paint(e.Graphics, destRect, paintProperties); 
 
      base.OnPaint(e); 
   } 
}

Remarks

The various RasterImage.Paint method overloads requires an instance of RasterPaintProperties to be passed. The members of the of the RasterPaintProperties passed controls the speed, quality, and style used when painting.

Inheritance Hierarchy

System.Object
   System.ValueType
      Leadtools.RasterPaintProperties

Requirements

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

See Also