PixelAspectRatio Class

An immutable pixel aspect ratio (the pasp box of ISO/IEC 14496-12): the relative width and height of a pixel, for images whose pixels are not square.

public sealed class PixelAspectRatio : IEquatable<PixelAspectRatio>

Remarks

A pixel is PixelAspectRatio.HorizontalSpacing units wide for PixelAspectRatio.VerticalSpacing units high: a ratio of 2:1 describes pixels twice as wide as they are high. The two terms are kept as they are given, not reduced, so that a description round-trips unchanged.

This is a label: no operation resamples the pixels to make them square. An operation that swaps the axes of the image (a rotation by a quarter turn, AutoOrient for the orientations that transpose) swaps the two terms.

Implements

Constructors

NameDescription
PixelAspectRatio(uint, uint)Initializes a new instance of the PixelAspectRatio class.

PixelAspectRatio(uint, uint)

PixelAspectRatio.cs

Initializes a new instance of the PixelAspectRatio class.

public PixelAspectRatio(uint horizontalSpacing, uint verticalSpacing)

Parameters

horizontalSpacing uint
The relative width of a pixel. Must be positive.
verticalSpacing uint
The relative height of a pixel. Must be positive.

Exceptions

ArgumentOutOfRangeException
A term is zero.

Properties

NameDescription
HorizontalSpacingGets the relative width of a pixel.
IsSquareGets a value indicating whether the pixels are square (the two terms are equal).
RatioGets the width of a pixel divided by its height.
VerticalSpacingGets the relative height of a pixel.

HorizontalSpacing

PixelAspectRatio.cs

Gets the relative width of a pixel.

public uint HorizontalSpacing { get; }

Property value

uint

Gets a value indicating whether the pixels are square (the two terms are equal).

public bool IsSquare { get; }

Property value

bool

Gets the width of a pixel divided by its height.

public double Ratio { get; }

Property value

double

VerticalSpacing

PixelAspectRatio.cs

Gets the relative height of a pixel.

public uint VerticalSpacing { get; }

Property value

uint

Methods

NameDescription
Equals(PixelAspectRatio?)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Determines whether the specified object is equal to the current object.
GetHashCode()Serves as the default hash function.
ToString()Returns a string that represents the current object.

Equals overloads

Equals(PixelAspectRatio?)

PixelAspectRatio.cs

Indicates whether the current object is equal to another object of the same type.

public bool Equals(PixelAspectRatio? other)
Parameters
other PixelAspectRatio?
An object to compare with this object.
Returns

bool true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

PixelAspectRatio.cs

Determines whether the specified object is equal to the current object.

public override bool Equals(object? obj)
Parameters
obj object?
The object to compare with the current object.
Returns

bool true if the specified object is equal to the current object; otherwise, false.

GetHashCode()

PixelAspectRatio.cs

Serves as the default hash function.

public override int GetHashCode()

Returns

int A hash code for the current object.

Returns a string that represents the current object.

public override string ToString()

Returns

string A string that represents the current object.