diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h index 03962d7d..52f4d010 100644 --- a/include/libcamera/geometry.h +++ b/include/libcamera/geometry.h @@ -92,6 +92,8 @@ public: { } + bool contains(const Size &size) const; + std::string toString() const; Size min; diff --git a/src/libcamera/geometry.cpp b/src/libcamera/geometry.cpp index e598f6ad..32b0faea 100644 --- a/src/libcamera/geometry.cpp +++ b/src/libcamera/geometry.cpp @@ -266,6 +266,22 @@ bool operator<(const Size &lhs, const Size &rhs) * \brief The vertical step */ +/** + * \brief Test if a size is contained in the range + * \param[in] size Size to check + * \returns True if \a size is contained in the range + */ +bool SizeRange::contains(const Size &size) const +{ + if (size.width < min.width || size.width > max.width || + size.height < min.height || size.height > max.height || + (hStep && (size.width - min.width) % hStep) || + (vStep && (size.height - min.height) % vStep)) + return false; + + return true; +} + /** * \brief Assemble and return a string describing the size range * \return A string describing the SizeRange