Porytiles
Loading...
Searching...
No Matches
porytiles2::Image< PixelType > Class Template Reference

A template for two-dimensional images with arbitrarily typed pixel values. More...

#include <image.hpp>

Public Member Functions

 Image ()
 
 Image (std::size_t width, std::size_t height)
 
 Image (std::size_t width, std::size_t height, std::vector< Rgba32 > palette)
 
PixelType at (std::size_t i) const
 Fetches the pixel value at a given one-dimensional pixel index.
 
PixelType at (std::size_t row, std::size_t col) const
 Fetches the pixel value at a given row and column.
 
void set (std::size_t i, PixelType pixel)
 Sets the pixel value at a given one-dimensional pixel index.
 
void set (std::size_t row, std::size_t col, PixelType pixel)
 Sets the pixel value at a given row and column.
 
std::size_t width () const
 Gets the width of this image in pixels.
 
std::size_t height () const
 Gets the height of this image in pixels.
 
std::size_t size () const
 Gets the size of this image in pixels.
 
const std::optional< std::vector< Rgba32 > > & palette () const
 

Detailed Description

template<typename PixelType>
class porytiles2::Image< PixelType >

A template for two-dimensional images with arbitrarily typed pixel values.

Clients who need to operate on images can use this class to read image data and manipulate image contents. This value type makes no assumptions about the underlying image storage format. Image provides an optional palette field for images which want to store an IndexPixel pixel type into a fixed palette of colors.

Template Parameters
PixelTypeThe pixel type for this Image

Definition at line 24 of file image.hpp.

Constructor & Destructor Documentation

◆ Image() [1/3]

template<typename PixelType >
porytiles2::Image< PixelType >::Image ( )
inline

Definition at line 26 of file image.hpp.

◆ Image() [2/3]

template<typename PixelType >
porytiles2::Image< PixelType >::Image ( std::size_t  width,
std::size_t  height 
)
inlineexplicit

Definition at line 28 of file image.hpp.

◆ Image() [3/3]

template<typename PixelType >
porytiles2::Image< PixelType >::Image ( std::size_t  width,
std::size_t  height,
std::vector< Rgba32 palette 
)
inline

Definition at line 30 of file image.hpp.

Member Function Documentation

◆ at() [1/2]

template<typename PixelType >
PixelType porytiles2::Image< PixelType >::at ( std::size_t  i) const
inline

Fetches the pixel value at a given one-dimensional pixel index.

The one-dimensional index assumes the image as an array of pixels, where the length of the array is the image's width times height.

Parameters
iThe one-dimensional pixel index.
Returns
The pixel value at the given pixel index.

Definition at line 45 of file image.hpp.

◆ at() [2/2]

template<typename PixelType >
PixelType porytiles2::Image< PixelType >::at ( std::size_t  row,
std::size_t  col 
) const
inline

Fetches the pixel value at a given row and column.

Parameters
rowThe pixel row.
colThe pixel column.
Returns
The pixel value at the given row and column.

Definition at line 60 of file image.hpp.

◆ height()

template<typename PixelType >
std::size_t porytiles2::Image< PixelType >::height ( ) const
inline

Gets the height of this image in pixels.

Returns
The height of this image in pixels.

Definition at line 118 of file image.hpp.

◆ palette()

template<typename PixelType >
const std::optional< std::vector< Rgba32 > > & porytiles2::Image< PixelType >::palette ( ) const
inline

Definition at line 133 of file image.hpp.

◆ set() [1/2]

template<typename PixelType >
void porytiles2::Image< PixelType >::set ( std::size_t  i,
PixelType  pixel 
)
inline

Sets the pixel value at a given one-dimensional pixel index.

Parameters
iThe one-dimensional pixel index.
pixelThe pixel value to set at the given pixel index.

Definition at line 77 of file image.hpp.

◆ set() [2/2]

template<typename PixelType >
void porytiles2::Image< PixelType >::set ( std::size_t  row,
std::size_t  col,
PixelType  pixel 
)
inline

Sets the pixel value at a given row and column.

Parameters
rowThe pixel row.
colThe pixel column.
pixelThe pixel value to set at the given pixel row and column.

Definition at line 92 of file image.hpp.

◆ size()

template<typename PixelType >
std::size_t porytiles2::Image< PixelType >::size ( ) const
inline

Gets the size of this image in pixels.

Returns
The size of this image in pixels.

Definition at line 128 of file image.hpp.

◆ width()

template<typename PixelType >
std::size_t porytiles2::Image< PixelType >::width ( ) const
inline

Gets the width of this image in pixels.

Returns
The width of this image in pixels.

Definition at line 108 of file image.hpp.


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