AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AImageView Class Reference

Non-owning read-only image representation of some format.

#include <AUI/Image/AImageView.h>

Public Types#

using Color = AColor
 

Public Member Functions#

 AImageView (AByteBufferView data, glm::uvec2 size, APixelFormat format)
 
 AImageView (const AImage &v)
 
AByteBufferView buffer () const noexcept
 
glm::uvec2 size () const noexcept
 
unsigned width () const noexcept
 
unsigned height () const noexcept
 
APixelFormat format () const noexcept
 
std::uint8_t bytesPerPixel () const noexcept
 
Color get (glm::uvec2 position) const noexcept
 Retrieves pixel color data.
 
template<AImageViewVisitor Visitor>
auto visit (Visitor &&visitor) const
 
AImage cropped (glm::uvec2 position, glm::uvec2 size) const
 Crops the image, creating new image with the same format.
 
Color averageColor () const noexcept
 
const char & rawDataAt (glm::uvec2 position) const noexcept
 Retrieves reference to raw data at specified position.
 
AImage mirroredVertically () const
 
AImage resizedLinearDownscale (glm::uvec2 newSize) const
 
AImage convert (APixelFormat format) const
 
const char * data () const noexcept
 Shortcut to buffer().data().
 

Protected Attributes#

AByteBufferView mData
 
glm::uvec2 mSize
 
APixelFormat mFormat = APixelFormat::UNKNOWN
 

Member Function Documentation#

◆ buffer()#

AByteBufferView AImageView::buffer ( ) const
inlinenodiscardnoexcept
Returns
Raw image pixel data.

◆ bytesPerPixel()#

std::uint8_t AImageView::bytesPerPixel ( ) const
inlinenodiscardnoexcept
Returns
Bytes per pixel.

◆ cropped()#

AImage AImageView::cropped ( glm::uvec2 position,
glm::uvec2 size ) const
nodiscard
Parameters
positionoffset
sizesize of new image

◆ format()#

APixelFormat AImageView::format ( ) const
inlinenodiscardnoexcept
Returns
Image pixel format.

◆ get()#

Color AImageView::get ( glm::uvec2 position) const
nodiscardnoexcept
Parameters
positionposition
Returns
color of specified pixel

This is a universal function that basically allows you to don't care about underlying image format representation. For performance critical code you may want to use visit method.

Note
Specifying position out of image range causes assertion fail in debug or undefined behaviour.

◆ height()#

unsigned AImageView::height ( ) const
inlinenodiscardnoexcept
Returns
Image height.

◆ rawDataAt()#

const char & AImageView::rawDataAt ( glm::uvec2 position) const
inlinenodiscardnoexcept
Parameters
positionposition
Returns
reference to raw pixel data
Note
Specifying position out of image range causes assertion fail in debug or undefined behaviour.

◆ size()#

glm::uvec2 AImageView::size ( ) const
inlinenodiscardnoexcept
Returns
Image size.

◆ width()#

unsigned AImageView::width ( ) const
inlinenodiscardnoexcept
Returns
Image width.