LEADTOOLS (Leadtools assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
CalculatePaintModeRectangle Method
See Also 
Leadtools Namespace > RasterImage Class : CalculatePaintModeRectangle Method



sourceWidth
The width of the source rectangle.
sourceHeight
The height of the source rectangle.
destinationRectangle
Destination rectangle.
sizeMode
Controls how the source rectangle is positioned inside the destination rectangle.
horizontalAlignMode
Controls how the source rectangle is aligned horizontally inside the destination rectangle.
verticalAlignMode
Controls how the source rectangle is aligned vertically inside the destination rectangle.
sourceWidth
The width of the source rectangle.
sourceHeight
The height of the source rectangle.
destinationRectangle
Destination rectangle.
sizeMode
Controls how the source rectangle is positioned inside the destination rectangle.
horizontalAlignMode
Controls how the source rectangle is aligned horizontally inside the destination rectangle.
verticalAlignMode
Controls how the source rectangle is aligned vertically inside the destination rectangle.
Adjusts the given rectangle based on the given paint mode properties. Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public Shared Function CalculatePaintModeRectangle( _
   ByVal sourceWidth As Integer, _
   ByVal sourceHeight As Integer, _
   ByVal destinationRectangle As LeadRect, _
   ByVal sizeMode As RasterPaintSizeMode, _
   ByVal horizontalAlignMode As RasterPaintAlignMode, _
   ByVal verticalAlignMode As RasterPaintAlignMode _
) As LeadRect
Visual Basic (Usage)Copy Code
Dim sourceWidth As Integer
Dim sourceHeight As Integer
Dim destinationRectangle As LeadRect
Dim sizeMode As RasterPaintSizeMode
Dim horizontalAlignMode As RasterPaintAlignMode
Dim verticalAlignMode As RasterPaintAlignMode
Dim value As LeadRect
 
value = RasterImage.CalculatePaintModeRectangle(sourceWidth, sourceHeight, destinationRectangle, sizeMode, horizontalAlignMode, verticalAlignMode)

Parameters

sourceWidth
The width of the source rectangle.
sourceHeight
The height of the source rectangle.
destinationRectangle
Destination rectangle.
sizeMode
Controls how the source rectangle is positioned inside the destination rectangle.
horizontalAlignMode
Controls how the source rectangle is aligned horizontally inside the destination rectangle.
verticalAlignMode
Controls how the source rectangle is aligned vertically inside the destination rectangle.

Return Value

The new destination rectangle adjusted based on the size mode and alignment.

Example

Visual BasicCopy Code
Public Sub CalculatePaintModeRectangleExample()
   ' assume image width/height of 3000 x 1000
   ' assume client rectangle of 500 x 500
   Dim client As LeadRect = New LeadRect(0, 0, 500, 500)
   Dim fit As LeadRect = RasterImage.CalculatePaintModeRectangle(3000, 1000, client, RasterPaintSizeMode.Fit, RasterPaintAlignMode.Near, RasterPaintAlignMode.Near)
   Console.WriteLine("{0},{1},{2},{3}", fit.Left, fit.Top, fit.Right, fit.Bottom)
End Sub
C#Copy Code
public void CalculatePaintModeRectangleExample()
{
   // assume image width/height of 3000 x 1000
   // assume client rectangle of 500 x 500
   LeadRect client = new LeadRect(0, 0, 500, 500);
   LeadRect fit = RasterImage.CalculatePaintModeRectangle(3000, 1000, client, RasterPaintSizeMode.Fit, RasterPaintAlignMode.Near, RasterPaintAlignMode.Near);
   Console.WriteLine("{0},{1},{2},{3}", fit.Left, fit.Top, fit.Right, fit.Bottom);
}
SilverlightCSharpCopy Code
SilverlightVBCopy Code

Remarks

This method allows you to calculate how a source rectangle can be adjusted into a destination rectangle based on a size mode and alignment.

Requirements

Target Platforms: Silverlight, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only), Windows Phone 7

See Also