Table of Contents

Struct Size

Namespace
SixLabors.ImageSharp
Assembly
SixLabors.ImageSharp.dll

Stores an ordered pair of integers, which specify a height and width.

public struct Size : IEquatable<Size>
Implements
Inherited Members

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)

Initializes a new instance of the Size struct from the given Point.

public Size(Point point)

Parameters

point Point

The point.

Size(Size)

Initializes a new instance of the Size struct.

public Size(Size size)

Parameters

size Size

The size.

Size(int)

Initializes a new instance of the Size struct.

public Size(int value)

Parameters

value int

The width and height of the size.

Size(int, int)

Initializes a new instance of the Size struct.

public Size(int width, int height)

Parameters

width int

The width of the size.

height int

The height of the size.

Fields

Empty

Represents a Size that has Width and Height values set to zero.

public static readonly Size Empty

Field Value

Size

Properties

Height

Gets or sets the height of this Size.

public int Height { readonly get; set; }

Property Value

int

Width

Gets or sets the width of this Size.

public int Width { readonly get; set; }

Property Value

int

Methods

Add(Size, Size)

Performs vector addition of two Size objects.

public static Size Add(Size left, Size right)

Parameters

left Size

The size on the left hand of the operand.

right Size

The size on the right hand of the operand.

Returns

Size

The Size.

Ceiling(SizeF)

Converts a SizeF to a Size by performing a ceiling operation on all the dimensions.

public static Size Ceiling(SizeF size)

Parameters

size SizeF

The size.

Returns

Size

The Size.

Deconstruct(out int, out int)

Deconstructs this size into two integers.

public void Deconstruct(out int width, out int height)

Parameters

width int

The out value for the width.

height int

The out value for the height.

Equals(Size)

public bool Equals(Size other)

Parameters

other Size

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

Round(SizeF)

Converts a SizeF to a Size by performing a round operation on all the dimensions.

public static Size Round(SizeF size)

Parameters

size SizeF

The size.

Returns

Size

The Size.

Subtract(Size, Size)

Contracts a Size by another Size.

public static Size Subtract(Size left, Size right)

Parameters

left Size

The size on the left hand of the operand.

right Size

The size on the right hand of the operand.

Returns

Size

The Size.

ToString()

public override string ToString()

Returns

string

Transform(Size, Matrix3x2)

Transforms a size by the given matrix.

public static SizeF Transform(Size size, Matrix3x2 matrix)

Parameters

size Size

The source size.

matrix Matrix3x2

The transformation matrix.

Returns

SizeF

A transformed size.

Truncate(SizeF)

Converts a SizeF to a Size by performing a round operation on all the dimensions.

public static Size Truncate(SizeF size)

Parameters

size SizeF

The size.

Returns

Size

The Size.

Operators

operator +(Size, Size)

Computes the sum of adding two sizes.

public static Size operator +(Size left, Size right)

Parameters

left Size

The size on the left hand of the operand.

right Size

The size on the right hand of the operand.

Returns

Size

The Size.

operator /(Size, int)

Divides Size by an int producing Size.

public static Size operator /(Size left, int right)

Parameters

left Size

Dividend of type Size.

right int

Divisor of type int.

Returns

Size

Result of type Size.

operator /(Size, float)

Divides Size by a float producing SizeF.

public static SizeF operator /(Size left, float right)

Parameters

left Size

Dividend of type Size.

right float

Divisor of type int.

Returns

SizeF

Result of type SizeF.

operator ==(Size, Size)

Compares two Size objects for equality.

public static bool operator ==(Size left, Size right)

Parameters

left Size

The Size on the left side of the operand.

right Size

The Size on the right side of the operand.

Returns

bool

True if the current left is equal to the right parameter; otherwise, false.

explicit operator Point(Size)

Converts the given Size into a Point.

public static explicit operator Point(Size size)

Parameters

size Size

The size.

Returns

Point

implicit operator SizeF(Size)

Creates a SizeF with the dimensions of the specified Size.

public static implicit operator SizeF(Size size)

Parameters

size Size

The point.

Returns

SizeF

operator !=(Size, Size)

Compares two Size objects for inequality.

public static bool operator !=(Size left, Size right)

Parameters

left Size

The Size on the left side of the operand.

right Size

The Size on the right side of the operand.

Returns

bool

True if the current left is unequal to the right parameter; otherwise, false.

operator *(Size, int)

Multiplies Size by an int producing Size.

public static Size operator *(Size left, int right)

Parameters

left Size

Multiplicand of type Size.

right int

Multiplier of type int.

Returns

Size

Product of type Size.

operator *(Size, float)

Multiplies Size by a float producing SizeF.

public static SizeF operator *(Size left, float right)

Parameters

left Size

Multiplicand of type Size.

right float

Multiplier of type float.

Returns

SizeF

Product of type SizeF.

operator *(int, Size)

Multiplies a Size by an int producing Size.

public static Size operator *(int left, Size right)

Parameters

left int

Multiplier of type int.

right Size

Multiplicand of type Size.

Returns

Size

Product of type Size.

operator *(float, Size)

Multiplies Size by a float producing SizeF.

public static SizeF operator *(float left, Size right)

Parameters

left float

Multiplier of type float.

right Size

Multiplicand of type Size.

Returns

SizeF

Product of type SizeF.

operator -(Size, Size)

Computes the difference left by subtracting one size from another.

public static Size operator -(Size left, Size right)

Parameters

left Size

The size on the left hand of the operand.

right Size

The size on the right hand of the operand.

Returns

Size

The Size.