libcamera  v0.3.2+75-ff069d87
Supporting cameras in Linux since 2019
Public Member Functions | Public Attributes | List of all members
libcamera::Size Class Reference

Describe a two-dimensional size. More...

Public Member Functions

constexpr Size ()
 Construct a Size with width and height set to 0.
 
constexpr Size (unsigned int w, unsigned int h)
 Construct a Size with given width and height. More...
 
bool isNull () const
 Check if the size is null. More...
 
const std::string toString () const
 Assemble and return a string describing the size. More...
 
SizealignDownTo (unsigned int hAlignment, unsigned int vAlignment)
 Align the size down horizontally and vertically in place. More...
 
SizealignUpTo (unsigned int hAlignment, unsigned int vAlignment)
 Align the size up horizontally and vertically in place. More...
 
SizeboundTo (const Size &bound)
 Bound the size to bound in place. More...
 
SizeexpandTo (const Size &expand)
 Expand the size to expand. More...
 
SizegrowBy (const Size &margins)
 Grow the size by margins in place. More...
 
SizeshrinkBy (const Size &margins)
 Shrink the size by margins in place. More...
 
__nodiscard constexpr Size alignedDownTo (unsigned int hAlignment, unsigned int vAlignment) const
 Align the size down horizontally and vertically. More...
 
__nodiscard constexpr Size alignedUpTo (unsigned int hAlignment, unsigned int vAlignment) const
 Align the size up horizontally and vertically. More...
 
__nodiscard constexpr Size boundedTo (const Size &bound) const
 Bound the size to bound. More...
 
__nodiscard constexpr Size expandedTo (const Size &expand) const
 Expand the size to expand. More...
 
__nodiscard constexpr Size grownBy (const Size &margins) const
 Grow the size by margins. More...
 
__nodiscard constexpr Size shrunkBy (const Size &margins) const
 Shrink the size by margins. More...
 
__nodiscard Size boundedToAspectRatio (const Size &ratio) const
 Bound the size down to match the aspect ratio given by ratio. More...
 
__nodiscard Size expandedToAspectRatio (const Size &ratio) const
 Expand the size to match the aspect ratio given by ratio. More...
 
__nodiscard Rectangle centeredTo (const Point &center) const
 Center a rectangle of this size at a given Point. More...
 
Size operator* (float factor) const
 Scale size up by the given factor. More...
 
Size operator/ (float factor) const
 Scale size down by the given factor. More...
 
Sizeoperator*= (float factor)
 Scale this size up by the given factor in place. More...
 
Sizeoperator/= (float factor)
 Scale this size down by the given factor in place. More...
 

Public Attributes

unsigned int width
 The Size width.
 
unsigned int height
 The Size height.
 

Detailed Description

Describe a two-dimensional size.

The Size class defines a two-dimensional size with integer precision.

Constructor & Destructor Documentation

◆ Size()

libcamera::Size::Size ( unsigned int  width,
unsigned int  height 
)
inline

Construct a Size with given width and height.

Parameters
[in]widthThe Size width
[in]heightThe Size height

Member Function Documentation

◆ alignDownTo()

libcamera::Size::alignDownTo ( unsigned int  hAlignment,
unsigned int  vAlignment 
)
inline

Align the size down horizontally and vertically in place.

Parameters
[in]hAlignmentHorizontal alignment
[in]vAlignmentVertical alignment

This functions rounds the width and height down to the nearest multiple of hAlignment and vAlignment respectively.

Returns
A reference to this object

◆ alignedDownTo()

libcamera::Size::alignedDownTo ( unsigned int  hAlignment,
unsigned int  vAlignment 
) const
inline

Align the size down horizontally and vertically.

Parameters
[in]hAlignmentHorizontal alignment
[in]vAlignmentVertical alignment
Returns
A Size whose width and height are equal to the width and height of this size rounded down to the nearest multiple of hAlignment and vAlignment respectively

◆ alignedUpTo()

libcamera::Size::alignedUpTo ( unsigned int  hAlignment,
unsigned int  vAlignment 
) const
inline

Align the size up horizontally and vertically.

Parameters
[in]hAlignmentHorizontal alignment
[in]vAlignmentVertical alignment
Returns
A Size whose width and height are equal to the width and height of this size rounded up to the nearest multiple of hAlignment and vAlignment respectively

◆ alignUpTo()

libcamera::Size::alignUpTo ( unsigned int  hAlignment,
unsigned int  vAlignment 
)
inline

Align the size up horizontally and vertically in place.

Parameters
[in]hAlignmentHorizontal alignment
[in]vAlignmentVertical alignment

This functions rounds the width and height up to the nearest multiple of hAlignment and vAlignment respectively.

Returns
A reference to this object

◆ boundedTo()

libcamera::Size::boundedTo ( const Size bound) const
inline

Bound the size to bound.

Parameters
[in]boundThe maximum size
Returns
A Size whose width and height are the minimum of the width and height of this size and the bound size

◆ boundedToAspectRatio()

Size libcamera::Size::boundedToAspectRatio ( const Size ratio) const

Bound the size down to match the aspect ratio given by ratio.

Parameters
[in]ratioThe size whose aspect ratio must be matched

The behaviour of this function is undefined if either the width or the height of the ratio is zero.

Returns
A Size whose width and height are equal to the width and height of this Size aligned down to the aspect ratio of ratio

◆ boundTo()

libcamera::Size::boundTo ( const Size bound)
inline

Bound the size to bound in place.

Parameters
[in]boundThe maximum size

This function sets the width and height to the minimum of this size and the bound size.

Returns
A reference to this object

◆ centeredTo()

Rectangle libcamera::Size::centeredTo ( const Point center) const

Center a rectangle of this size at a given Point.

Parameters
[in]centerThe center point the Rectangle is to have

A Rectangle of this object's size is positioned so that its center is at the given Point.

Returns
A Rectangle of this size, centered at the given Point.

◆ expandedTo()

libcamera::Size::expandedTo ( const Size expand) const
inline

Expand the size to expand.

Parameters
[in]expandThe minimum size
Returns
A Size whose width and height are the maximum of the width and height of this size and the expand size

◆ expandedToAspectRatio()

Size libcamera::Size::expandedToAspectRatio ( const Size ratio) const

Expand the size to match the aspect ratio given by ratio.

Parameters
[in]ratioThe size whose aspect ratio must be matched

The behaviour of this function is undefined if either the width or the height of the ratio is zero.

Returns
A Size whose width and height are equal to the width and height of this Size expanded up to the aspect ratio of ratio

◆ expandTo()

libcamera::Size::expandTo ( const Size expand)
inline

Expand the size to expand.

Parameters
[in]expandThe minimum size

This function sets the width and height to the maximum of this size and the expand size.

Returns
A reference to this object

◆ growBy()

libcamera::Size::growBy ( const Size margins)
inline

Grow the size by margins in place.

Parameters
[in]marginsThe margins to add to the size

This function adds the width and height of the margin size to this size.

Returns
A reference to this object

◆ grownBy()

libcamera::Size::grownBy ( const Size margins) const
inline

Grow the size by margins.

Parameters
[in]marginsThe margins to add to the size
Returns
A Size whose width and height are the sum of the width and height of this size and the margins size

◆ isNull()

bool libcamera::Size::isNull ( ) const
inline

Check if the size is null.

Returns
True if both the width and height are 0, or false otherwise

◆ operator*()

Size libcamera::Size::operator* ( float  factor) const

Scale size up by the given factor.

Parameters
[in]factorThe factor
Returns
The scaled Size

◆ operator*=()

Size & libcamera::Size::operator*= ( float  factor)

Scale this size up by the given factor in place.

Parameters
[in]factorThe factor
Returns
A reference to this object

◆ operator/()

Size libcamera::Size::operator/ ( float  factor) const

Scale size down by the given factor.

Parameters
[in]factorThe factor
Returns
The scaled Size

◆ operator/=()

Size & libcamera::Size::operator/= ( float  factor)

Scale this size down by the given factor in place.

Parameters
[in]factorThe factor
Returns
A reference to this object

◆ shrinkBy()

libcamera::Size::shrinkBy ( const Size margins)
inline

Shrink the size by margins in place.

Parameters
[in]marginsThe margins to subtract to the size

This function subtracts the width and height of the margin size from this size. If the width or height of the size are smaller than those of margins, the result is clamped to 0.

Returns
A reference to this object

◆ shrunkBy()

libcamera::Size::shrunkBy ( const Size margins) const
inline

Shrink the size by margins.

Parameters
[in]marginsThe margins to subtract to the size

If the width or height of the size are smaller than those of margins, the resulting size has its width or height clamped to 0.

Returns
A Size whose width and height are the difference of the width and height of this size and the margins size, clamped to 0

◆ toString()

const std::string libcamera::Size::toString ( ) const

Assemble and return a string describing the size.

Returns
A string describing the size

The documentation for this class was generated from the following files: