diff options
author | Yudhistira Erlandinata <yerlandinata@chromium.org> | 2024-09-25 08:12:24 +0000 |
---|---|---|
committer | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2024-10-01 21:01:25 +0200 |
commit | 724bbf7d2506d65e060c9475010738983f5b85bd (patch) | |
tree | 8944cf91d91f45edd98c92d568cd08cb2a3d2bd7 /include | |
parent | 2f621920eaf084b29ce3ad15204b989e868df826 (diff) |
libcamera: geometry: Add two-point Rectangle constructor
Add a constructor to the Rectangle class that accepts two points.
The constructed Rectangle spans all the space between the two given
points.
Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org>
Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Harvey Yang <chenghaoyang@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/libcamera/geometry.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index 3e6f0f5d..9ca5865a 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -262,6 +262,15 @@ public: { } + constexpr Rectangle(const Point &point1, const Point &point2) + : Rectangle(std::min(point1.x, point2.x), std::min(point1.y, point2.y), + static_cast<unsigned int>(std::max(point1.x, point2.x)) - + static_cast<unsigned int>(std::min(point1.x, point2.x)), + static_cast<unsigned int>(std::max(point1.y, point2.y)) - + static_cast<unsigned int>(std::min(point1.y, point2.y))) + { + } + int x; int y; unsigned int width; |