libcamera  v0.0.0+3-3b6e2d50-dirty (2022-01-27T16:18:04+08:00)
Supporting cameras in Linux since 2019
Public Member Functions | Public Attributes | List of all members
libcamera::Size Struct 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...
 
Size & alignDownTo (unsigned int hAlignment, unsigned int vAlignment)
 Align the size down horizontally and vertically in place. More...
 
Size & alignUpTo (unsigned int hAlignment, unsigned int vAlignment)
 Align the size up horizontally and vertically in place. More...
 
Size & boundTo (const Size &bound)
 Bound the size to bound in place. More...
 
Size & expandTo (const Size &expand)
 Expand the size to expand. More...
 
constexpr __nodiscard Size alignedDownTo (unsigned int hAlignment, unsigned int vAlignment) const
 Align the size down horizontally and vertically. More...
 
constexpr __nodiscard Size alignedUpTo (unsigned int hAlignment, unsigned int vAlignment) const
 Align the size up horizontally and vertically. More...
 
constexpr __nodiscard Size boundedTo (const Size &bound) const
 Bound the size to bound. More...
 
constexpr __nodiscard Size expandedTo (const Size &expand) const
 Expand the size to expand. 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...
 
Size & operator*= (float factor)
 Scale this size up by the given factor in place. More...
 
Size & operator/= (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 structure defines a two-dimensional size with integer precision.

Constructor & Destructor Documentation

◆ Size()

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

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
inlineconstexpr

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
inlineconstexpr

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
inlineconstexpr

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
inlineconstexpr

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

◆ 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

◆ 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 struct was generated from the following files: