libfacade 1.1
A library for manipulating PNG images with payloads.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
facade::png::PixelSpan< PixelType > Class Template Reference

A span of data representing the underlying bits or bytes of a pixel. More...

#include <png.hpp>

Public Member Functions

 PixelSpan ()
 
 PixelSpan (const PixelSpan &other)
 
Pixel operator[] (std::size_t index) const
 Syntactic sugar to get a facade::png::Pixel variant out of this span.
 
const std::uint8_t * data () const
 Return the underlying raw byte data representing this pixel span.
 
std::size_t data_size () const
 Return the size of this pixel span.
 
Pixel get (std::size_t index=0) const
 Retrieve a facade::png::Pixel variant of the underlying pixel type at the given index.
 
void set (const Pixel &pixel, std::size_t index=0)
 Set a given facade::png::Pixel variant at the given offset.
 

Static Public Attributes

static const std::size_t Samples = (8 / PixelType::Bits) + static_cast<int>(PixelType::Bits > 8)
 The amount of samples possibly contained within this pixel span.
 

Detailed Description

template<typename PixelType>
class facade::png::PixelSpan< PixelType >

A span of data representing the underlying bits or bytes of a pixel.

This class is the binary bridge which allows us to access pixel data that is less than 8 bits in size. It relies on a union of a byte and a byte array to contain as low as 1-bit pixels (with 8 samples) and as large as 64-bit pixels (with 1 sample). This design is necessary to properly type pixel data as it exists within raw PNG image data, allowing us to essentially create objects such as vectors of pixels, which then become a facade::png::ScanlineBase.

Template Parameters
PixelTypeThe base pixel type to use for this span of pixel data.

Constructor & Destructor Documentation

◆ PixelSpan() [1/2]

template<typename PixelType >
facade::png::PixelSpan< PixelType >::PixelSpan ( )
inline

◆ PixelSpan() [2/2]

template<typename PixelType >
facade::png::PixelSpan< PixelType >::PixelSpan ( const PixelSpan< PixelType > &  other)
inline

Member Function Documentation

◆ data()

template<typename PixelType >
const std::uint8_t * facade::png::PixelSpan< PixelType >::data ( ) const
inline

Return the underlying raw byte data representing this pixel span.

◆ data_size()

template<typename PixelType >
std::size_t facade::png::PixelSpan< PixelType >::data_size ( ) const
inline

Return the size of this pixel span.

◆ get()

template<typename PixelType >
Pixel facade::png::PixelSpan< PixelType >::get ( std::size_t  index = 0) const
inline

Retrieve a facade::png::Pixel variant of the underlying pixel type at the given index.

Parameters
indexThe index of the sample in the pixel to retrieve. 0 for anything over or equal to 8-bit, anything less than facade::png::PixelSpan::Samples for less than 8-bit.
Exceptions
facade::exception::OutOfBounds

◆ operator[]()

template<typename PixelType >
Pixel facade::png::PixelSpan< PixelType >::operator[] ( std::size_t  index) const
inline

Syntactic sugar to get a facade::png::Pixel variant out of this span.

Parameters
indexThe index of the sample to retrieve.
See also
facade::png::PixelSpan::get

◆ set()

template<typename PixelType >
void facade::png::PixelSpan< PixelType >::set ( const Pixel pixel,
std::size_t  index = 0 
)
inline

Set a given facade::png::Pixel variant at the given offset.

Parameters
pixelThe pixel variant to write to the pixel span.
indexThe index of the sample to set. For pixels greater than or equal to 8-bits, this should be 0. For pixels less than 8-bits, this can be anything less than facade::png::PixelSpan::Samples.
See also
facade::png::PixelSpan::get
Exceptions
facade::exception::PixelMismatch
facade::exception::OutOfBounds

Member Data Documentation

◆ bits

template<typename PixelType >
std::uint8_t facade::png::PixelSpan< PixelType >::bits

◆ bytes

template<typename PixelType >
std::uint8_t facade::png::PixelSpan< PixelType >::bytes[PixelType::Bits/8]

◆ Samples

template<typename PixelType >
const std::size_t facade::png::PixelSpan< PixelType >::Samples = (8 / PixelType::Bits) + static_cast<int>(PixelType::Bits > 8)
static

The amount of samples possibly contained within this pixel span.

Pixels that are greater than or equal to 8 bits are considered 1 sample.


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