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

The base scanline class containing a row of facade::png::PixelSpan of the given pixel type. More...

#include <png.hpp>

Public Types

using Span = PixelSpan< PixelType >
 The pixel span this scanline holds.
 

Public Member Functions

 ScanlineBase ()
 
 ScanlineBase (std::uint8_t filter_type, std::size_t width)
 
 ScanlineBase (std::uint8_t filter_type, std::vector< Span > pixel_data)
 
 ScanlineBase (const ScanlineBase &other)
 
Pixel operator[] (std::size_t index) const
 Syntactic sugar for getting a facade::png::Pixel variant.
 
std::uint8_t filter_type () const
 Get the filter type of this scanline.
 
void set_filter_type (std::uint8_t filter_type)
 Set the filter type of this scanline.
 
__attribute__((used)) const std std::size_t pixel_span () const
 Return a const reference to the underlying pixel data array.
 
std::size_t pixel_width () const
 Return the size, in samples, of the given scanline.
 
Spanget_span (std::size_t index)
 Get the facade::png::PixelSpan reference at the given index.
 
const Spanget_span (std::size_t index) const
 Get the const facade::png::PixelSpan reference at the given index.
 
void set_span (const Span &span, std::size_t index)
 Set the facade::png::PixelSpan object at the given index.
 
Pixel get_pixel (std::size_t index) const
 Get the pixel at the given index.
 
void set_pixel (const Pixel &pixel, std::size_t index)
 Set the pixel at the given index.
 
std::vector< std::uint8_t > to_raw () const
 Convert this scanline to raw byte form.
 
ScanlineBase reconstruct (std::optional< ScanlineBase > previous) const
 Reconstruct the scanline based on its filter value.
 
ScanlineBase filter (std::optional< ScanlineBase > previous) const
 Calculate all filters and determine the best compressed filter among them.
 
ScanlineBase filter (FilterType filter_type, std::optional< ScanlineBase > previous) const
 Calculate the given filter type on this scanline.
 

Static Public Member Functions

static ScanlineBase read_line (const std::vector< std::uint8_t > &raw_data, std::size_t offset, std::size_t width)
 Create a scanline object from raw data at the given data offset.
 
static std::vector< ScanlineBasefrom_raw (const Header &header, const std::vector< std::uint8_t > &raw_data)
 Collect a vector of scanlines from the given raw data.
 

Detailed Description

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

The base scanline class containing a row of facade::png::PixelSpan of the given pixel type.

Template Parameters
PixelTypeThe pixel type this scanline holds.

Member Typedef Documentation

◆ Span

template<typename PixelType >
using facade::png::ScanlineBase< PixelType >::Span = PixelSpan<PixelType>

The pixel span this scanline holds.

Constructor & Destructor Documentation

◆ ScanlineBase() [1/4]

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

◆ ScanlineBase() [2/4]

template<typename PixelType >
facade::png::ScanlineBase< PixelType >::ScanlineBase ( std::uint8_t  filter_type,
std::size_t  width 
)
inline

◆ ScanlineBase() [3/4]

template<typename PixelType >
facade::png::ScanlineBase< PixelType >::ScanlineBase ( std::uint8_t  filter_type,
std::vector< Span pixel_data 
)
inline

◆ ScanlineBase() [4/4]

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

Member Function Documentation

◆ filter() [1/2]

template<typename PixelType >
ScanlineBase facade::png::ScanlineBase< PixelType >::filter ( FilterType  filter_type,
std::optional< ScanlineBase< PixelType > >  previous 
) const

Calculate the given filter type on this scanline.

Parameters
filter_typeThe facade::png::FilterType to assign on the scanline.
previousThe previous scanline that is sometimes necessary for filtering. Typically the previous scanline if y > 0.
Returns
The filtered scanline result.
Exceptions
facade::exception::AlreadyFiltered
facade::exception::ScanlineMismatch
facade::exception::NoPixels
facade::exception::InvalidFilterType

◆ filter() [2/2]

template<typename PixelType >
ScanlineBase facade::png::ScanlineBase< PixelType >::filter ( std::optional< ScanlineBase< PixelType > >  previous) const

Calculate all filters and determine the best compressed filter among them.

Returns
The newly filtered scanline.
Parameters
previousThe previous scanline, if any. This is sometimes necessary for reconstruction procedures.
See also
facade::png::ScanlineBase::filter(std::uint8_t,std::optional<facade::png::ScanlineBase<PixelType>>)

◆ filter_type()

template<typename PixelType >
std::uint8_t ScanlineBase::filter_type

Get the filter type of this scanline.

◆ from_raw()

template<typename PixelType >
std::vector< ScanlineBase< PixelType > > ScanlineBase::from_raw ( const Header header,
const std::vector< std::uint8_t > &  raw_data 
)
static

Collect a vector of scanlines from the given raw data.

Parameters
headerThe header of the given image to collect scanlines from.
raw_dataThe raw pixel data from the uncompressed IDAT chunks.
Returns
A vector of scanlines of the given scanline type.
Exceptions
facade::exception::PixelMismatch
facade::exception::OutOfBounds

◆ get_pixel()

template<typename PixelType >
Pixel ScanlineBase::get_pixel ( std::size_t  index) const

Get the pixel at the given index.

Index, in this case, is bound by the value returned by facade::png::Header::width.

Exceptions
facade::exception::OutOfBounds

◆ get_span() [1/2]

template<typename PixelType >
Span & facade::png::ScanlineBase< PixelType >::get_span ( std::size_t  index)

Get the facade::png::PixelSpan reference at the given index.

Index, in this case, is bound by facade::png::ScanlineBase::pixel_span.

Exceptions
facade::exception::OutOfBounds

◆ get_span() [2/2]

template<typename PixelType >
const ScanlineBase< PixelType >::Span & ScanlineBase::get_span ( std::size_t  index) const

Get the const facade::png::PixelSpan reference at the given index.

Index, in this case, is bound by facade::png::ScanlineBase::pixel_span.

Exceptions
facade::exception::OutOfBounds

◆ operator[]()

template<typename PixelType >
Pixel ScanlineBase::operator[] ( std::size_t  index) const

Syntactic sugar for getting a facade::png::Pixel variant.

See also
facade::png::ScanlineBase::get_pixel

◆ pixel_span()

template<typename PixelType >
__attribute__((used)) const std std::size_t facade::png::ScanlineBase< PixelType >::pixel_span ( ) const

Return a const reference to the underlying pixel data array.

Return the size, in terms of pixel span objects, of the underlying scanline.

Warning
This is not always equivalent to facade::png::Header::width– sometimes it's less than that, due to pixel types that go below 8 bits.
See also
facade::png::ScanlineBase::pixel_width

◆ pixel_width()

template<typename PixelType >
std::size_t facade::png::ScanlineBase< PixelType >::pixel_width ( ) const

Return the size, in samples, of the given scanline.

Warning
This is not always equivalent to facade::png::Header::width– sometimes it's more than that, due to padding issues with samples less than 8 bits. You should know that this returns what the scanline is capable of holding, and not necessarily so much what it is holding.

◆ read_line()

template<typename PixelType >
ScanlineBase< PixelType > ScanlineBase::read_line ( const std::vector< std::uint8_t > &  raw_data,
std::size_t  offset,
std::size_t  width 
)
static

Create a scanline object from raw data at the given data offset.

Parameters
raw_dataThe raw data byte vector to read from.
offsetThe offset to begin reading the scanline.
widthThe width of the scanline.
Returns
The parsed scanline from the raw data.
Exceptions
facade::exception::OutOfBounds

◆ reconstruct()

template<typename PixelType >
ScanlineBase< PixelType > ScanlineBase::reconstruct ( std::optional< ScanlineBase< PixelType > >  previous) const

Reconstruct the scanline based on its filter value.

This essentially performs the inverse of what the facade::png::ScanlineBase::filter functions do.

Parameters
previousThe previous scanline, if any. This is sometimes necessary for reconstruction procedures.
Returns
The reconstructed scanline.
Exceptions
facade::exception::ScanlineMismatch
facade::exception::NoPixels
facade::exception::InvalidFilterType

◆ set_filter_type()

template<typename PixelType >
void ScanlineBase::set_filter_type ( std::uint8_t  filter_type)

Set the filter type of this scanline.

◆ set_pixel()

template<typename PixelType >
void ScanlineBase::set_pixel ( const Pixel pixel,
std::size_t  index 
)

Set the pixel at the given index.

Index, in this case, is bound by the value returned by facade::png::Header::width.

Exceptions
facade::exception::OutOfBounds

◆ set_span()

template<typename PixelType >
void ScanlineBase::set_span ( const Span span,
std::size_t  index 
)

Set the facade::png::PixelSpan object at the given index.

Index, in this case, is bound by facade::png::ScanlineBase::pixel_span.

Parameters
spanThe pixel span to set.
indexThe index of the span to set it to.
Exceptions
facade::exception::OutOfBounds

◆ to_raw()

template<typename PixelType >
std::vector< std::uint8_t > ScanlineBase::to_raw

Convert this scanline to raw byte form.


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