Search Results for

    Show / Hide Table of Contents

    Class CropRectangle

    A universally compatible Rectangle for .NET 7, .NET 6, .NET 5, and .NET Core. As well as compatiblity with Windows, NanoServer, IIS, macOS, Mobile, Xamarin, iOS, Android, Google Compute, Azure, AWS, and Linux.

    Works nicely with popular Image Rectangle such as System.Drawing.Rectangle, SkiaSharp.SKRect, SixLabors.ImageSharp.Rectangle, Microsoft.Maui.Graphics.Rect.

    Implicit casting means that using this class to input and output Rectangle from public API's gives full compatibility to all Rectangle type fully supported by Microsoft.

    Inheritance
    System.Object
    CropRectangle
    Namespace: IronSoftware.Drawing
    Assembly: IronSoftware.Drawing.Common.dll
    Syntax
    public class CropRectangle : Object

    Constructors

    CropRectangle()

    Construct a new CropRectangle.

    Declaration
    public CropRectangle()
    See Also
    CropRectangle

    CropRectangle(Int32, Int32, Int32, Int32, MeasurementUnits)

    Construct a new CropRectangle.

    Declaration
    public CropRectangle(int x, int y, int width, int height, MeasurementUnits units)
    Parameters
    Type Name Description
    System.Int32 x

    The x-coordinate of the upper-left corner of this Rectangle

    System.Int32 y

    The y-coordinate of the upper-left corner of this Rectangle

    System.Int32 width

    The width of this Rectangle

    System.Int32 height

    The height of this Rectangle

    MeasurementUnits units

    The measurement unit of this Rectangle

    See Also
    CropRectangle

    Properties

    Bottom

    Gets the y-coordinate of the bottom edge of this CropRectangle.

    Declaration
    public int Bottom { get; }
    Property Value
    Type Description
    System.Int32

    Height

    The height of this Rectangle. The default is 0.

    Declaration
    public int Height { get; set; }
    Property Value
    Type Description
    System.Int32

    Left

    Gets the x-coordinate of the left edge of this CropRectangle.

    Declaration
    public int Left { get; }
    Property Value
    Type Description
    System.Int32

    Right

    Gets the x-coordinate of the right edge of this CropRectangle.

    Declaration
    public int Right { get; }
    Property Value
    Type Description
    System.Int32

    Top

    Gets the y-coordinate of the top edge of this CropRectangle.

    Declaration
    public int Top { get; }
    Property Value
    Type Description
    System.Int32

    Units

    The measurement unit of this Rectangle. The default is Pixels

    Declaration
    public MeasurementUnits Units { get; set; }
    Property Value
    Type Description
    MeasurementUnits

    Width

    The width of this Rectangle. The default is 0.

    Declaration
    public int Width { get; set; }
    Property Value
    Type Description
    System.Int32

    X

    The x-coordinate of the upper-left corner of this Rectangle. The default is 0.

    Declaration
    public int X { get; set; }
    Property Value
    Type Description
    System.Int32

    Y

    The y-coordinate of the upper-left corner of this Rectangle. The default is 0.

    Declaration
    public int Y { get; set; }
    Property Value
    Type Description
    System.Int32

    Methods

    Contains(Int32, Int32)

    Determines if the specified point is contained within the rectangular region defined by this CropRectangle.

    Declaration
    public bool Contains(int x, int y)
    Parameters
    Type Name Description
    System.Int32 x

    The x-coordinate of the given point.

    System.Int32 y

    The y-coordinate of the given point.

    Returns
    Type Description
    System.Boolean

    ConvertTo(MeasurementUnits, Int32)

    Convert this crop rectangle to the specified units of measurement using the specified DPI

    Further Documentation:
    Code Example

    Declaration
    public CropRectangle ConvertTo(MeasurementUnits units, int dpi = 96)
    Parameters
    Type Name Description
    MeasurementUnits units

    Unit of measurement

    System.Int32 dpi

    DPI (Dots per inch) for conversion

    Returns
    Type Description
    CropRectangle

    A new crop rectangle which uses the desired units of measurement

    Exceptions
    Type Condition
    System.NotImplementedException

    Conversion not implemented

    Operators

    Implicit(CropRectangle to Rect)

    Implicitly casts to Microsoft.Maui.Graphics.Rect objects from CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support Microsoft.Maui.Graphics.Rect as well.

    Declaration
    public static implicit operator Rect(CropRectangle CropRectangle)
    Parameters
    Type Name Description
    CropRectangle CropRectangle

    CropRectangle is explicitly cast to a Microsoft.Maui.Graphics.Rect.

    Returns
    Type Description
    Microsoft.Maui.Graphics.Rect

    Implicit(CropRectangle to RectF)

    Implicitly casts to Microsoft.Maui.Graphics.RectF objects from CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support Microsoft.Maui.Graphics.RectF as well.

    Declaration
    public static implicit operator RectF(CropRectangle CropRectangle)
    Parameters
    Type Name Description
    CropRectangle CropRectangle

    CropRectangle is explicitly cast to a Microsoft.Maui.Graphics.RectF.

    Returns
    Type Description
    Microsoft.Maui.Graphics.RectF

    Implicit(CropRectangle to Rectangle)

    Implicitly casts to SixLabors.ImageSharp.Rectangle objects from CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support SixLabors.ImageSharp.Rectangle as well.

    Declaration
    public static implicit operator Rectangle(CropRectangle CropRectangle)
    Parameters
    Type Name Description
    CropRectangle CropRectangle

    CropRectangle is explicitly cast to a SixLabors.ImageSharp.Rectangle.

    Returns
    Type Description
    SixLabors.ImageSharp.Rectangle

    Implicit(CropRectangle to RectangleF)

    Implicitly casts to SixLabors.ImageSharp.RectangleF objects from CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support SixLabors.ImageSharp.RectangleF as well.

    Declaration
    public static implicit operator RectangleF(CropRectangle CropRectangle)
    Parameters
    Type Name Description
    CropRectangle CropRectangle

    CropRectangle is explicitly cast to a SixLabors.ImageSharp.RectangleF.

    Returns
    Type Description
    SixLabors.ImageSharp.RectangleF

    Implicit(CropRectangle to SKRect)

    Implicitly casts to SkiaSharp.SKRect objects from CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support SkiaSharp.SKRect as well.

    Declaration
    public static implicit operator SKRect(CropRectangle CropRectangle)
    Parameters
    Type Name Description
    CropRectangle CropRectangle

    CropRectangle is explicitly cast to a SkiaSharp.SKRect.

    Returns
    Type Description
    SkiaSharp.SKRect

    Implicit(CropRectangle to SKRectI)

    Implicitly casts to SkiaSharp.SKRectI objects from CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support SkiaSharp.SKRectI as well.

    Declaration
    public static implicit operator SKRectI(CropRectangle CropRectangle)
    Parameters
    Type Name Description
    CropRectangle CropRectangle

    CropRectangle is explicitly cast to a SkiaSharp.SKRectI.

    Returns
    Type Description
    SkiaSharp.SKRectI

    Implicit(CropRectangle to Rectangle)

    Implicitly casts to System.Drawing.Rectangle objects from CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support Rectangle as well.

    Declaration
    public static implicit operator Rectangle(CropRectangle CropRectangle)
    Parameters
    Type Name Description
    CropRectangle CropRectangle

    CropRectangle is explicitly cast to a System.Drawing.Rectangle.

    Returns
    Type Description
    System.Drawing.Rectangle

    Implicit(Rect to CropRectangle)

    Implicitly casts Microsoft.Maui.Graphics.Rect objects to CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support Microsoft.Maui.Graphics.Rect as well.

    Declaration
    public static implicit operator CropRectangle(Rect Rectangle)
    Parameters
    Type Name Description
    Microsoft.Maui.Graphics.Rect Rectangle

    Microsoft.Maui.Graphics.Rect will automatically be cast to CropRectangle.

    Returns
    Type Description
    CropRectangle

    Implicit(RectF to CropRectangle)

    Implicitly casts Microsoft.Maui.Graphics.RectF objects to CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support Microsoft.Maui.Graphics.RectF as well.

    Declaration
    public static implicit operator CropRectangle(RectF Rectangle)
    Parameters
    Type Name Description
    Microsoft.Maui.Graphics.RectF Rectangle

    Microsoft.Maui.Graphics.RectF will automatically be cast to CropRectangle.

    Returns
    Type Description
    CropRectangle

    Implicit(Rectangle to CropRectangle)

    Implicitly casts SixLabors.ImageSharp.Rectangle objects to CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support SixLabors.ImageSharp.Rectangle as well.

    Declaration
    public static implicit operator CropRectangle(Rectangle Rectangle)
    Parameters
    Type Name Description
    SixLabors.ImageSharp.Rectangle Rectangle

    SixLabors.ImageSharp.Rectangle will automatically be cast to CropRectangle.

    Returns
    Type Description
    CropRectangle

    Implicit(RectangleF to CropRectangle)

    Implicitly casts SixLabors.ImageSharp.RectangleF objects to CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support SixLabors.ImageSharp.RectangleF as well.

    Declaration
    public static implicit operator CropRectangle(RectangleF Rectangle)
    Parameters
    Type Name Description
    SixLabors.ImageSharp.RectangleF Rectangle

    SixLabors.ImageSharp.RectangleF will automatically be cast to CropRectangle.

    Returns
    Type Description
    CropRectangle

    Implicit(SKRect to CropRectangle)

    Implicitly casts SkiaSharp.SKRect objects to CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support SkiaSharp.SKRect as well.

    Declaration
    public static implicit operator CropRectangle(SKRect SKRect)
    Parameters
    Type Name Description
    SkiaSharp.SKRect SKRect

    SkiaSharp.SKRect will automatically be cast to CropRectangle.

    Returns
    Type Description
    CropRectangle

    Implicit(SKRectI to CropRectangle)

    Implicitly casts SkiaSharp.SKRectI objects to CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support SkiaSharp.SKRectI as well.

    Declaration
    public static implicit operator CropRectangle(SKRectI SKRectI)
    Parameters
    Type Name Description
    SkiaSharp.SKRectI SKRectI

    SkiaSharp.SKRectI will automatically be cast to CropRectangle.

    Returns
    Type Description
    CropRectangle

    Implicit(Rectangle to CropRectangle)

    Implicitly casts System.Drawing.Rectangle objects to CropRectangle.

    When your .NET Class methods use CropRectangle as parameters and return types, you now automatically support Rectangle as well.

    Declaration
    public static implicit operator CropRectangle(Rectangle Rectangle)
    Parameters
    Type Name Description
    System.Drawing.Rectangle Rectangle

    System.Drawing.Rectangle will automatically be cast to CropRectangle.

    Returns
    Type Description
    CropRectangle
    ☀
    ☾
    Downloads
    • Download with Nuget
    In This Article
    Back to top
    Install with Nuget
    Want to deploy IronDrawing to a live project for FREE?
    What’s included?
    30 days of fully-functional product
    Test and share in a live environment
    No watermarks in production
    Get your free 30-day Trial Key instantly.
    No credit card or account creation required
    Your Trial License Key has been emailed to you.
    Download IronDrawing free to apply
    your Trial Licenses Key
    Install with NuGet View Licenses
    Licenses from $499. Have a question? Get in touch.