libdonut 2.3.6
Application framework for cross-platform game development in C++20
|
Container for a 2D image. More...
#include <donut/graphics/Image.hpp>
Public Member Functions | |
Image () noexcept=default | |
Construct an empty image without a value. | |
Image (std::size_t width, std::size_t height, PixelFormat pixelFormat, PixelComponentType pixelComponentType, const void *pixels) | |
Construct an image copied from a contiguous 2D range of pixels. | |
Image (const ImageView &image) | |
Construct an image copied from an image view. | |
Image (const Filesystem &filesystem, const char *filepath, const ImageOptions &options={}) | |
Load an image from a virtual file. | |
operator bool () const noexcept | |
Check if this image has a value. | |
operator ImageView () const noexcept | |
Get a view over this image. | |
void | reset () noexcept |
Remove the value from this image and reset it to an empty image. | |
std::size_t | getWidth () const noexcept |
Get the width of the image. | |
std::size_t | getHeight () const noexcept |
Get the height of the image. | |
PixelFormat | getPixelFormat () const noexcept |
Get the pixel format of the image. | |
PixelComponentType | getPixelComponentType () const noexcept |
Get the pixel component type of the image. | |
void * | getPixels () noexcept |
Get the pixel data of this image. | |
const void * | getPixels () const noexcept |
Get the pixel data of this image. | |
std::size_t | getChannelCount () const noexcept |
Get the number of component channels in the pixel format of this image. | |
std::size_t | getPixelComponentSize () const noexcept |
Get the size in bytes of a single component of a pixel in this image. | |
std::size_t | getPixelStride () const noexcept |
Get the stride in bytes of the pixels in this image. | |
std::size_t | getSizeInBytes () const noexcept |
Get the size in bytes of this image. | |
Static Public Member Functions | |
static void | savePNG (const ImageView &image, Filesystem &filesystem, const char *filepath, const ImageSavePNGOptions &options={}) |
Save an 8-bit-per-channel image to a PNG file. | |
static void | saveBMP (const ImageView &image, Filesystem &filesystem, const char *filepath, const ImageSaveBMPOptions &options={}) |
Save an 8-bit-per-channel image to a Windows Bitmap file. | |
static void | saveTGA (const ImageView &image, Filesystem &filesystem, const char *filepath, const ImageSaveTGAOptions &options={}) |
Save an 8-bit-per-channel image to a Truevision TARGA file. | |
static void | saveJPG (const ImageView &image, Filesystem &filesystem, const char *filepath, const ImageSaveJPGOptions &options={}) |
Save an 8-bit-per-channel image to a JPEG file. | |
static void | saveHDR (const ImageView &image, Filesystem &filesystem, const char *filepath, const ImageSaveHDROptions &options={}) |
Save a floating-point 32-bit-per-channel image to a Radiance HDR RGBE file. | |
static void | save (const ImageView &image, Filesystem &filesystem, const char *filepath, const ImageSaveOptions &options={}) |
Save an image to a file. | |
|
defaultnoexcept |
Construct an empty image without a value.
donut::graphics::Image::Image | ( | std::size_t | width, |
std::size_t | height, | ||
PixelFormat | pixelFormat, | ||
PixelComponentType | pixelComponentType, | ||
const void * | pixels | ||
) |
Construct an image copied from a contiguous 2D range of pixels.
width | width of the image, in pixels. Must be 0 if pixels is nullptr. |
height | height of the image, in pixels. Must be 0 if pixels is nullptr. |
pixelFormat | pixel format of the image. Must be PixelFormat::R if pixels is nullptr. |
pixelComponentType | pixel component data type of the image. Must be PixelComponentType::U8 if pixels is nullptr. |
pixels | read-only non-owning pointer to the pixel data to copy, or nullptr to create an empty image without a value. |
std::bad_alloc | on allocation failure. |
|
explicit |
Construct an image copied from an image view.
image | read-only view over the image to copy. |
std::bad_alloc | on allocation failure. |
|
explicit |
Load an image from a virtual file.
The supported file formats are:
filesystem | virtual filesystem to load the file from. |
filepath | virtual filepath of the image file to load. |
options | image options, see ImageOptions. |
File::Error | on failure to open the file. |
graphics::Error | on failure to load an image from the file. |
std::bad_alloc | on allocation failure. |
|
static |
Save an 8-bit-per-channel image to a PNG file.
image | view over the image to save. |
filesystem | virtual filesystem to save the file to. |
filepath | virtual filepath at which to save the image. |
options | saving options, see ImageSavePNGOptions. |
File::Error | on failure to create the file. |
graphics::Error | on failure to write the image to the file. |
std::bad_alloc | on allocation failure. |
|
static |
Save an 8-bit-per-channel image to a Windows Bitmap file.
image | view over the image to save. |
filesystem | virtual filesystem to save the file to. |
filepath | virtual filepath at which to save the image. |
options | saving options, see ImageSaveBMPOptions. |
File::Error | on failure to create the file. |
graphics::Error | on failure to write the image to the file. |
std::bad_alloc | on allocation failure. |
|
static |
Save an 8-bit-per-channel image to a Truevision TARGA file.
image | view over the image to save. |
filesystem | virtual filesystem to save the file to. |
filepath | virtual filepath at which to save the image. |
options | saving options, see ImageSaveTGAOptions. |
File::Error | on failure to create the file. |
graphics::Error | on failure to write the image to the file. |
std::bad_alloc | on allocation failure. |
|
static |
Save an 8-bit-per-channel image to a JPEG file.
image | view over the image to save. |
filesystem | virtual filesystem to save the file to. |
filepath | virtual filepath at which to save the image. |
options | saving options, see ImageSaveJPGOptions. |
File::Error | on failure to create the file. |
graphics::Error | on failure to write the image to the file. |
std::bad_alloc | on allocation failure. |
|
static |
Save a floating-point 32-bit-per-channel image to a Radiance HDR RGBE file.
image | view over the image to save. |
filesystem | virtual filesystem to save the file to. |
filepath | virtual filepath at which to save the image. |
options | saving options, see ImageSaveHDROptions. |
File::Error | on failure to create the file. |
graphics::Error | on failure to write the image to the file. |
std::bad_alloc | on allocation failure. |
|
static |
Save an image to a file.
image | view over the image to save. |
filesystem | virtual filesystem to save the file to. |
filepath | virtual filepath at which to save the image. |
options | saving options, see ImageSaveOptions. |
File::Error | on failure to create the file. |
graphics::Error | on failure to write the image to the file. |
std::bad_alloc | on allocation failure. |
|
inlineexplicitnoexcept |
Check if this image has a value.
|
inlinenoexcept |
Get a view over this image.
|
inlinenoexcept |
Remove the value from this image and reset it to an empty image.
|
inlinenoexcept |
Get the width of the image.
|
inlinenoexcept |
Get the height of the image.
|
inlinenoexcept |
Get the pixel format of the image.
|
inlinenoexcept |
Get the pixel component type of the image.
|
inlinenoexcept |
Get the pixel data of this image.
The pixel data is tightly packed and fully contiguous, and the pixels are stored in row-major order, starting at the bottom left of the image (unless the image is flipped).
|
inlinenoexcept |
Get the pixel data of this image.
The pixel data is tightly packed and fully contiguous, and the pixels are stored in row-major order, starting at the bottom left of the image (unless the image is flipped).
|
inlinenoexcept |
Get the number of component channels in the pixel format of this image.
|
inlinenoexcept |
Get the size in bytes of a single component of a pixel in this image.
|
inlinenoexcept |
Get the stride in bytes of the pixels in this image.
|
inlinenoexcept |
Get the size in bytes of this image.