Class 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).
Parameters:
function getColor¶
Get the color of a pixel.
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).
Returns:
The underlying image data buffer
function getHeight¶
Get the image height.
Returns:
Image height in pixels
function getWidth¶
Get the image width.
Returns:
Image width in pixels
function setColor¶
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
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 pixelsheight
Image height in pixelsbuffer
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