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>
This commit is contained in:
parent
ccec150589
commit
e229b35edf
3 changed files with 115 additions and 5 deletions
|
@ -173,6 +173,28 @@ const std::string Size::toString() const
|
|||
* \return A reference to this object
|
||||
*/
|
||||
|
||||
/**
|
||||
* \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
|
||||
|
@ -209,6 +231,26 @@ const std::string Size::toString() const
|
|||
* height of this size and the \a expand size
|
||||
*/
|
||||
|
||||
/**
|
||||
* \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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue