diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-10-13 04:11:18 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-10-15 05:05:17 +0300 |
commit | e229b35edff5aeb2dbe819ec7b4cf9816f90460a (patch) | |
tree | 17d07579c82477398af84dead35a3e1e4b1c93ea /src | |
parent | ccec150589a177654b9039d21163c36ccff85cff (diff) |
libcamera: geometry: Add Size members to grown or shrink by a margin
Add four new member functions to the Size class (two in-place and two
const) to grow and shrink a Size by given margins.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/libcamera/geometry.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index b014180e..cb3c2de1 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -174,6 +174,28 @@ const std::string Size::toString() const */ /** + * \fn Size::growBy(const Size &margins) + * \brief Grow the size by \a margins in place + * \param[in] margins The margins to add to the size + * + * This function adds the width and height of the \a margin size to this size. + * + * \return A reference to this object + */ + +/** + * \fn Size::shrinkBy(const Size &margins) + * \brief Shrink the size by \a margins in place + * \param[in] margins The margins to subtract to the size + * + * This function subtracts the width and height of the \a margin size from this + * size. If the width or height of the size are smaller than those of \a + * margins, the result is clamped to 0. + * + * \return A reference to this object + */ + +/** * \fn Size::alignedDownTo(unsigned int hAlignment, unsigned int vAlignment) * \brief Align the size down horizontally and vertically * \param[in] hAlignment Horizontal alignment @@ -210,6 +232,26 @@ const std::string Size::toString() const */ /** + * \fn Size::grownBy(const Size &margins) + * \brief Grow the size by \a margins + * \param[in] margins The margins to add to the size + * \return A Size whose width and height are the sum of the width and height of + * this size and the \a margins size + */ + +/** + * \fn Size::shrunkBy(const Size &margins) + * \brief Shrink the size by \a margins + * \param[in] margins The margins to subtract to the size + * + * If the width or height of the size are smaller than those of \a margins, the + * resulting size has its width or height clamped to 0. + * + * \return A Size whose width and height are the difference of the width and + * height of this size and the \a margins size, clamped to 0 + */ + +/** * \brief Bound the size down to match the aspect ratio given by \a ratio * \param[in] ratio The size whose aspect ratio must be matched * |