Leadtools Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
GetRegionBounds Method
See Also  Example
Leadtools Namespace > RasterImage Class : GetRegionBounds Method



xform
RasterRegionXForm object that LEADTOOLS uses to translate between display coordinates and image coordinates. If you specify null (Nothing in Visual Basic) in this parameter, the scalar fields default to 1, the offsets default to 0, and the view perspective defaults to the image view perspective.
Gets the bounding rectangle of the image region.

Syntax

Visual Basic (Declaration) 
Public Function GetRegionBounds( _
   ByVal xform As RasterRegionXForm _
) As Rectangle
Visual Basic (Usage)Copy Code
Dim instance As RasterImage
Dim xform As RasterRegionXForm
Dim value As Rectangle
 
value = instance.GetRegionBounds(xform)
C# 
public Rectangle GetRegionBounds( 
   RasterRegionXForm xform
)
C++/CLI 
public:
Rectangle GetRegionBounds( 
   RasterRegionXForm^ xform
) 

Parameters

xform
RasterRegionXForm object that LEADTOOLS uses to translate between display coordinates and image coordinates. If you specify null (Nothing in Visual Basic) in this parameter, the scalar fields default to 1, the offsets default to 0, and the view perspective defaults to the image view perspective.

Return Value

The bounding rectangle.

Example

Visual BasicCopy Code
Public Sub GetRegionBoundsExample()
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()

   Dim srcFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"
   Dim destFileName As String = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_GetRegionBounds.bmp"

   ' Load the image
   Dim image As RasterImage = codecs.Load(srcFileName)

   ' Add an ellipse inside a rectangle region to the image

   Dim rc As Rectangle = New Rectangle(image.Width \ 3, image.Height \ 3, image.Width \ 3, image.Height \ 3)
   image.AddEllipseToRegion(Nothing, rc, RasterRegionCombineMode.Set)

   rc = image.GetRegionBounds(Nothing)

   image.AddRectangleToRegion(Nothing, rc, RasterRegionCombineMode.Xor)

   ' Invert the region area and save the image
   Dim command As InvertCommand = New InvertCommand()
   command.Run(image)
   codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24)

   image.Dispose()
   codecs.Dispose()
   RasterCodecs.Shutdown()
End Sub
C#Copy Code
public void GetRegionBoundsExample() 

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1.cmp"; 
   string destFileName = LeadtoolsExamples.Common.ImagesPath.Path + "Image1_GetRegionBounds.bmp"; 
 
   // Load the image 
   RasterImage image = codecs.Load(srcFileName); 
 
   // Add an ellipse inside a rectangle region to the image 
 
   Rectangle rc = new Rectangle(image.Width / 3, image.Height / 3, image.Width / 3, image.Height / 3); 
   image.AddEllipseToRegion(null, rc, RasterRegionCombineMode.Set); 
 
   rc = image.GetRegionBounds(null); 
 
   image.AddRectangleToRegion(null, rc, RasterRegionCombineMode.Xor); 
 
   // Invert the region area and save the image 
   InvertCommand command = new InvertCommand(); 
   command.Run(image); 
   codecs.Save(image, destFileName, RasterImageFormat.Bmp, 24); 
 
   image.Dispose(); 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Requirements

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

See Also