Decodes compressed image data (PNG) into a platform-native texture created from it.
More...
#include <GuiImageData.h>
|
| | GuiImageData () |
| | Constructor.
|
| |
| | GuiImageData (const uint8_t *i, int w=0, int h=0) |
| | Constructor Converts the PNG format image data to a platform-native texture, allocated and owned by this object.
|
| |
| | GuiImageData (const uint8_t *i, uint8_t *dst, int maxw=0, int maxh=0) |
| | Constructor Converts the PNG format image data to a platform-native texture, decoded directly into a caller-supplied buffer.
|
| |
| | GuiImageData (void *t, int w, int h, bool takeOwnership=true) |
| | Constructor Populates an image directly with an already-created platform-native texture.
|
| |
| | ~GuiImageData () |
| | Destructor.
|
| |
| bool | reload (const uint8_t *pngData, int maxw=0, int maxh=0) |
| | Decodes new PNG data into this object's own texture, reusing the existing allocation whenever it's already large enough for the new image instead of freeing and reallocating.
|
| |
| void * | getTexture () |
| | Gets the attached platform-native texture.
|
| |
| int | getWidth () |
| | Gets the image width.
|
| |
| int | getHeight () |
| | Gets the image height.
|
| |
|
| static void | setDecodeScratch (void *buffer, unsigned int size) |
| | Sets the scratch buffer that every decode (the PNG-decoding constructors, and reload()) will stage its raw, uncompressed pixel rows into while it runs.
|
| |
| static Mutex & | scratchLock () |
| |
|
| void * | texture |
| | Attached platform-native texture.
|
| |
| int | height |
| | Height of image.
|
| |
| int | width |
| | Width of image.
|
| |
Decodes compressed image data (PNG) into a platform-native texture created from it.
Currently designed for use only with PNG files.
Definition at line 13 of file GuiImageData.h.
◆ GuiImageData() [1/4]
| GuiImageData::GuiImageData |
( |
| ) |
|
◆ GuiImageData() [2/4]
| GuiImageData::GuiImageData |
( |
const uint8_t * | i, |
|
|
int | w = 0, |
|
|
int | h = 0 ) |
Constructor Converts the PNG format image data to a platform-native texture, allocated and owned by this object.
- Parameters
-
| i | Source image data (PNG) |
| w | Max image width (0 = not set) |
| h | Max image height (0 = not set) |
Definition at line 47 of file GuiImageData.cpp.
◆ GuiImageData() [3/4]
| GuiImageData::GuiImageData |
( |
const uint8_t * | i, |
|
|
uint8_t * | dst, |
|
|
int | maxw = 0, |
|
|
int | maxh = 0 ) |
Constructor Converts the PNG format image data to a platform-native texture, decoded directly into a caller-supplied buffer.
- Parameters
-
| i | Source image data (PNG) |
| dst | Destination texture buffer, owned by the caller |
| maxw | Max image width (0 = not set) |
| maxh | Max image height (0 = not set) |
Definition at line 60 of file GuiImageData.cpp.
◆ GuiImageData() [4/4]
| GuiImageData::GuiImageData |
( |
void * | t, |
|
|
int | w, |
|
|
int | h, |
|
|
bool | takeOwnership = true ) |
Constructor Populates an image directly with an already-created platform-native texture.
- Parameters
-
| t | Platform-native texture |
| w | Image width |
| h | Image height |
| takeOwnership | If true (default), this object will destroy t when it is destroyed or replaced. |
Definition at line 74 of file GuiImageData.cpp.
◆ ~GuiImageData()
| GuiImageData::~GuiImageData |
( |
| ) |
|
◆ getHeight()
| int GuiImageData::getHeight |
( |
| ) |
|
|
inline |
Gets the image height.
- Returns
- image height
Definition at line 60 of file GuiImageData.h.
◆ getTexture()
| void * GuiImageData::getTexture |
( |
| ) |
|
|
inline |
Gets the attached platform-native texture.
- Returns
- opaque texture handle
Definition at line 54 of file GuiImageData.h.
◆ getWidth()
| int GuiImageData::getWidth |
( |
| ) |
|
|
inline |
Gets the image width.
- Returns
- image width
Definition at line 57 of file GuiImageData.h.
◆ reload()
| bool GuiImageData::reload |
( |
const uint8_t * | pngData, |
|
|
int | maxw = 0, |
|
|
int | maxh = 0 ) |
Decodes new PNG data into this object's own texture, reusing the existing allocation whenever it's already large enough for the new image instead of freeing and reallocating.
- Parameters
-
| pngData | Source image data (PNG) |
| maxw | Max image width (0 = not set) |
| maxh | Max image height (0 = not set) |
- Returns
- true on success
Definition at line 110 of file GuiImageData.cpp.
◆ scratchLock()
| Mutex & GuiImageData::scratchLock |
( |
| ) |
|
|
static |
- Returns
- the mutex guarding the shared decode scratch buffer set by setDecodeScratch() - callers decoding from more than one thread must hold this for the duration of a decode.
Definition at line 32 of file GuiImageData.cpp.
◆ setDecodeScratch()
| void GuiImageData::setDecodeScratch |
( |
void * | buffer, |
|
|
unsigned int | size ) |
|
static |
Sets the scratch buffer that every decode (the PNG-decoding constructors, and reload()) will stage its raw, uncompressed pixel rows into while it runs.
- Parameters
-
| buffer | Scratch buffer, owned and sized by the caller |
| size | Size of buffer, in bytes |
- Examples
- demo.cpp.
Definition at line 26 of file GuiImageData.cpp.
◆ height
◆ texture
| void* GuiImageData::texture |
|
protected |
◆ width
The documentation for this class was generated from the following files: