←Select platform

PaintRegion(RasterImage,Graphics,LeadRect,LeadRect,LeadRect,LeadRect,RasterPaintProperties) Method

Summary
Paints the image region to a System.Drawing.Graphics object.
Syntax
C#
VB
C++
Public Overloads Shared Sub PaintRegion( _ 
   ByVal image As RasterImage, _ 
   ByVal graphics As Graphics, _ 
   ByVal srcRect As LeadRect, _ 
   ByVal srcClipRect As LeadRect, _ 
   ByVal destRect As LeadRect, _ 
   ByVal destClipRect As LeadRect, _ 
   ByVal properties As RasterPaintProperties _ 
)  

Parameters

image
The source image.

graphics
The destination System.Drawing.Graphics object where the image region will be displayed.

srcRect
A Leadtools.LeadRect object that specifies the part of the image to use as the display source.

The coordinates in the srcRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image.

srcClipRect
A Leadtools.LeadRect object specifies the portion of the display source to paint. Generally, this is used for updating the display when part of the source image has changed.

The coordinates in the srcClipRect rectangle are relative to the image. You can pass Rectangle.Empty to use the default, which matches the image

destRect
A Leadtools.LeadRect object that determines how the source rectangle is scaled and how the image is positioned in the destination graphics object.

The coordinates in the destRect object are relative to the graphics object. There is no default for this parameter. You must specify the Leadtools.LeadRect object.

destClipRect
A Leadtools.LeadRect object that specifies the portion of the display rectangle to paint. Generally, this is used for updating changes in the display surface, such as when a user moves another window, uncovering a part of the image that had been covered up.

The coordinates in the destClipRect are relative to the System.Drawing.Graphics object. You can pass Rectangle.Empty to use the default, which matches the System.Drawing.Graphics object. In most cases, however, you should use the rectangle returned by the .NET PaintEventArgs.ClipRectangle or Windows WM_PAINT message.

properties
Options for the display.

Remarks

This method works the same as Paint(RasterImage,Graphics,LeadRect,RasterPaintProperties), except that only the image region is painted.

Example
C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
 
 
public void PaintRegionExample() 
{ 
   PaintRegionForm f = new PaintRegionForm(); 
   f.ShowDialog(); 
} 
 
class PaintRegionForm : Form 
{ 
   private RasterImage image; 
 
   public PaintRegionForm() 
   { 
      // Load the image 
      RasterCodecs codecs = new RasterCodecs(); 
 
      string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
      image = codecs.Load(srcFileName); 
 
      // add a region to the image 
      image.AddEllipseToRegion( 
         RasterRegionXForm.Default, 
         new LeadRect(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2), 
         RasterRegionCombineMode.Set); 
 
      Text = "PaintRegion Example"; 
   } 
 
   protected override void Dispose(bool disposing) 
   { 
      // Clean up 
      if (disposing) 
      { 
         image.Dispose(); 
      } 
 
      base.Dispose(disposing); 
   } 
 
   protected override void OnPaint(PaintEventArgs e) 
   { 
      // Draw the image fit and center on this form 
      LeadRect destRect = LeadRect.FromLTRB(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Right, ClientRectangle.Bottom); 
      destRect = RasterImage.CalculatePaintModeRectangle( 
         image.ImageWidth, 
         image.ImageHeight, 
         destRect, 
         RasterPaintSizeMode.Fit, 
         RasterPaintAlignMode.Center, 
         RasterPaintAlignMode.Center); 
 
      RasterImagePainter.PaintRegion(image, e.Graphics, LeadRect.Empty, LeadRect.Empty, destRect, LeadRect.Empty, RasterPaintProperties.Default); 
 
      base.OnPaint(e); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Drawing 
Imports Leadtools.ImageProcessing 
 
Public Sub PaintRegionExample() 
   Dim f As New PaintRegionForm() 
   f.ShowDialog() 
End Sub 
 
Class PaintRegionForm 
   Inherits Form 
   Private image As RasterImage 
 
   Public Sub New() 
      ' Load the image 
      Dim codecs As New RasterCodecs() 
 
      Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp") 
      image = codecs.Load(srcFileName) 
 
      ' add a region to the image 
      image.AddEllipseToRegion( 
         RasterRegionXForm.Default, 
         New LeadRect(image.Width \ 4, image.Height \ 4, image.Width \ 2, image.Height \ 2), 
         RasterRegionCombineMode.Set) 
 
      Text = "PaintRegion Example" 
   End Sub 
 
   Protected Overrides Sub Dispose(ByVal disposing As Boolean) 
      ' Clean up 
      If disposing Then 
         image.Dispose() 
      End If 
 
      MyBase.Dispose(disposing) 
   End Sub 
 
   Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) 
      ' Draw the image fit and center on this form 
      Dim destRect As LeadRect = LeadRect.FromLTRB(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Right, ClientRectangle.Bottom) 
      destRect = RasterImage.CalculatePaintModeRectangle( 
         image.ImageWidth, 
         image.ImageHeight, 
         destRect, 
         RasterPaintSizeMode.Fit, 
         RasterPaintAlignMode.Center, 
         RasterPaintAlignMode.Center) 
 
      RasterImagePainter.PaintRegion(image, e.Graphics, LeadRect.Empty, LeadRect.Empty, destRect, LeadRect.Empty, RasterPaintProperties.Default) 
 
      MyBase.OnPaint(e) 
   End Sub 
End Class 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images" 
End Class 
Requirements

Target Platforms

Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Drawing Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.