SpatiumLib
Public Member Functions | Protected Attributes | List of all members
spatium::Image< T, N > Class Template Reference

Templated image container. More...

#include <Image.h>

Collaboration diagram for spatium::Image< T, N >:
Collaboration graph
[legend]

Public Member Functions

 Image ()
 Constructor Constructs an image with a single pixel to ensure function pixel() can always return a reference to a value. More...
 
 Image (size_t width, size_t height)
 Constructor. More...
 
 Image (const Image &other)
 Copy constructor. Deep copy. More...
 
 Image (Image &&other)
 Move constructor. More...
 
Imageoperator= (const Image &other)
 Copy assignment operator Deep copy. More...
 
Image operator= (Image &&other)
 Move assignment operator. More...
 
 ~Image ()=default
 Destructor. More...
 
bool operator== (const Image &other) const
 Compare operator. Is equal. More...
 
bool operator!= (const Image &other) const
 Compare operator. Is unequal. More...
 
size_t width () const
 Image width in pixels. More...
 
size_t height () const
 Image height in pixels. More...
 
size_t channelCount () const
 Channel count of pixel values. More...
 
std::array< T, N > * imageDataPtr () const
 Pointer to image data. More...
 
void resize (size_t newWidth, size_t newHeight)
 Resize image. This allocates new memory without copying pixel values. More...
 
void clear ()
 Clear the image data (Set to zero) More...
 
std::array< T, N > pixel (size_t x, size_t y, bool checkBounds=true) const
 Access pixel by value. More...
 
std::array< T, N > & pixel (size_t x, size_t y, bool checkBounds=true)
 Access pixel by reference. More...
 

Protected Attributes

size_t m_width
 Image width in pixels. More...
 
size_t m_height
 Image height in pixels. More...
 
std::unique_ptr< std::array< T, N >[]> m_imageData
 Pointer to image data. More...
 

Detailed Description

template<typename T = unsigned char, int N = 3>
class spatium::Image< T, N >

Templated image container.

An image has no knowledge about color. The minimum image size is 1x1 pixel.

Constructor & Destructor Documentation

◆ Image() [1/4]

template<typename T = unsigned char, int N = 3>
spatium::Image< T, N >::Image ( )
inline

Constructor Constructs an image with a single pixel to ensure function pixel() can always return a reference to a value.

Exceptions
std::bad_allocon bad allocation

◆ Image() [2/4]

template<typename T = unsigned char, int N = 3>
spatium::Image< T, N >::Image ( size_t  width,
size_t  height 
)
inline

Constructor.

Parameters
[in]widthImage width in pixels
[in]heightImage height in pixels
Exceptions
std::bad_allocon bad allocation

◆ Image() [3/4]

template<typename T = unsigned char, int N = 3>
spatium::Image< T, N >::Image ( const Image< T, N > &  other)
inline

Copy constructor. Deep copy.

Exceptions
std::bad_allocon bad allocation

◆ Image() [4/4]

template<typename T = unsigned char, int N = 3>
spatium::Image< T, N >::Image ( Image< T, N > &&  other)
inline

Move constructor.

Exceptions
std::bad_allocon bad allocation

◆ ~Image()

template<typename T = unsigned char, int N = 3>
spatium::Image< T, N >::~Image ( )
default

Destructor.

Member Function Documentation

◆ channelCount()

template<typename T = unsigned char, int N = 3>
size_t spatium::Image< T, N >::channelCount ( ) const
inline

Channel count of pixel values.

◆ clear()

template<typename T = unsigned char, int N = 3>
void spatium::Image< T, N >::clear ( )
inline

Clear the image data (Set to zero)

◆ height()

template<typename T = unsigned char, int N = 3>
size_t spatium::Image< T, N >::height ( ) const
inline

Image height in pixels.

◆ imageDataPtr()

template<typename T = unsigned char, int N = 3>
std::array<T, N>* spatium::Image< T, N >::imageDataPtr ( ) const
inline

Pointer to image data.

◆ operator!=()

template<typename T = unsigned char, int N = 3>
bool spatium::Image< T, N >::operator!= ( const Image< T, N > &  other) const
inline

Compare operator. Is unequal.

Parameters
[in]otherOther image
Returns
True if unequal, otherwise false

◆ operator=() [1/2]

template<typename T = unsigned char, int N = 3>
Image& spatium::Image< T, N >::operator= ( const Image< T, N > &  other)
inline

Copy assignment operator Deep copy.

Exceptions
std::bad_allocon bad allocation

◆ operator=() [2/2]

template<typename T = unsigned char, int N = 3>
Image spatium::Image< T, N >::operator= ( Image< T, N > &&  other)
inline

Move assignment operator.

◆ operator==()

template<typename T = unsigned char, int N = 3>
bool spatium::Image< T, N >::operator== ( const Image< T, N > &  other) const
inline

Compare operator. Is equal.

Parameters
[in]otherOther image
Returns
True if equal, otherwise false

◆ pixel() [1/2]

template<typename T = unsigned char, int N = 3>
std::array<T, N> spatium::Image< T, N >::pixel ( size_t  x,
size_t  y,
bool  checkBounds = true 
) const
inline

Access pixel by value.

Parameters
[in]xX coordinate
[in]yY coordinate
[in]checkBoundsCheck bounds (default = true). If the coordinates
Returns
Pixel value

◆ pixel() [2/2]

template<typename T = unsigned char, int N = 3>
std::array<T, N>& spatium::Image< T, N >::pixel ( size_t  x,
size_t  y,
bool  checkBounds = true 
)
inline

Access pixel by reference.

Parameters
[in]xX coordinate
[in]yY coordinate
Returns
Pixel reference

◆ resize()

template<typename T = unsigned char, int N = 3>
void spatium::Image< T, N >::resize ( size_t  newWidth,
size_t  newHeight 
)
inline

Resize image. This allocates new memory without copying pixel values.

Parameters
[in]widthImage width in pixels
[in]heightImage height in pixels
Exceptions
std::bad_allocon bad allocation

◆ width()

template<typename T = unsigned char, int N = 3>
size_t spatium::Image< T, N >::width ( ) const
inline

Image width in pixels.

Member Data Documentation

◆ m_height

template<typename T = unsigned char, int N = 3>
size_t spatium::Image< T, N >::m_height
protected

Image height in pixels.

◆ m_imageData

template<typename T = unsigned char, int N = 3>
std::unique_ptr<std::array<T, N>[]> spatium::Image< T, N >::m_imageData
protected

Pointer to image data.

◆ m_width

template<typename T = unsigned char, int N = 3>
size_t spatium::Image< T, N >::m_width
protected

Image width in pixels.


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