Read-only non-owning view over a 2D image.
More...
#include <donut/graphics/Image.hpp>
|
constexpr | ImageView () noexcept=default |
| Construct a view that does not reference an image. More...
|
|
constexpr | ImageView (std::size_t width, std::size_t height, PixelFormat pixelFormat, PixelComponentType pixelComponentType, const void *pixels) noexcept |
| Construct an image view over arbitrary 2D pixel data. More...
|
|
| operator bool () const noexcept |
| Check if this view references an image. More...
|
|
constexpr std::size_t | getWidth () const noexcept |
| Get the width of the image referenced by this view. More...
|
|
constexpr std::size_t | getHeight () const noexcept |
| Get the height of the image referenced by this view. More...
|
|
constexpr PixelFormat | getPixelFormat () const noexcept |
| Get the pixel format of the image referenced by this view. More...
|
|
constexpr PixelComponentType | getPixelComponentType () const noexcept |
| Get the pixel component type of the image referenced by this view. More...
|
|
constexpr const void * | getPixels () const noexcept |
| Get the pixel data referenced by this view. More...
|
|
constexpr std::size_t | getChannelCount () const noexcept |
| Get the number of component channels in the pixel format of the image referenced by this view. More...
|
|
constexpr std::size_t | getPixelComponentSize () const noexcept |
| Get the size in bytes of a single component of a pixel in the image referenced by this view. More...
|
|
constexpr std::size_t | getPixelStride () const noexcept |
| Get the stride in bytes of the pixels in the image referenced by this view. More...
|
|
constexpr std::size_t | getSizeInBytes () const noexcept |
| Get the size in bytes of the image referenced by this view. More...
|
|
Read-only non-owning view over a 2D image.
- See also
- Image
◆ ImageView() [1/2]
constexpr donut::graphics::ImageView::ImageView |
( |
| ) |
|
|
constexprdefaultnoexcept |
Construct a view that does not reference an image.
◆ ImageView() [2/2]
constexpr donut::graphics::ImageView::ImageView |
( |
std::size_t |
width, |
|
|
std::size_t |
height, |
|
|
PixelFormat |
pixelFormat, |
|
|
PixelComponentType |
pixelComponentType, |
|
|
const void * |
pixels |
|
) |
| |
|
inlineconstexprnoexcept |
Construct an image view over arbitrary 2D pixel data.
- Parameters
-
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, or nullptr to create a view that doesn't reference an image. |
◆ operator bool()
donut::graphics::ImageView::operator bool |
( |
| ) |
const |
|
inlineexplicitnoexcept |
Check if this view references an image.
- Returns
- true if the view references an image, false otherwise.
◆ getWidth()
constexpr std::size_t donut::graphics::ImageView::getWidth |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Get the width of the image referenced by this view.
- Returns
- the width of the image, in pixels, or 0 if the view does not reference an image.
- See also
- getHeight()
-
getSizeInBytes()
◆ getHeight()
constexpr std::size_t donut::graphics::ImageView::getHeight |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Get the height of the image referenced by this view.
- Returns
- the height of the image, in pixels, or 0 if the view does not reference an image.
- See also
- getWidth()
-
getSizeInBytes()
◆ getPixelFormat()
constexpr PixelFormat donut::graphics::ImageView::getPixelFormat |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Get the pixel format of the image referenced by this view.
- Returns
- the pixel format, or PixelFormat::R if the view does not reference an image.
- See also
- getChannelCount()
◆ getPixelComponentType()
◆ getPixels()
constexpr const void* donut::graphics::ImageView::getPixels |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Get the pixel data referenced by this view.
The pixel data is tightly packed and fully contiguous, so the total size of the image in bytes is:
width * height * pixelSize
```.
The size of a single pixel, `pixelSize`, is
pixelFormatChannelCount * pixelComponentTypeSize `` where
pixelFormatChannelCountis the number of component channels in the pixel format, and
pixelComponentTypeSize` is the size in bytes of a single pixel component.
The pixels are stored in row-major order, starting at the bottom left of the image (unless the image is flipped).
- Returns
- a read-only non-owning pointer to the pixel data, or nullptr if the view does not reference an image.
- See also
- getWidth()
-
getHeight()
-
getPixelFormat()
-
getPixelComponentType()
◆ getChannelCount()
constexpr std::size_t donut::graphics::ImageView::getChannelCount |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Get the number of component channels in the pixel format of the image referenced by this view.
- Returns
- the number of channels, or 0 if the view does not reference an image.
- See also
- getPixelFormat()
-
getPixelStride()
◆ getPixelComponentSize()
constexpr std::size_t donut::graphics::ImageView::getPixelComponentSize |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Get the size in bytes of a single component of a pixel in the image referenced by this view.
- Returns
- the size of the pixel component type, or 0 if the view does not reference an image.
- See also
- getPixelComponentType()
-
getPixelStride()
◆ getPixelStride()
constexpr std::size_t donut::graphics::ImageView::getPixelStride |
( |
| ) |
const |
|
inlineconstexprnoexcept |
◆ getSizeInBytes()
constexpr std::size_t donut::graphics::ImageView::getSizeInBytes |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Get the size in bytes of the image referenced by this view.
- Returns
- the total size of the image, or 0 if the view does not reference an image.
- See also
- getWidth()
-
getHeight()
-
getPixelStride()
The documentation for this class was generated from the following file: