10#define AVARA3D_IMAGE_H
39 explicit Image(
const std::filesystem::path& path,
40 bool flipVertical =
true,
41 bool flipHorizontal =
false);
50 explicit Image(
const Buffer&
buffer,
bool flipVertical =
true,
bool flipHorizontal =
false);
66 bool flipVertical =
true,
67 bool flipHorizontal =
false);
104 bool writePNG(
const std::filesystem::path& path)
const;
109 void loadBuffer(
const Buffer&
buffer,
bool flipVertical,
bool flipHorizontal);
111 void flipHorizontal();
117 unsigned _bytesPerPixel;
118 std::unique_ptr<Buffer> _buffer;
Container for a contiguous byte buffer.
Owns decoded pixel data and its dimensions.
unsigned width() const
Returns the image width in pixels.
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.
const Buffer & buffer() const
Returns the Buffer containing the owned pixel data.
std::unique_ptr< Image > inverted() const
Returns a new Image with its color bytes inverted.
Image(const Buffer &buffer, bool flipVertical=true, bool flipHorizontal=false)
Decodes encoded image data from buffer.
Image(const std::filesystem::path &path, bool flipVertical=true, bool flipHorizontal=false)
Loads and decodes an image from path.
unsigned height() const
Returns the image height in pixels.
unsigned bytesPerPixel() const
Returns the number of bytes stored for each pixel.
bool writePNG(const std::filesystem::path &path) const
Writes the image pixels to a PNG file at path.