[libcamera-devel] [PATCH] implement vector casts for Point, Size and Rectangle
Christian Rauch
Rauch.Christian at gmx.de
Tue Mar 22 21:57:08 CET 2022
Cast operators from Point, Size and Rectangle to std::vector<int> allows to
serialise those types without dedicated conversion functions.
---
include/libcamera/geometry.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/include/libcamera/geometry.h b/include/libcamera/geometry.h
index 7838b679..7d1e403a 100644
--- a/include/libcamera/geometry.h
+++ b/include/libcamera/geometry.h
@@ -38,6 +38,11 @@ public:
{
return { -x, -y };
}
+
+ operator std::vector<int>() const
+ {
+ return { x, y };
+ }
};
bool operator==(const Point &lhs, const Point &rhs);
@@ -167,6 +172,11 @@ public:
Size &operator*=(float factor);
Size &operator/=(float factor);
+
+ operator std::vector<int>() const
+ {
+ return { static_cast<int>(width), static_cast<int>(height) };
+ }
};
bool operator==(const Size &lhs, const Size &rhs);
@@ -283,6 +293,11 @@ public:
__nodiscard Rectangle scaledBy(const Size &numerator,
const Size &denominator) const;
__nodiscard Rectangle translatedBy(const Point &point) const;
+
+ operator std::vector<int>() const
+ {
+ return { x, y, static_cast<int>(width), static_cast<int>(height) };
+ }
};
bool operator==(const Rectangle &lhs, const Rectangle &rhs);
--
2.25.1
More information about the libcamera-devel
mailing list