Castor3D 0.16.0
Multiplatform 3D engine
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | List of all members
castor::Pixel< FT > Class Template Reference

Pixel definition. More...

#include <Pixel.hpp>

Inheritance diagram for castor::Pixel< FT >:
Inheritance graph
[legend]

Public Types

using iterator = uint8_t *
 
using const_iterator = uint8_t const *
 

Public Member Functions

 Pixel (bool init=false)
 Constructor.
 
 Pixel (uint8_t *components)
 Constructor.
 
 Pixel (Pixel const &pxl)
 Copy Constructor.
 
 Pixel (Pixel &&pxl) noexcept
 Move Constructor.
 
template<PixelFormat FU>
 Pixel (Array< uint8_t, PixelDefinitionsT< FU >::Size > const &components)
 Constructor.
 
template<PixelFormat FU>
 Pixel (Pixel< FU > const &pxl)
 Constructor.
 
 ~Pixel () noexcept
 Destructor.
 
Pixeloperator= (Pixel &&pxl) noexcept
 Copy assignment operator.
 
Pixeloperator= (Pixel const &pxl)
 Move assignment operator.
 
template<PixelFormat FU>
Pixeloperator= (Pixel< FU > const &pxl)
 Copy assignment operator.
 
template<typename U >
void sum (U &result) const
 Computes the sum of all components.
 
template<PixelFormat FU>
Pixel< FU > mul (Pixel< FU > const &px) const
 Multiplication function.
 
void clear () noexcept
 deallocate components
 
void link (uint8_t *components) noexcept
 Links the data pointer to the one given in parameter.
 
void unlink () noexcept
 Unlinks the data pointer from the ones previously given.
 
template<PixelFormat FU>
void set (Array< uint8_t, PixelDefinitionsT< FU >::Size > const &components)
 Converts given data and copies it into this pixel's components.
 
template<PixelFormat FU>
void set (uint8_t const *components)
 Converts given data and copies it into this pixel's components.
 
template<PixelFormat FU>
void set (Pixel< FU > const &px)
 Converts given pixel and copies it into this pixel's components.
 
component_ref operator[] (uint8_t index)
 Retrieves the data at given index.
 
component_const_ref operator[] (uint8_t index) const
 Retrieves the data at given index.
 
component_const_ptr constPtr () const
 Retrieves the pointer on constant datas.
 
component_ptr ptr ()
 Retrieves the pointer on datas.
 
iterator begin ()
 Retrieves an iterator to the first element.
 
const_iterator begin () const
 Retrieves a constant iterator to the first element.
 
iterator end ()
 Retrieves an iterator to the last element.
 
const_iterator end () const
 Retrieves a constant iterator to the last element.
 
Arithmetic member operators.
template<PixelFormat FU>
Pixeloperator+= (Pixel< FU > const &px)
 
template<PixelFormat FU>
Pixeloperator-= (Pixel< FU > const &px)
 
template<PixelFormat FU>
Pixeloperator*= (Pixel< FU > const &px)
 
template<PixelFormat FU>
Pixeloperator/= (Pixel< FU > const &px)
 

Static Public Member Functions

static PixelFormat getFormat ()
 Retrieves the pixel format.
 
static uint32_t getSize ()
 Retrieves the pixel size.
 

Protected Types

using component_ptr = uint8_t *
 
using component_const_ptr = uint8_t const *
 
using component_ref = uint8_t &
 
using component_const_ref = uint8_t const &
 

Detailed Description

template<PixelFormat FT>
class castor::Pixel< FT >

Pixel definition.

Remarks
Takes a PixelFormat as a template argument to determine size anf format.

Member Typedef Documentation

◆ component_const_ptr

template<PixelFormat FT>
using castor::Pixel< FT >::component_const_ptr = uint8_t const *
protected

◆ component_const_ref

template<PixelFormat FT>
using castor::Pixel< FT >::component_const_ref = uint8_t const &
protected

◆ component_ptr

template<PixelFormat FT>
using castor::Pixel< FT >::component_ptr = uint8_t *
protected

◆ component_ref

template<PixelFormat FT>
using castor::Pixel< FT >::component_ref = uint8_t &
protected

◆ const_iterator

template<PixelFormat FT>
using castor::Pixel< FT >::const_iterator = uint8_t const *

Constant iterator on the pixel's data.

◆ iterator

template<PixelFormat FT>
using castor::Pixel< FT >::iterator = uint8_t *

Iterator on the pixel's data.

Constructor & Destructor Documentation

◆ Pixel() [1/6]

template<PixelFormat FT>
castor::Pixel< FT >::Pixel ( bool init = false)
explicit

Constructor.

Parameters
[in]initTells if the data are initialised

◆ Pixel() [2/6]

template<PixelFormat FT>
castor::Pixel< FT >::Pixel ( uint8_t * components)
explicit

Constructor.

Remarks
This Pixel doesn't own it's data
Parameters
[in]componentsInitialises the data to this one

◆ Pixel() [3/6]

template<PixelFormat FT>
castor::Pixel< FT >::Pixel ( Pixel< FT > const & pxl)

Copy Constructor.

Parameters
[in]pxlThe Pixel object to copy

◆ Pixel() [4/6]

template<PixelFormat FT>
castor::Pixel< FT >::Pixel ( Pixel< FT > && pxl)
noexcept

Move Constructor.

Parameters
[in]pxlThe Pixel object to move

◆ Pixel() [5/6]

template<PixelFormat FT>
template<PixelFormat FU>
castor::Pixel< FT >::Pixel ( Array< uint8_t, PixelDefinitionsT< FU >::Size > const & components)
explicit

Constructor.

Remarks
This Pixel owns it's data
Parameters
[in]componentsInitialises the data to this one

◆ Pixel() [6/6]

template<PixelFormat FT>
template<PixelFormat FU>
castor::Pixel< FT >::Pixel ( Pixel< FU > const & pxl)
explicit

Constructor.

Parameters
[in]pxlThe Pixel object to copy

◆ ~Pixel()

template<PixelFormat FT>
castor::Pixel< FT >::~Pixel ( )
noexcept

Destructor.

Member Function Documentation

◆ begin() [1/2]

template<PixelFormat FT>
iterator castor::Pixel< FT >::begin ( )
inline

Retrieves an iterator to the first element.

Returns
The iterator

◆ begin() [2/2]

template<PixelFormat FT>
const_iterator castor::Pixel< FT >::begin ( ) const
inline

Retrieves a constant iterator to the first element.

Returns
The iterator

◆ clear()

template<PixelFormat FT>
void castor::Pixel< FT >::clear ( )
noexcept

deallocate components

◆ constPtr()

template<PixelFormat FT>
component_const_ptr castor::Pixel< FT >::constPtr ( ) const
inline

Retrieves the pointer on constant datas.

Returns
The pointer

◆ end() [1/2]

template<PixelFormat FT>
iterator castor::Pixel< FT >::end ( )
inline

Retrieves an iterator to the last element.

Returns
The iterator

◆ end() [2/2]

template<PixelFormat FT>
const_iterator castor::Pixel< FT >::end ( ) const
inline

Retrieves a constant iterator to the last element.

Returns
The iterator

◆ getFormat()

template<PixelFormat FT>
static PixelFormat castor::Pixel< FT >::getFormat ( )
inlinestatic

Retrieves the pixel format.

Returns
The pixel format

◆ getSize()

template<PixelFormat FT>
static uint32_t castor::Pixel< FT >::getSize ( )
inlinestatic

Retrieves the pixel size.

Returns
The size

◆ link()

template<PixelFormat FT>
void castor::Pixel< FT >::link ( uint8_t * components)
noexcept

Links the data pointer to the one given in parameter.

Remarks
The pixel loses ownership of it's data

◆ mul()

template<PixelFormat FT>
template<PixelFormat FU>
Pixel< FU > castor::Pixel< FT >::mul ( Pixel< FU > const & px) const

Multiplication function.

Parameters
[in]pxThe pixel to multiply
Returns
The multiplication result

◆ operator*=()

template<PixelFormat FT>
template<PixelFormat FU>
Pixel & castor::Pixel< FT >::operator*= ( Pixel< FU > const & px)

◆ operator+=()

template<PixelFormat FT>
template<PixelFormat FU>
Pixel & castor::Pixel< FT >::operator+= ( Pixel< FU > const & px)

◆ operator-=()

template<PixelFormat FT>
template<PixelFormat FU>
Pixel & castor::Pixel< FT >::operator-= ( Pixel< FU > const & px)

◆ operator/=()

template<PixelFormat FT>
template<PixelFormat FU>
Pixel & castor::Pixel< FT >::operator/= ( Pixel< FU > const & px)

◆ operator=() [1/3]

template<PixelFormat FT>
Pixel & castor::Pixel< FT >::operator= ( Pixel< FT > && pxl)
noexcept

Copy assignment operator.

Parameters
[in]pxlThe Pixel object to copy
Returns
A reference to this Pixel object

◆ operator=() [2/3]

template<PixelFormat FT>
Pixel & castor::Pixel< FT >::operator= ( Pixel< FT > const & pxl)

Move assignment operator.

Parameters
[in]pxlThe Pixel object to move
Returns
A reference to this Pixel object

◆ operator=() [3/3]

template<PixelFormat FT>
template<PixelFormat FU>
Pixel & castor::Pixel< FT >::operator= ( Pixel< FU > const & pxl)

Copy assignment operator.

Parameters
[in]pxlThe Pixel object to copy
Returns
A reference to this Pixel object

◆ operator[]() [1/2]

template<PixelFormat FT>
component_ref castor::Pixel< FT >::operator[] ( uint8_t index)
inline

Retrieves the data at given index.

Remarks
No check is made, if you make an index error, expect a crash
Returns
A reference on data at wanted index

◆ operator[]() [2/2]

template<PixelFormat FT>
component_const_ref castor::Pixel< FT >::operator[] ( uint8_t index) const
inline

Retrieves the data at given index.

Remarks
No check is made, if you make an index error, expect a crash
Returns
A constant reference on data at wanted index

◆ ptr()

template<PixelFormat FT>
component_ptr castor::Pixel< FT >::ptr ( )
inline

Retrieves the pointer on datas.

Returns
The pointer

◆ set() [1/3]

template<PixelFormat FT>
template<PixelFormat FU>
void castor::Pixel< FT >::set ( Array< uint8_t, PixelDefinitionsT< FU >::Size > const & components)

Converts given data and copies it into this pixel's components.

Parameters
[in]componentsData to convert

◆ set() [2/3]

template<PixelFormat FT>
template<PixelFormat FU>
void castor::Pixel< FT >::set ( Pixel< FU > const & px)

Converts given pixel and copies it into this pixel's components.

Parameters
[in]pxPixel to convert

◆ set() [3/3]

template<PixelFormat FT>
template<PixelFormat FU>
void castor::Pixel< FT >::set ( uint8_t const * components)

Converts given data and copies it into this pixel's components.

Parameters
[in]componentsData to convert

◆ sum()

template<PixelFormat FT>
template<typename U >
void castor::Pixel< FT >::sum ( U & result) const

Computes the sum of all components.

Parameters
[out]resultReceives the sum

◆ unlink()

template<PixelFormat FT>
void castor::Pixel< FT >::unlink ( )
noexcept

Unlinks the data pointer from the ones previously given.

Remarks
The pixel regains ownership of it's data

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