Struct Size
Stores an ordered pair of integers, which specify a height and width.
Implements
Inherited Members
Namespace: SixLabors.ImageSharp
Assembly: SixLabors.ImageSharp.dll
Syntax
public struct Size : IEquatable<Size>
Remarks
This struct is fully mutable. This is done (against the guidelines) for the sake of performance, as it avoids the need to create new values for modification operations.
Constructors
Size(Point)
Declaration
public Size(Point point)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | point | The point. |
Size(Size)
Initializes a new instance of the Size struct.
Declaration
public Size(Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | size | The size. |
Size(int)
Initializes a new instance of the Size struct.
Declaration
public Size(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The width and height of the size. |
Size(int, int)
Initializes a new instance of the Size struct.
Declaration
public Size(int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | The width of the size. |
| int | height | The height of the size. |
Fields
Empty
Represents a Size that has Width and Height values set to zero.
Declaration
public static readonly Size Empty
Field Value
| Type | Description |
|---|---|
| Size |
Properties
Height
Gets or sets the height of this Size.
Declaration
public int Height { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Width
Gets or sets the width of this Size.
Declaration
public int Width { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Add(Size, Size)
Performs vector addition of two Size objects.
Declaration
public static Size Add(Size left, Size right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | The size on the left hand of the operand. |
| Size | right | The size on the right hand of the operand. |
Returns
| Type | Description |
|---|---|
| Size | The Size. |
Ceiling(SizeF)
Declaration
public static Size Ceiling(SizeF size)
Parameters
| Type | Name | Description |
|---|---|---|
| SizeF | size | The size. |
Returns
| Type | Description |
|---|---|
| Size | The Size. |
Deconstruct(out int, out int)
Deconstructs this size into two integers.
Declaration
public void Deconstruct(out int width, out int height)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | The out value for the width. |
| int | height | The out value for the height. |
Equals(Size)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(Size other)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | other | An object to compare with this object. |
Returns
| Type | Description |
|---|---|
| bool | true if the current object is equal to the |
Equals(object?)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool | true if |
Overrides
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
Round(SizeF)
Declaration
public static Size Round(SizeF size)
Parameters
| Type | Name | Description |
|---|---|---|
| SizeF | size | The size. |
Returns
| Type | Description |
|---|---|
| Size | The Size. |
Subtract(Size, Size)
Declaration
public static Size Subtract(Size left, Size right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | The size on the left hand of the operand. |
| Size | right | The size on the right hand of the operand. |
Returns
| Type | Description |
|---|---|
| Size | The Size. |
ToString()
Returns the fully qualified type name of this instance.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The fully qualified type name. |
Overrides
Transform(Size, Matrix3x2)
Transforms a size by the given matrix.
Declaration
public static SizeF Transform(Size size, Matrix3x2 matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | size | The source size. |
| Matrix3x2 | matrix | The transformation matrix. |
Returns
| Type | Description |
|---|---|
| SizeF | A transformed size. |
Truncate(SizeF)
Declaration
public static Size Truncate(SizeF size)
Parameters
| Type | Name | Description |
|---|---|---|
| SizeF | size | The size. |
Returns
| Type | Description |
|---|---|
| Size | The Size. |
Operators
operator +(Size, Size)
Computes the sum of adding two sizes.
Declaration
public static Size operator +(Size left, Size right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | The size on the left hand of the operand. |
| Size | right | The size on the right hand of the operand. |
Returns
| Type | Description |
|---|---|
| Size | The Size. |
operator /(Size, int)
Declaration
public static Size operator /(Size left, int right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | Dividend of type Size. |
| int | right | Divisor of type int. |
Returns
| Type | Description |
|---|---|
| Size | Result of type Size. |
operator /(Size, float)
Declaration
public static SizeF operator /(Size left, float right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | Dividend of type Size. |
| float | right | Divisor of type int. |
Returns
| Type | Description |
|---|---|
| SizeF | Result of type SizeF. |
operator ==(Size, Size)
Compares two Size objects for equality.
Declaration
public static bool operator ==(Size left, Size right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | The Size on the left side of the operand. |
| Size | right | The Size on the right side of the operand. |
Returns
| Type | Description |
|---|---|
| bool | True if the current left is equal to the |
explicit operator Point(Size)
Declaration
public static explicit operator Point(Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | size | The size. |
Returns
| Type | Description |
|---|---|
| Point |
implicit operator SizeF(Size)
Declaration
public static implicit operator SizeF(Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | size | The point. |
Returns
| Type | Description |
|---|---|
| SizeF |
operator !=(Size, Size)
Compares two Size objects for inequality.
Declaration
public static bool operator !=(Size left, Size right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | The Size on the left side of the operand. |
| Size | right | The Size on the right side of the operand. |
Returns
| Type | Description |
|---|---|
| bool | True if the current left is unequal to the |
operator *(Size, int)
Declaration
public static Size operator *(Size left, int right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | Multiplicand of type Size. |
| int | right | Multiplier of type int. |
Returns
| Type | Description |
|---|---|
| Size | Product of type Size. |
operator *(Size, float)
Declaration
public static SizeF operator *(Size left, float right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | Multiplicand of type Size. |
| float | right | Multiplier of type float. |
Returns
| Type | Description |
|---|---|
| SizeF | Product of type SizeF. |
operator *(int, Size)
Declaration
public static Size operator *(int left, Size right)
Parameters
| Type | Name | Description |
|---|---|---|
| int | left | Multiplier of type int. |
| Size | right | Multiplicand of type Size. |
Returns
| Type | Description |
|---|---|
| Size | Product of type Size. |
operator *(float, Size)
Declaration
public static SizeF operator *(float left, Size right)
Parameters
| Type | Name | Description |
|---|---|---|
| float | left | Multiplier of type float. |
| Size | right | Multiplicand of type Size. |
Returns
| Type | Description |
|---|---|
| SizeF | Product of type SizeF. |
operator -(Size, Size)
Computes the difference left by subtracting one size from another.
Declaration
public static Size operator -(Size left, Size right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | The size on the left hand of the operand. |
| Size | right | The size on the right hand of the operand. |
Returns
| Type | Description |
|---|---|
| Size | The Size. |