|
Allolib
1.0
C++ Components For Interactive Multimedia
|
Interface for loading image files. More...
Classes | |
| struct | RGBAPix |
Public Member Functions | |
| Image (const Image &)=default | |
| Image (Image &&)=default | |
| Image & | operator= (const Image &)=default |
| Image & | operator= (Image &&)=default |
| Image (const std::string &filename) | |
| bool | load (const std::string &filePath) |
| Load image from disk. More... | |
| bool | save (const std::string &filePath) |
| Save image to disk. More... | |
| const std::string & | filepath () const |
| File path to image. | |
| bool | loaded () const |
| Whether image was loaded from file. | |
| std::vector< uint8_t > & | array () |
| Get pixels as an Array. | |
| const std::vector< uint8_t > & | array () const |
| Get pixels as an Array (read-only) | |
| template<typename T = RGBAPix> | |
| T * | pixels () |
| Get pointer to pixels. | |
| template<typename T = RGBAPix> | |
| const T * | pixels () const |
| Get pointer to pixels (read-only) | |
| unsigned | width () const |
| Get number of bytes per pixel. More... | |
| unsigned | height () const |
| Get height, in pixels. | |
| int | compression () const |
| Get compression flags for saving. | |
| Image & | compression (int flags) |
| Set compression flags for saving. More... | |
| template<typename Pix = RGBAPix> | |
| const Pix & | at (unsigned x, unsigned y) const |
| Get read-only reference to a pixel. More... | |
| template<typename Pix = RGBAPix> | |
| Pix & | at (unsigned x, unsigned y) |
| Get mutable reference to a pixel. More... | |
| template<typename Pix = RGBAPix> | |
| void | write (const Pix &pix, unsigned x, unsigned y) |
| Write a pixel to an Image. More... | |
| template<typename Pix = RGBAPix> | |
| void | read (Pix &pix, unsigned x, unsigned y) const |
| Read a pixel from an Image. More... | |
| template<typename T > | |
| bool | resize (int dimX, int dimY) |
| Resize internal pixel buffer. Erases any existing data. More... | |
Static Public Member Functions | |
| static bool | saveImage (std::string fileName, unsigned char *pixs, int width, int height, bool flipVertically=false, int numComponents=3) |
| saveImage More... | |
Public Attributes | |
| unsigned int | mWidth = 0 |
| unsigned int | mHeight = 0 |
| std::vector< uint8_t > | mArray |
| std::string | mFilename = "" |
| int | mCompression = 50 |
| bool | mLoaded = false |
Interface for loading image files.
Loads image as 8-bit 4 channels RGBA. Supported formats: PNG, JPG, ... Implementation uses stb_image.h >> https://github.com/nothings/stb
Definition at line 62 of file al_Image.hpp.
|
inline |
Get mutable reference to a pixel.
Warning: doesn't check that Pix has matching type/component count. Warning: no bounds checking performed on x and y.
Definition at line 172 of file al_Image.hpp.
|
inline |
Get read-only reference to a pixel.
Warning: doesn't check that Pix has matching type/component count. Warning: no bounds checking performed on x and y.
Definition at line 162 of file al_Image.hpp.
|
inline |
Set compression flags for saving.
The flags consist of a bitwise-or of the level of compression in [0,100] and other flags which may be specific to the image format.
Definition at line 152 of file al_Image.hpp.
| bool al::Image::load | ( | const std::string & | filePath | ) |
|
inline |
Read a pixel from an Image.
Warning: doesn't check that Pix has matching type/component count Warning: no bounds checking performed on x and y
Definition at line 197 of file al_Image.hpp.
|
inline |
Resize internal pixel buffer. Erases any existing data.
| [in] | dimX | number of pixels in x direction |
| [in] | dimY | number of pixels in y direction |
| [in] | format | pixel color format |
Definition at line 212 of file al_Image.hpp.
| bool al::Image::save | ( | const std::string & | filePath | ) |
|
static |
saveImage
| fileName | |
| pixs | |
| width | |
| height | |
| flipVertically | |
| numComponents | use 3 for RGB and 4 for RGBA |
|
inline |
Get number of bytes per pixel.
Get pixel format Get width, in pixels
Definition at line 140 of file al_Image.hpp.
|
inline |
Write a pixel to an Image.
Warning: doesn't check that Pix has matching type/component count Warning: no bounds checking performed on x and y
Definition at line 183 of file al_Image.hpp.