11#include "../drivers/Mutex.h"
35 GuiImageData(
const uint8_t * i, uint8_t * dst,
int maxw=0,
int maxh=0);
44 GuiImageData(
void * t,
int w,
int h,
bool takeOwnership =
true);
54 bool reload(
const uint8_t * pngData,
int maxw = 0,
int maxh = 0);
79 std::unique_ptr<uint8_t,
decltype(&free)>
rgba{
nullptr, free};
84 bool valid()
const {
return rgba !=
nullptr; }
92 static DecodedImage
decodeToRgba(
const uint8_t * pngData,
int maxw = 0,
int maxh = 0);
114 bool loadClipped(
const uint8_t * pngData,
int boxW,
int boxH,
float radius,
float inset = 0.0f,
float offsetX = 0.0f,
float offsetY = 0.0f);
129 bool decodeImage(
const uint8_t * pngData,
int *
width,
int *
height,
int maxw,
int maxh);
static DecodedImage decodeToRgba(const uint8_t *pngData, int maxw=0, int maxh=0)
Decodes a PNG buffer into plain RGBA8 pixels, resizing to fit maxw/maxh the same way the decoding con...
~GuiImageData()
Destructor.
void clear()
Releases any owned texture and resets this object to the same (empty) state as a default-constructed ...
bool uploadDecoded(DecodedImage &&decoded)
Uploads a DecodedImage produced by decodeToRgba() into this object's own texture, reusing the existin...
GuiImageData()
Constructor.
void * texture
Attached platform-native texture.
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 the pla...
static void setDecodeScratch(void *buffer, unsigned int size)
Sets the scratch buffer that every decode (the PNG-decoding constructors, reload(),...
bool loadClipped(const uint8_t *pngData, int boxW, int boxH, float radius, float inset=0.0f, float offsetX=0.0f, float offsetY=0.0f)
Decodes PNG data and fits it into a box of a given size, then masks it with a rounded rectangle: the ...
void * getTexture()
Gets the attached platform-native texture.
int getWidth()
Gets the image width.
int height
Height of image.
int getHeight()
Gets the image height.
static Mutex & scratchLock()
A simple mutual-exclusion lock.
CPU-only decode result from decodeToRgba(): raw RGBA8 pixel data that has NOT been uploaded to a plat...
std::unique_ptr< uint8_t, decltype(&free)> rgba
row-major RGBA8, or null if decode failed
bool assetScaled
False when maxw/maxh constrained this decode to a caller-specified pixel box.