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) const
Get the color of a pixel.
Parameters:
x
X coordinate (0 ≤ x < width)y
Y coordinate (0 ≤ y < height)
Returns:
Color at (x, y)
getData
std::string_view getData() const
Gets the raw pixel buffer (row-major, H x W x D).
Returns:
The underlying image data buffer
getDepth
int getDepth() const
Get the image depth.
Returns:
Image depth
getHeight
int getHeight() const
Get the image height.
Returns:
Image height in pixels
getWidth
int getWidth() const
Get 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:
x
X coordinate (0 ≤ x < width)y
Y coordinate (0 ≤ y < height)color
New 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