Gets the bounding rectangle of the image region.
Syntax
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 Basic | Copy 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"
Dim image As RasterImage = codecs.Load(srcFileName)
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)
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