endstone::Image
Represents an RGBA image.
Types:
| Name | Description |
|---|---|
Type |
Functions:
| Name | Description |
|---|---|
Image | Create an empty image (all pixels transparent black). |
getColor | Get the color of a pixel. |
getData | Gets the raw pixel buffer (row-major, H x W x D). |
getDepth | Get the image depth. |
getHeight | Get the image height. |
getWidth | Get the image width. |
setColor | Set the color of a pixel. |
Functions:
| Name | Description |
|---|---|
fromArray | Creates an image from the pixel data in a byte array. |
fromBuffer | Creates an image from the pixel data in a byte buffer. |
Type
enum Type { Invalid = 0, Grayscale = 1, RGB = 3, RGBA = 4 }; Image
Image(const Type type, const int width, const int height)Create an empty image (all pixels transparent black).
Parameters:
getColor
Color getColor(const int x, const int y) constGet the color of a pixel.
Parameters:
xX coordinate (0 ≤ x < width)yY coordinate (0 ≤ y < height)
Returns:
Color at (x, y)
getData
std::string_view getData() constGets the raw pixel buffer (row-major, H x W x D).
Returns:
The underlying image data buffer
getDepth
int getDepth() constGet the image depth.
Returns:
Image depth
getHeight
int getHeight() constGet the image height.
Returns:
Image height in pixels
getWidth
int getWidth() constGet the image width.
Returns:
Image width in pixels
setColor
void setColor(const int x, const int y, const Color color)Set the color of a pixel.
Parameters:
xX coordinate (0 ≤ x < width)yY coordinate (0 ≤ y < height)colorNew color for the pixel
fromArray
static Result<Image> fromArray(Type type, const int width, const int height,
const std::vector<unsigned char> &array)Creates an image from the pixel data in a byte array.
Parameters:
Returns:
The image on success, or an error on failure.
fromBuffer
static 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.
Parameters:
Returns:
The image on success, or an error on failure.
Last updated on