JNGL
Easy to use cross-platform 2D game library
|
Containing the pixel data of an image file. More...
#include <jngl/ImageData.hpp>
Public Member Functions | |
virtual int | getWidth () const =0 |
Returns the width of the image in pixels. | |
virtual int | getHeight () const =0 |
Returns the height of the image in pixels. | |
virtual int | getImageWidth () const =0 |
If the image has been scaled by getScaleFactor() this will return the original image width. | |
virtual int | getImageHeight () const =0 |
If the image has been scaled by getScaleFactor() this will return the original image height. | |
virtual const uint8_t * | pixels () const =0 |
RGBA values ordered row-major. | |
Static Public Member Functions | |
static std::unique_ptr< ImageData > | load (const std::string &filename, double scaleHint=1.) |
Passing a filename will load the specified filename. | |
Containing the pixel data of an image file.
Definition at line 13 of file ImageData.hpp.
|
static |
Passing a filename will load the specified filename.
PNG and WebP files are supported.
scaleHint might be completely ignored, compare getImageWidth with getWidth after loading to check.
|
pure virtual |
RGBA values ordered row-major.
To access the x=5, y=7 pixel's green value: img->pixels()[5 * 4 + 7 * img->getWidth() * 4 + 1]
This function doesn't create the underlying data or loads the image (that has already happened in ImageData::load), so you may call this as often as you like.
Example: