Aether
SDL2 based UI Framework for NX
Public Member Functions | List of all members
Aether::ImageData Class Reference

Represents an object containing the raw pixel data for an image/texture as an array, along with required metadata such as width and height. More...

#include <ImageData.hpp>

Public Member Functions

 ImageData ()
 The number of channels in the image (usually 3 or 4) More...
 
 ImageData (const std::vector< uint8_t > &data, const size_t width, const size_t height, const uint8_t channels)
 Constructs a new ImageData object from the given raw bytes. More...
 
 ImageData (const std::vector< Colour > &pixels, const size_t width, const size_t height, const uint8_t channels)
 Constructs a new ImageData object from the given raw bytes. More...
 
bool valid () const
 Returns whether the associated image is considered 'valid' (i.e. has some pixel data). More...
 
size_t width () const
 Returns the width of the stored image in pixels. More...
 
size_t height () const
 Returns the height of the stored image in pixels. More...
 
uint8_t channels () const
 Returns the number of channels used within the stored image. This will usually return 3 (RGB) or 4 (RGBA). More...
 
ColourcolourAt (const size_t x, const size_t y) const
 Returns a pointer to the colour of a pixel at the given coordinate. More...
 
std::vector< uint8_t > toByteVector () const
 Returns the stored image as a vector of bytes (i.e. one byte per channel). e.g. For an RGB image: [r0, g0, b0, r1, g1, b1, etc...]. More...
 
std::vector< ColourtoColourVector () const
 Returns the stored image as a vector of colours. More...
 

Detailed Description

Represents an object containing the raw pixel data for an image/texture as an array, along with required metadata such as width and height.

Note
Only RGB and RGBA (i.e. 3 or 4 channels) are supported.

Constructor & Destructor Documentation

◆ ImageData() [1/3]

Aether::ImageData::ImageData ( )

The number of channels in the image (usually 3 or 4)

Constructs a new (invalid) ImageData object.

◆ ImageData() [2/3]

Aether::ImageData::ImageData ( const std::vector< uint8_t > &  data,
const size_t  width,
const size_t  height,
const uint8_t  channels 
)

Constructs a new ImageData object from the given raw bytes.

Parameters
dataVector of bytes containing pixels in RGB(A) format.
widthWidth of image in pixels
heightHeight of image in pixels
channelsNumber of channels forming the image.

◆ ImageData() [3/3]

Aether::ImageData::ImageData ( const std::vector< Colour > &  pixels,
const size_t  width,
const size_t  height,
const uint8_t  channels 
)

Constructs a new ImageData object from the given raw bytes.

Parameters
pixelsVector of pixels.
widthWidth of image in pixels
heightHeight of image in pixels
channelsNumber of channels forming the image.

Member Function Documentation

◆ channels()

uint8_t Aether::ImageData::channels ( ) const

Returns the number of channels used within the stored image. This will usually return 3 (RGB) or 4 (RGBA).

Returns
Number of channels used in the stored image.

◆ colourAt()

Colour* Aether::ImageData::colourAt ( const size_t  x,
const size_t  y 
) const

Returns a pointer to the colour of a pixel at the given coordinate.

Parameters
xx-coordinate of pixel
yy-coordinate of pixel
Returns
Pointer to pixel colour, or nullptr if outside of image

◆ height()

size_t Aether::ImageData::height ( ) const

Returns the height of the stored image in pixels.

Returns
Height of the stored image in pixels.

◆ toByteVector()

std::vector<uint8_t> Aether::ImageData::toByteVector ( ) const

Returns the stored image as a vector of bytes (i.e. one byte per channel). e.g. For an RGB image: [r0, g0, b0, r1, g1, b1, etc...].

Returns
Vector of image pixels in raw byte format.

◆ toColourVector()

std::vector<Colour> Aether::ImageData::toColourVector ( ) const

Returns the stored image as a vector of colours.

Returns
Vector of image pixels.

◆ valid()

bool Aether::ImageData::valid ( ) const

Returns whether the associated image is considered 'valid' (i.e. has some pixel data).

Returns
true if the stored image and metadata are valid values, false wtherwise.

◆ width()

size_t Aether::ImageData::width ( ) const

Returns the width of the stored image in pixels.

Returns
Width of the stored image in pixels.

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