AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
AeonGUI::RasterImage Class Reference

Decoded raster image. More...

#include <aeongui/RasterImage.hpp>

Public Types

enum class  EncodedFormat { Unknown , PNG , JPEG , PCX }
 Supported encoded image formats. More...
enum class  PixelFormat { Unknown , RGBA8 }
 Decoded pixel formats. More...

Public Member Functions

 RasterImage ()
 Default constructor. Creates an empty (unloaded) image.
bool LoadFromFile (const std::string &aPath)
 Load an image from a file.
bool LoadFromMemory (const void *aData, size_t aSize)
 Load an image from a memory buffer.
void Clear ()
 Release the decoded pixel data.
bool IsLoaded () const
 Check whether an image has been loaded.
EncodedFormat GetEncodedFormat () const
 Get the original encoded format of the loaded image.
PixelFormat GetPixelFormat () const
 Get the decoded pixel format.
uint32_t GetWidth () const
 Get the image width in pixels.
uint32_t GetHeight () const
 Get the image height in pixels.
size_t GetStride () const
 Get the stride (bytes per row) of the decoded image.
const uint8_t * GetPixels () const
 Get a pointer to the decoded pixel data.
const std::vector< uint8_t > & GetPixelData () const
 Get a reference to the decoded pixel data vector.

Detailed Description

Decoded raster image.

Loads PNG, JPEG, or PCX images from files or memory and provides access to the decoded RGBA pixel data.

Member Enumeration Documentation

◆ EncodedFormat

Supported encoded image formats.

Enumerator
Unknown 

Format not recognized.

PNG 

PNG format.

JPEG 

JPEG format.

PCX 

PCX format.

◆ PixelFormat

Decoded pixel formats.

Enumerator
Unknown 

No decoded data.

RGBA8 

8 bits per channel, RGBA.

Member Function Documentation

◆ GetEncodedFormat()

RasterImage::EncodedFormat AeonGUI::RasterImage::GetEncodedFormat ( ) const
nodiscard

Get the original encoded format of the loaded image.

Returns
The encoded format.

◆ GetHeight()

uint32_t AeonGUI::RasterImage::GetHeight ( ) const
nodiscard

Get the image height in pixels.

Returns
Height in pixels.

◆ GetPixelData()

const std::vector< uint8_t > & AeonGUI::RasterImage::GetPixelData ( ) const
nodiscard

Get a reference to the decoded pixel data vector.

Returns
Const reference to the internal pixel buffer.

◆ GetPixelFormat()

RasterImage::PixelFormat AeonGUI::RasterImage::GetPixelFormat ( ) const
nodiscard

Get the decoded pixel format.

Returns
The pixel format.

◆ GetPixels()

const uint8_t * AeonGUI::RasterImage::GetPixels ( ) const
nodiscard

Get a pointer to the decoded pixel data.

Returns
Pointer to RGBA8 pixel data, or nullptr if not loaded.

◆ GetStride()

size_t AeonGUI::RasterImage::GetStride ( ) const
nodiscard

Get the stride (bytes per row) of the decoded image.

Returns
Stride in bytes.

◆ GetWidth()

uint32_t AeonGUI::RasterImage::GetWidth ( ) const
nodiscard

Get the image width in pixels.

Returns
Width in pixels.

◆ IsLoaded()

bool AeonGUI::RasterImage::IsLoaded ( ) const
nodiscard

Check whether an image has been loaded.

Returns
true if pixel data is available.

◆ LoadFromFile()

bool AeonGUI::RasterImage::LoadFromFile ( const std::string & aPath)

Load an image from a file.

Parameters
aPathPath to the image file.
Returns
true if loading succeeded.

◆ LoadFromMemory()

bool AeonGUI::RasterImage::LoadFromMemory ( const void * aData,
size_t aSize )

Load an image from a memory buffer.

Parameters
aDataPointer to the encoded image data.
aSizeSize of the data in bytes.
Returns
true if loading succeeded.

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