libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GuiImageData Class Reference

Decodes compressed image data (PNG) into a platform-native texture created from it. More...

#include <GuiImageData.h>

Public Member Functions

 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 Public Member Functions

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 ()
 

Protected Attributes

void * texture
 Attached platform-native texture.
 
int height
 Height of image.
 
int width
 Width of image.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ GuiImageData() [1/4]

GuiImageData::GuiImageData ( )

Constructor.

Definition at line 37 of file GuiImageData.cpp.

◆ 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
iSource image data (PNG)
wMax image width (0 = not set)
hMax 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
iSource image data (PNG)
dstDestination texture buffer, owned by the caller
maxwMax image width (0 = not set)
maxhMax 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
tPlatform-native texture
wImage width
hImage height
takeOwnershipIf true (default), this object will destroy t when it is destroyed or replaced.

Definition at line 74 of file GuiImageData.cpp.

◆ ~GuiImageData()

GuiImageData::~GuiImageData ( )

Destructor.

Definition at line 84 of file GuiImageData.cpp.

Member Function Documentation

◆ 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
pngDataSource image data (PNG)
maxwMax image width (0 = not set)
maxhMax 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
bufferScratch buffer, owned and sized by the caller
sizeSize of buffer, in bytes
Examples
demo.cpp.

Definition at line 26 of file GuiImageData.cpp.

Member Data Documentation

◆ height

int GuiImageData::height
protected

Height of image.

Definition at line 73 of file GuiImageData.h.

◆ texture

void* GuiImageData::texture
protected

Attached platform-native texture.

Definition at line 72 of file GuiImageData.h.

◆ width

int GuiImageData::width
protected

Width of image.

Definition at line 74 of file GuiImageData.h.


The documentation for this class was generated from the following files: