New to Telerik UI for .NET MAUIStart a free 30-day trial

Represents the aspect ratio expressed as the ratio between the width and height of an image.

Definition

Namespace:Telerik.Maui.Controls.ImageEditor

Assembly:Telerik.Maui.Controls.dll

Syntax:

C#
[TypeConverter(typeof(AspectRatioConverter))]
public struct AspectRatio : IEquatable<AspectRatio>

Implements: IEquatable<AspectRatio>

Constructors

Initializes a new instance of an aspect ratio with the specified components.

C#
public AspectRatio(double width, double height)
Parameters:widthdouble

Specifies the width component of the aspect ratio.

heightdouble

Specifies the height component of the aspect ratio.

Fields

Special value, indicating the aspect ratio should not be constrained.

C#
public static readonly AspectRatio Free

Special value, indicating the aspect ratio should match the original image.

C#
public static readonly AspectRatio Original

Special value, indicating the width and height of the image should be equal.

C#
public static readonly AspectRatio Square

Methods

Compares the current aspect ratio with the specified one for equality.

C#
public bool Equals(AspectRatio aspectRatio)
Parameters:aspectRatioAspectRatio

Specifies the aspect ratio for comparison.

Returns:

bool

True, if the two aspect ratios are equal, false otherwise.

Implements: IEquatable<AspectRatio>.Equals(AspectRatio)

Compares the current aspect ratio with the specified object for equality.

C#
public override bool Equals(object value)
Parameters:valueobject

Specifies the object value for comparison.

Returns:

bool

True, if the two objects are equal, false otherwise.

Overrides: ValueType.Equals(object)

Computes the hash code of the current aspect ratio.

C#
public override int GetHashCode()
Returns:

int

Overrides: ValueType.GetHashCode()

Parses the specified string and converts it to an aspect ratio.

C#
public static AspectRatio Parse(string text)
Parameters:textstring

Specifies the input string to parse.

Returns:

AspectRatio

The converted aspect ratio on success.

Exceptions:

FormatException

If the specified string cannot be parsed.

Converts the current aspect ratio to its floating-point representation.

C#
public double ToDouble()
Returns:

double

Converts the current aspect ratio to its string representation.

C#
public override string ToString()
Returns:

string

Overrides: ValueType.ToString()

Parses the specified string and converts it to an aspect ratio.

C#
public static bool TryParse(string text, out AspectRatio aspectRatio)
Parameters:textstring

Specifies the input string to parse.

aspectRatioAspectRatio

Returns the converted aspect ratio on success.

Returns:

bool

True, if the parse operation is successful, false otherwise.

Operators

Converts the specified aspect ratio to its floating-point representation.

C#
public static explicit operator double(AspectRatio aspectRatio)
Parameters:aspectRatioAspectRatio

Specifies the aspect ratio to convert.

Returns:

double

Compares the specified two aspect ratios for inequality.

C#
public static bool operator !=(AspectRatio leftOperand, AspectRatio rightOperand)
Parameters:leftOperandAspectRatio

Specifies the left operand for the comparison.

rightOperandAspectRatio

Specifies the right operand for the comparison.

Returns:

bool

True, if the two aspect ratios are not equal, false otherwise.

Compares the specified two aspect ratios for equality.

C#
public static bool operator ==(AspectRatio leftOperand, AspectRatio rightOperand)
Parameters:leftOperandAspectRatio

Specifies the left operand for the comparison.

rightOperandAspectRatio

Specifies the right operand for the comparison.

Returns:

bool

True, if the two aspect ratios are equal, false otherwise.