public class Dimensions extends Object
Represents the linear dimensions (width and height) of one raster rectangular image in arbitrary unit. Immutable struct.
Constructor and Description |
---|
Dimensions(int width,
int height)
Creates a new instance from specified width and height
|
Modifier and Type | Method and Description |
---|---|
Dimensions |
deepClone()
Returns a full copy of this instance
|
boolean |
equals(Dimensions other)
Determines whether this instance is equal with specified "Dimensions"
instance
|
boolean |
equals(Object obj)
Determines whether this instance is equal with specified uncasted object,
which presumably is another "Dimensions" instance
|
static Dimensions |
fromSize(Dimension size)
Generates and returns a new instance from specified System.Drawing.Size
instance
|
long |
getArea()
Returns an area (Width x Height)
|
Ratio |
getAspectRatio()
Aspect ratio of this dimensions as width/height
|
static Dimensions |
getEmpty()
Returns an empty Dimensions instance
|
int |
getHeight()
Returns height of the image
|
int |
getWidth()
Returns width of the image
|
int |
hashCode()
Returns a hashcode for this instance, which cannot be changed during its
lifetime
|
boolean |
isEmpty()
Determines whether this "Dimensions" instance is empty and default, i.e.
|
boolean |
isSquare()
Determines whether specified 'Dimensions' represents square, i.e.
|
static boolean |
op_Equality(Dimensions first,
Dimensions second)
Checks whether two "Dimensions" values are equal, i.e.
|
static boolean |
op_Inequality(Dimensions first,
Dimensions second)
Checks whether two "Dimensions" values are not equal, i.e.
|
Dimensions |
proportionallyResizeForNewHeight(int targetHeight)
Creates and returns new "Dimensions" instance, which is proportionally
resized from current, based on specified height
|
Dimensions |
proportionallyResizeForNewWidth(int targetWidth)
Creates and returns new "Dimensions" instance, which is proportionally
resized from current, based on specified width
|
String |
toString()
Returns a string representation of this "Dimensions"
|
public Dimensions(int width, int height)
Creates a new instance from specified width and height
width
- Width of imageheight
- Height of imagepublic final Dimensions deepClone()
Returns a full copy of this instance
public final boolean equals(Dimensions other)
Determines whether this instance is equal with specified "Dimensions" instance
other
- Other "Dimensions" instance to check on equalitypublic boolean equals(Object obj)
Determines whether this instance is equal with specified uncasted object, which presumably is another "Dimensions" instance
public static Dimensions fromSize(Dimension size)
Generates and returns a new instance from specified System.Drawing.Size instance
size
- Any instance of System.Drawing.Sizepublic final long getArea()
Returns an area (Width x Height)
public final Ratio getAspectRatio()
Aspect ratio of this dimensions as width/height
public static Dimensions getEmpty()
Returns an empty Dimensions instance
public final int getHeight()
Returns height of the image
public final int getWidth()
Returns width of the image
public int hashCode()
Returns a hashcode for this instance, which cannot be changed during its lifetime
public final boolean isEmpty()
Determines whether this "Dimensions" instance is empty and default, i.e. it doesn't store correct width and height
public final boolean isSquare()
Determines whether specified 'Dimensions' represents square, i.e. if width is equal to height
public static boolean op_Equality(Dimensions first, Dimensions second)
Checks whether two "Dimensions" values are equal, i.e. they have equal width and height, or both are empty
first
- First instance to checksecond
- Second instance to checkpublic static boolean op_Inequality(Dimensions first, Dimensions second)
Checks whether two "Dimensions" values are not equal, i.e. their corresponding width and/or height are different
first
- First instance to checksecond
- Second instance to checkpublic final Dimensions proportionallyResizeForNewHeight(int targetHeight)
Creates and returns new "Dimensions" instance, which is proportionally resized from current, based on specified height
targetHeight
- New target height, that will be present in resultant
Dimensionpublic final Dimensions proportionallyResizeForNewWidth(int targetWidth)
Creates and returns new "Dimensions" instance, which is proportionally resized from current, based on specified width
targetWidth
- New target width, that will be present in resultant
Dimension