LEADTOOLS (Leadtools assembly)
LEAD Technologies, Inc

CalculatePaintModeRectangle Method

Example 





The width of the source rectangle.
The height of the source rectangle.
Destination rectangle.
Controls how the source rectangle is positioned inside the destination rectangle.
Controls how the source rectangle is aligned horizontally inside the destination rectangle.
Controls how the source rectangle is aligned vertically inside the destination rectangle.
Adjusts the given rectangle based on the given paint mode properties. .NET support Silverlight support WinRT support
Syntax
'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
'Usage
 
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)
 function Leadtools.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.
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.

Example
 
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
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);
}
RasterImageExamples.prototype.CalculatePaintModeRectangleExample = function ( ) 
{
   Tools.SetLicense ( ) ;
   with ( Leadtools ) 
   {
      // assume image width/height of 3000 x 1000
      // assume client rectangle of 500 x 500
      var client = LeadRectHelper.create(0, 0, 500, 500);
      var fit = RasterImage.calculatePaintModeRectangle(3000, 1000, client, RasterPaintSizeMode.fit, RasterPaintAlignMode.near, RasterPaintAlignMode.near);
      console.info(fit.x + "," + fit.y+ "," + fit.width + "," + fit.height);
   }
}
[TestMethod]
public void CalculatePaintModeRectangleExample()
{
   // assume image width/height of 3000 x 1000
   // assume client rectangle of 500 x 500
   LeadRect client = LeadRectHelper.Create(0, 0, 500, 500);
   LeadRect fit = RasterImage.CalculatePaintModeRectangle(3000, 1000, client, RasterPaintSizeMode.Fit, RasterPaintAlignMode.Near, RasterPaintAlignMode.Near);
   Debug.WriteLine("{0},{1},{2},{3}", fit.X, fit.Y, fit.Width, fit.Height);
}
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

RasterImage Class
RasterImage Members

 

 


Products | Support | Contact Us | Copyright Notices

© 2006-2012 All Rights Reserved. LEAD Technologies, Inc.