Aether
SDL2 based UI Framework for NX
Image.hpp
1 #ifndef AETHER_IMAGE_HPP
2 #define AETHER_IMAGE_HPP
3 
4 #include "Aether/base/Texture.hpp"
5 
6 namespace Aether {
12  class Image : public Texture {
13  private:
17  enum class Type {
18  File,
19  Pointer,
20  Vector,
21  };
22 
26  struct Ptr {
27  unsigned char * ptr;
28  size_t size;
29  } mem;
30  std::vector<unsigned char> copy;
31  std::string path;
32  Type type;
34  size_t scaleWidth_;
35  size_t scaleHeight_;
40  Drawable * renderDrawable();
41 
47  void performRender(const Render type);
48 
49  public:
60  Image(const int x, const int y, unsigned char * data, const size_t size, const Render type = Render::Sync);
61 
70  Image(const int x, const int y, const std::string & path, const Render type = Render::Sync);
71 
80  Image(const int x, const int y, const std::vector<unsigned char> & data, const Render type = Render::Sync);
81 
92  bool setScaleDimensions(const size_t width, const size_t height);
93 
99  size_t scaleWidth();
100 
106  size_t scaleHeight();
107 
111  ~Image();
112  };
113 };
114 
115 #endif
size_t scaleHeight()
Returns the currently set scale height.
~Image()
Destroys the image element.
Image(const int x, const int y, unsigned char *data, const size_t size, const Render type=Render::Sync)
Constructs a new Image element using a pointer to data.
Stores either a surface or texture which can be drawn on screen by providing a renderer to render()...
Definition: Drawable.hpp:22
int x()
Returns x-coordinate of element.
A Texture is an element that stores a texture to render in the window. It can&#39;t be instantiated alone...
Definition: Texture.hpp:24
Base namespace for all Aether related classes and functions.
size_t scaleWidth()
Returns the currently set scale width.
Element for rendering an image, either from memory or a file system.
Definition: Image.hpp:12
Render
Supported "on create" texture rendering options.
Definition: Texture.hpp:11
bool setScaleDimensions(const size_t width, const size_t height)
Sets the dimensions to scale the image to when rendered. Scaling produces a better image quality when...
int y()
Returns y-coordinate of element.