ImageResolution Class

An immutable physical resolution, in dots (pixels) per inch.

public sealed class ImageResolution : IEquatable<ImageResolution>

Remarks

Formats storing a resolution in another unit (for example PNG pixels per meter) are converted on import (dpi = pixelsPerMeter * 0.0254) and rounded to the format's integer unit on export, so decoded values round-trip to the same encoded integers. Aspect-ratio-only resolutions without a physical unit are not represented.

Implements

Constructors

NameDescription
ImageResolution(double, double)Initializes a new instance of the ImageResolution class.

ImageResolution(double, double)

ImageResolution.cs

Initializes a new instance of the ImageResolution class.

public ImageResolution(double horizontalDpi, double verticalDpi)

Parameters

horizontalDpi double
The horizontal resolution. Must be positive and finite.
verticalDpi double
The vertical resolution. Must be positive and finite.

Exceptions

ArgumentOutOfRangeException
A resolution is zero, negative, infinite or NaN.

Properties

NameDescription
HorizontalDpiGets the horizontal resolution, in dots per inch.
VerticalDpiGets the vertical resolution, in dots per inch.

HorizontalDpi

ImageResolution.cs

Gets the horizontal resolution, in dots per inch.

public double HorizontalDpi { get; }

Property value

double

Gets the vertical resolution, in dots per inch.

public double VerticalDpi { get; }

Property value

double

Methods

NameDescription
Equals(ImageResolution?)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(ImageResolution?)

ImageResolution.cs

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

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

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

Equals(object?)

ImageResolution.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()

ImageResolution.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.