libcamera
v0.3.2+116-83c5ad0f
Supporting cameras in Linux since 2019
|
Describe a rectangle's position and dimensions. More...
Public Member Functions | |
constexpr | Rectangle () |
Construct a Rectangle with all coordinates set to 0. | |
constexpr | Rectangle (int xpos, int ypos, const Size &size) |
Construct a Rectangle with the given position and size. More... | |
constexpr | Rectangle (int xpos, int ypos, unsigned int w, unsigned int h) |
Construct a Rectangle with the given position and size. More... | |
constexpr | Rectangle (const Size &size) |
Construct a Rectangle of size with its top left corner located at (0,0) More... | |
constexpr | Rectangle (const Point &point1, const Point &point2) |
Construct a Rectangle from two opposite corners. More... | |
bool | isNull () const |
Check if the rectangle is null. More... | |
const std::string | toString () const |
Assemble and return a string describing the rectangle. More... | |
Point | center () const |
Retrieve the center point of this rectangle. More... | |
Size | size () const |
Retrieve the size of this rectangle. More... | |
Point | topLeft () const |
Retrieve the coordinates of the top left corner of this Rectangle. More... | |
Rectangle & | scaleBy (const Size &numerator, const Size &denominator) |
Apply a non-uniform rational scaling in place to this Rectangle. More... | |
Rectangle & | translateBy (const Point &point) |
Translate this Rectangle in place by the given Point. More... | |
__nodiscard Rectangle | boundedTo (const Rectangle &bound) const |
Calculate the intersection of this Rectangle with another. More... | |
__nodiscard Rectangle | enclosedIn (const Rectangle &boundary) const |
Enclose a Rectangle so as not to exceed another Rectangle. More... | |
__nodiscard Rectangle | scaledBy (const Size &numerator, const Size &denominator) const |
Apply a non-uniform rational scaling to this Rectangle. More... | |
__nodiscard Rectangle | translatedBy (const Point &point) const |
Translate a Rectangle by the given amounts. More... | |
Public Attributes | |
int | x |
The horizontal coordinate of the rectangle's top-left corner. More... | |
int | y |
The vertical coordinate of the rectangle's top-left corner. More... | |
unsigned int | width |
The distance between the left and right sides. | |
unsigned int | height |
The distance between the top and bottom sides. | |
Describe a rectangle's position and dimensions.
Rectangles are used to identify an area of an image. They are specified by the coordinates of top-left corner and their horizontal and vertical size. By convention, the top-left corner is defined as the corner with the lowest x and y coordinates, regardless of the origin and direction of the axes.
The measure unit of the rectangle coordinates and size, as well as the reference point from which the Rectangle::x and Rectangle::y displacements refers to, are defined by the context were rectangle is used.
|
inline |
Construct a Rectangle with the given position and size.
[in] | x | The horizontal coordinate of the top-left corner |
[in] | y | The vertical coordinate of the top-left corner |
[in] | size | The size |
The rectangle's top-left corner is the point with the smaller x and y values.
|
inline |
Construct a Rectangle with the given position and size.
[in] | x | The horizontal coordinate of the top-left corner |
[in] | y | The vertical coordinate of the top-left corner |
[in] | width | The width |
[in] | height | The height |
The rectangle's top-left corner is the point with the smaller x and y values.
|
inlineexplicit |
Construct a Rectangle from two opposite corners.
[in] | point1 | One of corners of the rectangle |
[in] | point2 | The opposite corner of point1 |
Calculate the intersection of this Rectangle with another.
This function calculates the standard intersection of two rectangles. If the rectangles do not overlap in either the x or y direction, then the size of that dimension in the result (its width or height) is set to zero. Even when one dimension is set to zero, note that the other dimension may still have a positive value if there was some overlap.
Point libcamera::Rectangle::center | ( | ) | const |
Retrieve the center point of this rectangle.
Enclose a Rectangle so as not to exceed another Rectangle.
[in] | boundary | The limit that the returned Rectangle will not exceed |
The Rectangle is modified so that it does not exceed the given boundary. This process involves translating the Rectangle if any of its edges lie beyond boundary, so that those edges then lie along the boundary instead.
If either width or height are larger than boundary, then the returned Rectangle is clipped to be no larger. But other than this, the Rectangle is not clipped or reduced in size, merely translated.
Note that this is not a conventional Rectangle intersection function which is provided by boundedTo().
|
inline |
Check if the rectangle is null.
Apply a non-uniform rational scaling in place to this Rectangle.
[in] | numerator | The numerators of the x and y scaling factors |
[in] | denominator | The denominators of the x and y scaling factors |
A non-uniform scaling is applied in place such the resulting x coordinates are multiplied by numerator.width / denominator.width, and similarly for the y coordinates (using height in place of width).
Apply a non-uniform rational scaling to this Rectangle.
[in] | numerator | The numerators of the x and y scaling factors |
[in] | denominator | The denominators of the x and y scaling factors |
A non-uniform scaling is applied such the resulting x coordinates are multiplied by numerator.width / denominator.width, and similarly for the y coordinates (using height in place of width).
|
inline |
Retrieve the size of this rectangle.
|
inline |
const std::string libcamera::Rectangle::toString | ( | ) | const |
Assemble and return a string describing the rectangle.
libcamera::Rectangle::x |
The horizontal coordinate of the rectangle's top-left corner.
The rectangle's top-left corner is the point with the smaller x and y values.
libcamera::Rectangle::y |
The vertical coordinate of the rectangle's top-left corner.
The rectangle's top-left corner is the point with the smaller x and y values.