libcamera  v0.2.0+129-626172a1
Supporting cameras in Linux since 2019
Public Member Functions | Static Public Member Functions | List of all members
libcamera::PixelFormat Class Reference

libcamera image pixel format More...

Public Member Functions

constexpr PixelFormat ()
 Construct a PixelFormat with an invalid format. More...
 
constexpr PixelFormat (uint32_t fourcc, uint64_t modifier=0)
 Construct a PixelFormat from a DRM FourCC and a modifier. More...
 
bool operator== (const PixelFormat &other) const
 Compare pixel formats for equality. More...
 
bool operator!= (const PixelFormat &other) const
 Compare pixel formats for inequality. More...
 
bool operator< (const PixelFormat &other) const
 Compare pixel formats for smaller than order. More...
 
constexpr bool isValid () const
 Check if the pixel format is valid. More...
 
constexpr operator uint32_t () const
 Convert the the pixel format numerical value. More...
 
constexpr uint32_t fourcc () const
 Retrieve the pixel format FourCC. More...
 
constexpr uint64_t modifier () const
 Retrieve the pixel format modifier. More...
 
std::string toString () const
 Assemble and return a string describing the pixel format. More...
 

Static Public Member Functions

static PixelFormat fromString (const std::string &name)
 Create a PixelFormat from a string. More...
 

Detailed Description

libcamera image pixel format

The PixelFormat type describes the format of images in the public libcamera API. It stores a FourCC value as a 32-bit unsigned integer and a modifier. The FourCC and modifier values are defined in the Linux kernel DRM/KMS API (see linux/drm_fourcc.h). Constant expressions for all pixel formats supported by libcamera are available in libcamera/formats.h.

Constructor & Destructor Documentation

◆ PixelFormat() [1/2]

libcamera::PixelFormat::PixelFormat ( )
inline

Construct a PixelFormat with an invalid format.

PixelFormat instances constructed with the default constructor are invalid, calling the isValid() function returns false.

◆ PixelFormat() [2/2]

libcamera::PixelFormat::PixelFormat ( uint32_t  fourcc,
uint64_t  modifier = 0 
)
inlineexplicit

Construct a PixelFormat from a DRM FourCC and a modifier.

Parameters
[in]fourccA DRM FourCC
[in]modifierA DRM FourCC modifier

Member Function Documentation

◆ fourcc()

libcamera::PixelFormat::fourcc ( ) const
inline

Retrieve the pixel format FourCC.

Returns
DRM FourCC

◆ fromString()

PixelFormat libcamera::PixelFormat::fromString ( const std::string &  name)
static

Create a PixelFormat from a string.

Returns
The PixelFormat represented by the name if known, or an invalid pixel format otherwise.

◆ isValid()

bool libcamera::PixelFormat::isValid ( ) const
inline

Check if the pixel format is valid.

PixelFormat instances constructed with the default constructor are invalid. Instances constructed with a FourCC defined in the DRM API are valid. The behaviour is undefined otherwise.

Returns
True if the pixel format is valid, false otherwise

◆ modifier()

libcamera::PixelFormat::modifier ( ) const
inline

Retrieve the pixel format modifier.

Returns
DRM modifier

◆ operator uint32_t()

libcamera::PixelFormat::operator uint32_t ( ) const
inline

Convert the the pixel format numerical value.

Returns
The pixel format numerical value

◆ operator!=()

bool libcamera::PixelFormat::operator!= ( const PixelFormat other) const
inline

Compare pixel formats for inequality.

Returns
True if the two pixel formats are not equal, false otherwise

◆ operator<()

bool libcamera::PixelFormat::operator< ( const PixelFormat other) const

Compare pixel formats for smaller than order.

Returns
True if this is smaller than other, false otherwise

◆ operator==()

bool libcamera::PixelFormat::operator== ( const PixelFormat other) const

Compare pixel formats for equality.

Returns
True if the two pixel formats are equal, false otherwise

◆ toString()

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

Assemble and return a string describing the pixel format.

Returns
A string describing the pixel format

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