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

A sample of data for a given pixel. More...

#include <png.hpp>

Inheritance diagram for facade::png::Sample< _Base, _Bits >:
facade::png::GrayscalePixel< std::uint8_t > facade::png::GrayscalePixel< _Base, _Bits > facade::png::PalettePixel< _Bits > facade::png::AlphaGrayscalePixel< _Base >

Public Types

using Base = _Base
 The base type used by this sample.
 

Public Member Functions

 Sample ()
 
 Sample (Base value)
 
 Sample (const Sample &other)
 
Base operator* () const
 Syntactic sugar to get the value of this sample.
 
Sampleoperator= (Base value)
 Syntactic sugar to assign the value of this sample.
 
Base value () const
 Get the value retained by this sample.
 
void set_value (Base value)
 Assign the given value to this sample.
 

Static Public Attributes

static const std::size_t Bits = _Bits
 The size, in bits, of this sample.
 
static const std::size_t Max = (1 << Bits) - 1
 The maximum value that can be used with this sample.
 

Detailed Description

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
class facade::png::Sample< _Base, _Bits >

A sample of data for a given pixel.

A sample is a unit of bits representing a given pixel value (e.g., a color channel). It can be a variety of sizes:

As a result, it can be two different types:

To make typing easier, a series of typedefs are created to declare what type of sample you want.

Template Parameters
_BaseThe base type that contains the sample value. Can be std::uint8_t or std::uint16_t.
_BitsThe size, in bits, of the desired sample. Can be 1, 2, 4, 8 or 16.
See also
facade::png::Sample1Bit
facade::png::Sample2Bit
facade::png::Sample4Bit
facade::png::Sample8Bit
facade::png::Sample16Bit

Member Typedef Documentation

◆ Base

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
using facade::png::Sample< _Base, _Bits >::Base = _Base

The base type used by this sample.

Constructor & Destructor Documentation

◆ Sample() [1/3]

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
facade::png::Sample< _Base, _Bits >::Sample ( )
inline

◆ Sample() [2/3]

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
facade::png::Sample< _Base, _Bits >::Sample ( Base  value)
inline

◆ Sample() [3/3]

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
facade::png::Sample< _Base, _Bits >::Sample ( const Sample< _Base, _Bits > &  other)
inline

Member Function Documentation

◆ operator*()

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
Base facade::png::Sample< _Base, _Bits >::operator* ( ) const
inline

Syntactic sugar to get the value of this sample.

See also
facade::png::Sample::value

◆ operator=()

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
Sample & facade::png::Sample< _Base, _Bits >::operator= ( Base  value)
inline

Syntactic sugar to assign the value of this sample.

See also
facade::png::Sample::set_value

◆ set_value()

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
void facade::png::Sample< _Base, _Bits >::set_value ( Base  value)
inline

Assign the given value to this sample.

Throws an exception if the value provided is too large for the given sample size.

Parameters
valueThe value to assign to the sample.
Exceptions
facade::exception::IntegerOverflow

◆ value()

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
Base facade::png::Sample< _Base, _Bits >::value ( ) const
inline

Get the value retained by this sample.

Member Data Documentation

◆ Bits

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
const std::size_t facade::png::Sample< _Base, _Bits >::Bits = _Bits
static

The size, in bits, of this sample.

◆ Max

template<typename _Base = std::uint8_t, std::size_t _Bits = sizeof(_Base)*8>
const std::size_t facade::png::Sample< _Base, _Bits >::Max = (1 << Bits) - 1
static

The maximum value that can be used with this sample.


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