|
Aegis2D
Modular C++26 2D game engine for networked games
|
RGBA image with 8 bits per channel, ready to become a texture. More...
#include <aegis2d/render/image.hpp>
Public Member Functions | |
| void | save_png (const std::filesystem::path &path) const |
| Writes the image as a PNG file, creating its folder. | |
| bool | empty () const noexcept |
| Tells whether the image has no pixel. | |
| Color | pixel (int x, int y) const |
| Color of one pixel. | |
Static Public Member Functions | |
| static Image | load (const std::filesystem::path &path) |
| Reads an image file. | |
| static Image | from_pixels (int width, int height, std::vector< std::uint8_t > pixels) |
| Wraps pixels generated in memory, such as marker_image(). | |
Public Attributes | |
| int | width = 0 |
| Width in pixels. | |
| int | height = 0 |
| Height in pixels. | |
| std::vector< std::uint8_t > | pixels |
width * height * 4 bytes. | |
RGBA image with 8 bits per channel, ready to become a texture.
Pixels are stored row by row from the top-left corner, 4 bytes each (red, green, blue, alpha), alpha not premultiplied.
|
noexcept |
Tells whether the image has no pixel.
true for a default-constructed image.
|
static |
Wraps pixels generated in memory, such as marker_image().
| width | Width in pixels, more than 0. |
| height | Height in pixels, more than 0. |
| pixels | width * height * 4 bytes of RGBA, row by row from the top. |
| std::invalid_argument | if a size is not positive or pixels has another length. |
|
static |
Reads an image file.
| path | PNG, JPEG, BMP, TGA, GIF (first frame), PSD, HDR or PNM file; any channel count is converted to RGBA. |
| ImageError | if the file cannot be read or decoded; the message starts with the path. |
| Color aegis2d::render::Image::pixel | ( | int | x, |
| int | y | ||
| ) | const |
Color of one pixel.
| x | Column, from 0 at the left. |
| y | Row, from 0 at the top. |
| std::out_of_range | if the pixel is outside the image. |
| void aegis2d::render::Image::save_png | ( | const std::filesystem::path & | path | ) | const |
Writes the image as a PNG file, creating its folder.
| path | File to write. |
| ImageError | if the image is empty or the file cannot be written; the message starts with the path. |
| int aegis2d::render::Image::height = 0 |
Height in pixels.
| std::vector<std::uint8_t> aegis2d::render::Image::pixels |
width * height * 4 bytes.
| int aegis2d::render::Image::width = 0 |
Width in pixels.