Skip to content

Class endstone::Image

ClassList > endstone > Image

Represents an RGBA image. More...

  • #include <endstone/util/image.h>

Public Functions

Type Name
Image (const int width, const int height)
Create an empty image (all pixels transparent black).
Color getColor (const int x, const int y) const
Get the color of a pixel.
std::string_view getData () const
Gets the raw pixel buffer (RGBA, row-major).
int getHeight () const
Get the image height.
int getWidth () const
Get the image width.
void setColor (const int x, const int y, const Color color)
Set the color of a pixel.

Public Static Functions

Type Name
Result< Image > fromBuffer (const int width, const int height, std::string_view buffer)
Creates an image from the pixel data in a byte buffer.

Detailed Description

Each pixel is four bytes: R, G, B, A, in row-major order.

Public Functions Documentation

function Image [½]

Create an empty image (all pixels transparent black).

inline explicit endstone::Image::Image (
    const  int width,
    const  int height
) 

Parameters:

  • width Image width in pixels
  • height Image height in pixels

function getColor

Get the color of a pixel.

inline Color endstone::Image::getColor (
    const  int x,
    const  int y
) const

Parameters:

  • x X coordinate (0 ≤ x < width)
  • y Y coordinate (0 ≤ y < height)

Returns:

Color at (x, y)


function getData

Gets the raw pixel buffer (RGBA, row-major).

inline std::string_view endstone::Image::getData () const

Returns:

The underlying image data buffer


function getHeight

Get the image height.

inline int endstone::Image::getHeight () const

Returns:

Image height in pixels


function getWidth

Get the image width.

inline int endstone::Image::getWidth () const

Returns:

Image width in pixels


function setColor

Set the color of a pixel.

inline void endstone::Image::setColor (
    const  int x,
    const  int y,
    const  Color color
) 

Parameters:

  • x X coordinate (0 ≤ x < width)
  • y Y coordinate (0 ≤ y < height)
  • color New color for the pixel

Public Static Functions Documentation

function fromBuffer

Creates an image from the pixel data in a byte buffer.

static inline Result< Image > endstone::Image::fromBuffer (
    const  int width,
    const  int height,
    std::string_view buffer
) 

Parameters:

  • width Image width in pixels
  • height Image height in pixels
  • buffer A string_view over exactly width*height*4 bytes of RGBA data

Returns:

The image on success, or an error on failure.



The documentation for this class was generated from the following file include/endstone/util/image.h