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



viewPerspective
Destination view perspective to which the rectangle should be translated.
rc
The rectangle to translate.
Translates a rectangle from this RasterImage view perspective to the specified view perspective.

Syntax

Visual Basic (Declaration)  
Public Function RectangleFromImage( _
   ByVal viewPerspective As RasterViewPerspective, _
   ByVal rc As Rectangle _
) As Rectangle
Visual Basic (Usage) Copy Code
Dim instance As RasterImage
Dim viewPerspective As RasterViewPerspective
Dim rc As Rectangle
Dim value As Rectangle
 
value = instance.RectangleFromImage(viewPerspective, rc)
C#  
public Rectangle RectangleFromImage( 
   RasterViewPerspective viewPerspective,
   Rectangle rc
)
C++/CLI  
public:
Rectangle RectangleFromImage( 
   RasterViewPerspective viewPerspective,
   Rectangle rc
) 

Parameters

viewPerspective
Destination view perspective to which the rectangle should be translated.
rc
The rectangle to translate.

Return Value

The translated rectangle.

Example

This example finds out where the selected rectangle of the image would be in a TopLeft ViewPerspective.

Visual Basic Copy Code
Public Sub RectangleFromImageExample()
   RasterCodecs.Startup()
   Dim codecs As RasterCodecs = New RasterCodecs()
   ' Load an image that has BottomLeft ViewPerspective
   Dim image As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "ULAY1.BMP")

   Dim ImageRectangle As Rectangle = New Rectangle(0, 0, image.Width - 1, image.Height - 1)
   ImageRectangle = image.RectangleFromImage(RasterViewPerspective.TopLeft, ImageRectangle)
   Console.WriteLine(String.Format("{0},{1},{2},{3}", ImageRectangle.Left, ImageRectangle.Top, ImageRectangle.Right, ImageRectangle.Bottom))

   ImageRectangle = New Rectangle(0, 0, image.Width - 1, image.Height - 1)
   ImageRectangle = image.RectangleToImage(RasterViewPerspective.TopLeft, ImageRectangle)
   Console.WriteLine(String.Format("{0},{1},{2},{3}", ImageRectangle.Left, ImageRectangle.Top, ImageRectangle.Right, ImageRectangle.Bottom))

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

   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   // Load an image that has BottomLeft ViewPerspective 
   RasterImage image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "ULAY1.BMP"); 
 
   Rectangle ImageRectangle = new Rectangle(0, 0, image.Width - 1, image.Height - 1); 
   ImageRectangle = image.RectangleFromImage(Leadtools.RasterViewPerspective.TopLeft, ImageRectangle); 
   Console.WriteLine(string.Format("{0},{1},{2},{3}", ImageRectangle.Left, ImageRectangle.Top, ImageRectangle.Right, ImageRectangle.Bottom)); 
 
   ImageRectangle = new Rectangle(0, 0, image.Width - 1, image.Height - 1); 
   ImageRectangle = image.RectangleToImage(Leadtools.RasterViewPerspective.TopLeft, ImageRectangle); 
   Console.WriteLine(string.Format("{0},{1},{2},{3}", ImageRectangle.Left, ImageRectangle.Top, ImageRectangle.Right, ImageRectangle.Bottom)); 
 
   image.Dispose(); 
   codecs.Dispose(); 
   RasterCodecs.Shutdown(); 
}

Remarks

For more information, refer to Accounting for View Perspective.

For more information, refer to Changing Image Coordinates.

Requirements

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

See Also