|
Avara3D 0.2.0
C++ API reference
|
Owns decoded pixel data and its dimensions. More...
#include <a3d/Image.h>
Public Member Functions | |
| Image (const std::filesystem::path &path, bool flipVertical=true, bool flipHorizontal=false) | |
Loads and decodes an image from path. More... | |
| Image (const Buffer &buffer, bool flipVertical=true, bool flipHorizontal=false) | |
Decodes encoded image data from buffer. More... | |
| Image (std::unique_ptr< Buffer > buffer, unsigned width, unsigned height, unsigned bytesPerPixel, bool flipVertical=true, bool flipHorizontal=false) | |
| Takes ownership of an existing pixel buffer and its dimensions. More... | |
| unsigned | width () const |
| Returns the image width in pixels. More... | |
| unsigned | height () const |
| Returns the image height in pixels. More... | |
| unsigned | bytesPerPixel () const |
| Returns the number of bytes stored for each pixel. More... | |
| std::unique_ptr< Image > | inverted () const |
| Returns a new Image with its color bytes inverted. More... | |
| const Buffer & | buffer () const |
| Returns the Buffer containing the owned pixel data. More... | |
| bool | writePNG (const std::filesystem::path &path) const |
Writes the image pixels to a PNG file at path. More... | |
Owns decoded pixel data and its dimensions.
Images decoded from encoded file or Buffer data are converted to four-byte RGBA pixels. They are vertically flipped by default to match A3D texture coordinates. Copying an Image deep-copies its pixel buffer; moving transfers the owned storage.
|
explicit |
Loads and decodes an image from path.
| flipVertical | vertically flips the decoded pixels when true. |
| flipHorizontal | horizontally mirrors the decoded pixels when true. |
| std::runtime_error | if the file cannot be read or its image data cannot be decoded. |
|
explicit |
Decodes encoded image data from buffer.
| flipVertical | vertically flips the decoded pixels when true. |
| flipHorizontal | horizontally mirrors the decoded pixels when true. |
| std::runtime_error | if the image data cannot be decoded. |
| a3d::Image::Image | ( | std::unique_ptr< Buffer > | buffer, |
| unsigned | width, | ||
| unsigned | height, | ||
| unsigned | bytesPerPixel, | ||
| bool | flipVertical = true, |
||
| bool | flipHorizontal = false |
||
| ) |
Takes ownership of an existing pixel buffer and its dimensions.
The caller is responsible for supplying a buffer compatible with width, height, and bytesPerPixel.
| flipVertical | vertically flips the pixels when true. |
| flipHorizontal | horizontally mirrors the pixels when true. |
| std::runtime_error | if horizontal flipping is requested for data that is not four bytes per pixel. |
| unsigned a3d::Image::bytesPerPixel | ( | ) | const |
Returns the number of bytes stored for each pixel.
| unsigned a3d::Image::height | ( | ) | const |
Returns the image height in pixels.
| std::unique_ptr< Image > a3d::Image::inverted | ( | ) | const |
Returns a new Image with its color bytes inverted.
For four-byte pixels, RGB is inverted while alpha is preserved. For other pixel sizes, every stored byte is inverted.
| unsigned a3d::Image::width | ( | ) | const |
Returns the image width in pixels.
| bool a3d::Image::writePNG | ( | const std::filesystem::path & | path | ) | const |
Writes the image pixels to a PNG file at path.