libcamera v0.3.2 Supporting cameras in Linux since 2019

Loading...
Searching...
No Matches
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.
bool | isNull () const
| Check if the size is null.
const std::string | toString () const
| Assemble and return a string describing the size.
Size & | alignDownTo (unsigned int hAlignment, unsigned int vAlignment)
| Align the size down horizontally and vertically in place.
Size & | alignUpTo (unsigned int hAlignment, unsigned int vAlignment)
| Align the size up horizontally and vertically in place.
Size & | boundTo (const Size &bound)
| Bound the size to bound in place.
Size & | expandTo (const Size &expand)
| Expand the size to expand.
Size & | growBy (const Size &margins)
| Grow the size by margins in place.
Size & | shrinkBy (const Size &margins)
| Shrink the size by margins in place.
__nodiscard constexpr Size | alignedDownTo (unsigned int hAlignment, unsigned int vAlignment) const
| Align the size down horizontally and vertically.
__nodiscard constexpr Size | alignedUpTo (unsigned int hAlignment, unsigned int vAlignment) const
| Align the size up horizontally and vertically.
__nodiscard constexpr Size | boundedTo (const Size &bound) const
| Bound the size to bound.
__nodiscard constexpr Size | expandedTo (const Size &expand) const
| Expand the size to expand.
__nodiscard constexpr Size | grownBy (const Size &margins) const
| Grow the size by margins.
__nodiscard constexpr Size | shrunkBy (const Size &margins) const
| Shrink the size by margins.
__nodiscard Size | boundedToAspectRatio (const Size &ratio) const
| Bound the size down to match the aspect ratio given by ratio.
__nodiscard Size | expandedToAspectRatio (const Size &ratio) const
| Expand the size to match the aspect ratio given by ratio.
__nodiscard Rectangle | centeredTo (const Point &center) const
| Center a rectangle of this size at a given Point.
Size | operator* (float factor) const
| Scale size up by the given factor.
Size | operator/ (float factor) const
| Scale size down by the given factor.
Size & | operator*= (float factor)
| Scale this size up by the given factor in place.
Size & | operator/= (float factor)
| Scale this size down by the given factor in place.

## 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 constexpr

Construct a Size with given width and height.

Parameters

  [in] | width | The Size width
  [in] | height | The Size height

## Member Function Documentation

## ◆ alignDownTo()

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

Align the size down horizontally and vertically in place.

Parameters

  [in] | hAlignment | Horizontal alignment
  [in] | vAlignment | Vertical 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()

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

Align the size down horizontally and vertically.

Parameters

  [in] | hAlignment | Horizontal alignment
  [in] | vAlignment | Vertical 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()

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

Align the size up horizontally and vertically.

Parameters

  [in] | hAlignment | Horizontal alignment
  [in] | vAlignment | Vertical 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()

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

Align the size up horizontally and vertically in place.

Parameters

  [in] | hAlignment | Horizontal alignment
  [in] | vAlignment | Vertical 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()

__nodiscard constexpr Size libcamera::Size::boundedTo | ( | const Size & | bound | ) | const
| inline constexpr

Bound the size to bound.

Parameters

  [in] | bound | The 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] | ratio | The 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()

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

Bound the size to bound in place.

Parameters

  [in] | bound | The 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] | center | The 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()

__nodiscard constexpr Size libcamera::Size::expandedTo | ( | const Size & | expand | ) | const
| inline constexpr

Expand the size to expand.

Parameters

  [in] | expand | The 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] | ratio | The 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()

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

Expand the size to expand.

Parameters

  [in] | expand | The 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()

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

Grow the size by margins in place.

Parameters

  [in] | margins | The 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()

__nodiscard constexpr Size libcamera::Size::grownBy | ( | const Size & | margins | ) | const
| inline constexpr

Grow the size by margins.

Parameters

  [in] | margins | The 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] | factor | The factor

Returns
  The scaled Size

## ◆ operator*=()

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

Scale this size up by the given factor in place.

Parameters

  [in] | factor | The factor

Returns
  A reference to this object

## ◆ operator/()

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

Scale size down by the given factor.

Parameters

  [in] | factor | The factor

Returns
  The scaled Size

## ◆ operator/=()

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

Scale this size down by the given factor in place.

Parameters

  [in] | factor | The factor

Returns
  A reference to this object

## ◆ shrinkBy()

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

Shrink the size by margins in place.

Parameters

  [in] | margins | The 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()

__nodiscard constexpr Size libcamera::Size::shrunkBy | ( | const Size & | margins | ) | const
| inline constexpr

Shrink the size by margins.

Parameters

  [in] | margins | The 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:

- include/libcamera/geometry.h
- src/libcamera/geometry.cpp