Skip to content

Class endstone::Image

ClassList > endstone > Image

Represents an RGBA image. More...

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

Public Types

Type Name
enum Type

Public Functions

Type Name
Image (const Type type, 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 (row-major, H x W x D).
int getDepth () const
Get the image depth.
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 (Type type, 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 Types Documentation

enum Type

enum endstone::Image::Type {
    Invalid = 0,
    Grayscale = 1,
    RGB = 3,
    RGBA = 4
};

Public Functions Documentation

function Image [½]

Create an empty image (all pixels transparent black).

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

Parameters:

  • type Image type
  • 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 (row-major, H x W x D).

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

Returns:

The underlying image data buffer


function getDepth

Get the image depth.

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

Returns:

Image depth


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 (
    Type type,
    const int width,
    const int height,
    std::string_view buffer
) 

Parameters:

  • type Image type
  • width Image width in pixels
  • height Image height in pixels
  • buffer

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