diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/libcamera/geometry.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index fdd1b467..fa7ae7bc 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -94,6 +94,20 @@ public: return *this; } + Size &growBy(const Size &margins) + { + width += margins.width; + height += margins.height; + return *this; + } + + Size &shrinkBy(const Size &margins) + { + width = width > margins.width ? width - margins.width : 0; + height = height > margins.height ? height - margins.height : 0; + return *this; + } + __nodiscard constexpr Size alignedDownTo(unsigned int hAlignment, unsigned int vAlignment) const { @@ -128,6 +142,22 @@ public: }; } + __nodiscard constexpr Size grownBy(const Size &margins) const + { + return { + width + margins.width, + height + margins.height + }; + } + + __nodiscard constexpr Size shrunkBy(const Size &margins) const + { + return { + width > margins.width ? width - margins.width : 0, + height > margins.height ? height - margins.height : 0 + }; + } + __nodiscard Size boundedToAspectRatio(const Size &ratio) const; __nodiscard Size expandedToAspectRatio(const Size &ratio) const; |