Class RectangleOfPixels
- Namespace
- VirtualLabAPI.Core.Numerics
- Assembly
- VirtualLabAPI.dll
Special rectangle of integer values using to store a rectangular or range selection. In contrast to the System.Drawing.Rectangle class its point of origin is in the lower left corner and the y-axis points upwards. Furthermore its Width is (Right - Left + 1) and its Height is (Bottom - Top + 1). That's because if the rectangle contains two pixels in x-direction its Left property may be "0" while its "Right" property is "1". But then the width should be "2", as two pixels are in the rectangle.
[Serializable]
public class RectangleOfPixels : SerializableObjectBase, IEquatable<IObjectBase>, ICloneable
- Inheritance
-
ObjectBaseSerializableObjectBaseRectangleOfPixels
- Implements
-
IEquatable<IObjectBase>
- Inherited Members
Constructors
RectangleOfPixels(long, long)
Special constructor for a one-dimensional rectangle of pixels. Top and Bottom property are set to "0".
public RectangleOfPixels(long left, long right)
Parameters
leftlongThe start index of the selection, i.e. the left-most selected pixel.
rightlongThe end index of the selection, i.e. the right-most selected pixel.
RectangleOfPixels(long, long, long, long)
Constructor for a two-dimensional rectangle of pixels.
public RectangleOfPixels(long left, long bottom, long numberOfPixelsX, long numberOfPixelsY)
Parameters
leftlongThe smallest x-coordinate, i.e. the left-most pixel.
bottomlongThe smallest y-coordinate, i.e. the bottom-most pixel.
numberOfPixelsXlongThe width of the rectangle in pixels.
numberOfPixelsYlongThe height of the rectangle in pixels.
RectangleOfPixels(RectangleOfPixels)
Copy constructor which initializes a new instance of the RectangleOfPixels class.
public RectangleOfPixels(RectangleOfPixels copyObject)
Parameters
copyObjectRectangleOfPixelsThe object to copy.
RectangleOfPixels(VectorL, VectorL)
Constructor for a two-dimensional rectangle of pixels.
public RectangleOfPixels(VectorL lowerLeftIndices, VectorL upperRightIndices)
Parameters
lowerLeftIndicesVectorLThe indices of the lower left pixel.
upperRightIndicesVectorLThe indices of the upper right pixel.
Fields
Empty
An empty rectangle.
public static readonly RectangleOfPixels Empty
Field Value
Properties
Bottom
Gets and sets the index of the bottom-most selected row of pixels. Must be smaller than Top.
public long Bottom { get; set; }
Property Value
Left
Gets and sets the index of the left-most selected column of pixels. Must be smaller than Right.
public long Left { get; set; }
Property Value
NumberOfPixels
Gets the number of pixels in both x- and y-direction.
public VectorL NumberOfPixels { get; }
Property Value
NumberOfPixelsOneD
Gets the number of pixels for one-dimensional rectangles.
public long NumberOfPixelsOneD { get; }
Property Value
NumberOfPixelsTotal
Gets the total number of pixels, i.e. the number of pixels in x-direction times the number of pixels in y-direction.
public long NumberOfPixelsTotal { get; }
Property Value
Origin
Gets the point of origin, i.e. the left-bottom pixel.
public VectorL Origin { get; }
Property Value
Right
Gets and sets the index of the right-most selected column of pixels. Must be larger than Left.
public long Right { get; set; }
Property Value
Top
Gets and sets the index of the top-most selected row of pixels. Must be larger than Bottom.
public long Top { get; set; }
Property Value
Methods
Clone()
Creates a new object that is a copy of the current instance.
public override object Clone()
Returns
- object
A new object that is a copy of this instance.
Equals(object, EqualityIntent)
Determines whether the specified object is equal to this instance.
public override bool Equals(object otherObject, EqualityIntent equality)
Parameters
Returns
FromCoordinates(long, long, long, long)
Constructor for a two-dimensional rectangle of pixels.
public static RectangleOfPixels FromCoordinates(long left, long right, long bottom, long top)
Parameters
leftlongThe smallest x-coordinate, i.e. the left-most pixel.
rightlongThe largest x-coordinate, i.e. the right-most pixel.
bottomlongThe smallest y-coordinate, i.e. the bottom-most pixel.
toplongThe largest y-coordinate, i.e. the top-most pixel.
Returns
Inflate(RectangleOfPixels, long, long)
Enlarges the given RectangleOfPixels by the specified amount.
public static RectangleOfPixels Inflate(RectangleOfPixels rectangle, long incrementX, long incrementY)
Parameters
rectangleRectangleOfPixelsThe original rectangle.
incrementXlongThe increment in x-direction (subtracted from the left and added to the right).
incrementYlongThe increment in y-direction (subtracted from the bottom and added to the top).
Returns
- RectangleOfPixels
The inflated rectangle.
Intersect(RectangleOfPixels, RectangleOfPixels)
Returns a third RectangleOfPixels that represents the intersection of two other RectangleOfPixels objects. If there is no intersection, an empty RectangleOfPixels is returned.
public static RectangleOfPixels Intersect(RectangleOfPixels a, RectangleOfPixels b)
Parameters
aRectangleOfPixelsFirst rectangle to intersect.
bRectangleOfPixelsSecond rectangle to intersect.
Returns
- RectangleOfPixels
A RectangleOfPixels that represents the intersection of a and b.
IntersectsWith(RectangleOfPixels)
Determines if this rectangle intersects with otherRectangle.
public bool IntersectsWith(RectangleOfPixels otherRectangle)
Parameters
otherRectangleRectangleOfPixelsThe other rectangle.
Returns
- bool
This method returns
trueif there is any intersection, otherwisefalse.
Operators
explicit operator Rectangle?(RectangleOfPixels)
Converts this rectangle of a pixels to a System.Drawing.Rectangle object.
public static explicit operator Rectangle?(RectangleOfPixels rectangleOfPixels)
Parameters
rectangleOfPixelsRectangleOfPixelsThe rectangle of pixels to convert.
Returns
- Rectangle?
The converted rectangle. It has the same size and location (= origin) as this RectangleOfPixels. But the right and top/bottom coordinate differs.