Aether
SDL2 based UI Framework for NX
ImageData.hpp
1 #ifndef AETHER_IMAGEDATA_HPP
2 #define AETHER_IMAGEDATA_HPP
3 
4 #include "Aether/types/Colour.hpp"
5 #include <cstddef>
6 #include <cstdint>
7 #include <vector>
8 
9 namespace Aether {
16  class ImageData {
17  private:
18  std::vector<Colour> pixels_;
19  size_t width_;
20  size_t height_;
21  uint8_t channels_;
23  public:
27  ImageData();
28 
37  ImageData(const std::vector<uint8_t> & data, const size_t width, const size_t height, const uint8_t channels);
38 
47  ImageData(const std::vector<Colour> & pixels, const size_t width, const size_t height, const uint8_t channels);
48 
54  bool valid() const;
55 
61  size_t width() const;
62 
68  size_t height() const;
69 
76  uint8_t channels() const;
77 
85  Colour * colourAt(const size_t x, const size_t y) const;
86 
93  std::vector<uint8_t> toByteVector() const;
94 
100  std::vector<Colour> toColourVector() const;
101  };
102 };
103 
104 #endif
Colour * colourAt(const size_t x, const size_t y) const
Returns a pointer to the colour of a pixel at the given coordinate.
size_t height() const
Returns the height of the stored image in pixels.
ImageData()
The number of channels in the image (usually 3 or 4)
uint8_t channels() const
Returns the number of channels used within the stored image. This will usually return 3 (RGB) or 4 (R...
size_t width() const
Returns the width of the stored image in pixels.
Stores RGBA values representing a colour. Each component can be within the range 0 to 255 (inclusive)...
Definition: Colour.hpp:9
std::vector< Colour > toColourVector() const
Returns the stored image as a vector of colours.
Base namespace for all Aether related classes and functions.
Represents an object containing the raw pixel data for an image/texture as an array, along with required metadata such as width and height.
Definition: ImageData.hpp:16
bool valid() const
Returns whether the associated image is considered &#39;valid&#39; (i.e. has some pixel data).
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...