libcamera: Add transpose() function to size
Add a transpose() function to size that applies the Transformation::Transpose operation in the size. This is useful when handling orientation adjustments. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
@@ -108,6 +108,12 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
Size &transpose()
|
||||
{
|
||||
std::swap(width, height);
|
||||
return *this;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr Size alignedDownTo(unsigned int hAlignment,
|
||||
unsigned int vAlignment) const
|
||||
{
|
||||
|
||||
@@ -209,6 +209,16 @@ std::string Size::toString() const
|
||||
* \return A reference to this object
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn Size::transpose()
|
||||
* \brief Transpose the size in place
|
||||
*
|
||||
* This function swaps width and height of this size. This effectively applies
|
||||
* the \a Transform::Transpose transformation on this size.
|
||||
*
|
||||
* \return A reference to this object
|
||||
*/
|
||||
|
||||
/**
|
||||
* \fn Size::alignedDownTo(unsigned int hAlignment, unsigned int vAlignment)
|
||||
* \brief Align the size down horizontally and vertically
|
||||
|
||||
@@ -203,6 +203,11 @@ protected:
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
if (Size(200, 50).transpose() != Size(50, 200)) {
|
||||
cout << "Size::transpose() test failed" << endl;
|
||||
return TestFail;
|
||||
}
|
||||
|
||||
/* Aspect ratio tests */
|
||||
if (Size(0, 0).boundedToAspectRatio(Size(4, 3)) != Size(0, 0) ||
|
||||
Size(1920, 1440).boundedToAspectRatio(Size(16, 9)) != Size(1920, 1080) ||
|
||||
|
||||
Reference in New Issue
Block a user