API Documentation
Public Member Functions | List of all members
nkImages::ImageBase Class Referenceabstract

Base for all image data classes. More...

Inheritance diagram for nkImages::ImageBase:
nkImages::Image nkImages::ImageView

Public Member Functions

 ImageBase () noexcept
 
 ImageBase (unsigned int width, unsigned int height, unsigned int depth, PIXEL_FORMAT format, unsigned int pixelOrBlockByteSize=0, unsigned int rowByteSize=0, unsigned int sliceByteSize=0) noexcept
 
 ImageBase (unsigned int width, unsigned int height, unsigned int depth, unsigned int arraySize, unsigned int mips, PIXEL_FORMAT format, unsigned int pixelOrBlockByteSize=0) noexcept
 
 ImageBase (nkMemory::BufferCast< ImageDescriptor > &&images, PIXEL_FORMAT format, unsigned int pixelOrBlockByteSize, bool alphaPremultiplied=false, bool cubeMap=false) noexcept
 
 ImageBase (const ImageBase &other) noexcept
 
 ImageBase (ImageBase &&other) noexcept
 
virtual ~ImageBase ()
 
unsigned int getWidth (unsigned int mip=0u) const
 
unsigned int getHeight (unsigned int mip=0u) const
 
unsigned int getDepthOrArraySize (unsigned int mip=0u) const
 
unsigned int getMipCount () const
 
PIXEL_FORMAT getFormat () const
 
unsigned int getPixelByteSize () const
 
unsigned int getRowByteSize (unsigned int mip=0u) const
 
unsigned int getSliceByteSize (unsigned int mip=0u) const
 
bool getAlphaPremultiplied () const
 
bool getCubeMap () const
 
bool isArray () const
 
void setFormat (PIXEL_FORMAT value)
 
void setPixelOrBlockByteSize (unsigned int value)
 
void setAlphaPremultiplied (bool value)
 
void setCubeMap (bool value)
 
nkMaths::Vector getPixel (unsigned int x, unsigned int y, unsigned int z=0u, unsigned int mip=0u) const
 
void setPixel (nkMaths::Vector v, unsigned int x, unsigned int y, unsigned int z=0u, unsigned int mip=0u)
 
Image decompress (const AlignmentDescriptor &alignmentDescriptor=AlignmentDescriptor()) const
 
virtual unsigned char * getDataPtr () const =0
 
virtual unsigned long long getDataByteSize () const =0
 
virtual nkMemory::BufferView getDataBuffer () const =0
 
virtual bool isView () const =0
 
ImageBaseoperator= (const ImageBase &other) noexcept
 
ImageBaseoperator= (ImageBase &&other) noexcept
 

Detailed Description

Base for all image data classes.

An image holds informations such as the data of the image, its size, alignment in memory... It also offers utilities to access a particular pixel data.

This class family is also the basis for all exchanges in the component. Where data ownership is in play, Image is used. Where no data ownership is needed, ImageView is used.

Constructor & Destructor Documentation

◆ ImageBase() [1/6]

nkImages::ImageBase::ImageBase ( )
noexcept

Default constructor.

◆ ImageBase() [2/6]

nkImages::ImageBase::ImageBase ( unsigned int  width,
unsigned int  height,
unsigned int  depth,
PIXEL_FORMAT  format,
unsigned int  pixelOrBlockByteSize = 0,
unsigned int  rowByteSize = 0,
unsigned int  sliceByteSize = 0 
)
noexcept

2D image without mips constructor.

Parameters
widthThe width of the image, in pixels.
heightThe height of the image, in pixels.
depthThe depth of the image, in number of slices of width * height images.
formatThe pixel format of the image.
pixelOrBlockByteSizeThe size of a pixel or block, in bytes. Defaults to 0 to be automatically derived from the format.
rowByteSizeThe size of a row, in bytes. Defaults to 0 to be automatically derived from the pixel byte size and width.
sliceByteSizeThe size of a slice, in bytes. Defaults to 0 to be automatically derived from the row size size and height.

◆ ImageBase() [3/6]

nkImages::ImageBase::ImageBase ( unsigned int  width,
unsigned int  height,
unsigned int  depth,
unsigned int  arraySize,
unsigned int  mips,
PIXEL_FORMAT  format,
unsigned int  pixelOrBlockByteSize = 0 
)
noexcept

Tightly packed full constructor. Will derive all information for slices and mips based on width, height, depth and format given / pixelOrBlockSize given. Memory will be assumed as being tightly packed (no padding inside).

Parameters
widthThe width of the image, in pixels.
heightThe height of the image, in pixels.
depthThe depth of the image, in number of slices of width * height images.
arraySizeThe number of slice in the image array.
mipsThe number of mips for each image slice.
formatThe pixel format of the image.
pixelOrBlockByteSizeThe size of a pixel or block, in bytes. Defaults to 0 to be automatically derived from the format.

◆ ImageBase() [4/6]

nkImages::ImageBase::ImageBase ( nkMemory::BufferCast< ImageDescriptor > &&  images,
PIXEL_FORMAT  format,
unsigned int  pixelOrBlockByteSize,
bool  alphaPremultiplied = false,
bool  cubeMap = false 
)
noexcept

Full constructor.

Parameters
imagesThe sub-images constituting the full image. One entry corresponds to an entry within a 2D image array.
formatThe pixel format of the image.
pixelOrBlockByteSizeThe size of a pixel or block, in bytes.
alphaPremultipliedWhether the alpha is premultiplied (true) or not (false).
cubeMapWhether the image is a cube map (true) or not (false).

◆ ImageBase() [5/6]

nkImages::ImageBase::ImageBase ( const ImageBase other)
noexcept

Copy constructor.

Parameters
otherThe base to copy over.

◆ ImageBase() [6/6]

nkImages::ImageBase::ImageBase ( ImageBase &&  other)
noexcept

Move constructor.

Parameters
otherThe base to move over.

◆ ~ImageBase()

virtual nkImages::ImageBase::~ImageBase ( )
virtual

Destructor.

Member Function Documentation

◆ getWidth()

unsigned int nkImages::ImageBase::getWidth ( unsigned int  mip = 0u) const
Parameters
mipThe mip which dimension should be retrieved.
Returns
The width of given mip, in pixels.

◆ getHeight()

unsigned int nkImages::ImageBase::getHeight ( unsigned int  mip = 0u) const
Parameters
mipThe mip which dimension should be retrieved.
Returns
The height of given mip, in pixels.

◆ getDepthOrArraySize()

unsigned int nkImages::ImageBase::getDepthOrArraySize ( unsigned int  mip = 0u) const
Parameters
mipThe mip which dimension should be retrieved.
Returns
The depth of given mip, in pixels, if the image is 3D. The array size if the image is a 2D image array.
Remarks
An array can only contain 2D images.

◆ getMipCount()

unsigned int nkImages::ImageBase::getMipCount ( ) const
Returns
The number of mip levels the image has.

◆ getFormat()

PIXEL_FORMAT nkImages::ImageBase::getFormat ( ) const
Returns
The pixel format of the image.

◆ getPixelByteSize()

unsigned int nkImages::ImageBase::getPixelByteSize ( ) const
Returns
The size of a pixel, in bytes.

◆ getRowByteSize()

unsigned int nkImages::ImageBase::getRowByteSize ( unsigned int  mip = 0u) const
Parameters
mipThe mip which size should be retrieved.
Returns
The size of a mip row, in bytes.

◆ getSliceByteSize()

unsigned int nkImages::ImageBase::getSliceByteSize ( unsigned int  mip = 0u) const
Parameters
mipThe mip which size should be retrieved.
Returns
The size of a mip slice, in bytes.

◆ getAlphaPremultiplied()

bool nkImages::ImageBase::getAlphaPremultiplied ( ) const
Returns
Whether the image is alpha premultiplied (true) or not (false).

◆ getCubeMap()

bool nkImages::ImageBase::getCubeMap ( ) const
Returns
Whether the image is a cube map (true) or not (false).

◆ isArray()

bool nkImages::ImageBase::isArray ( ) const
Returns
Whether the image is an array (true) or not (false).
Remarks
Array images will have a z component corresponding to their index in the array, rather than their depth.

◆ setFormat()

void nkImages::ImageBase::setFormat ( PIXEL_FORMAT  value)

Sets the pixel format.

Parameters
valueThe pixel format image is using.

◆ setPixelOrBlockByteSize()

void nkImages::ImageBase::setPixelOrBlockByteSize ( unsigned int  value)

Sets the size of a pixel or block.

Parameters
valueThe size to assign, in bytes.

◆ setAlphaPremultiplied()

void nkImages::ImageBase::setAlphaPremultiplied ( bool  value)

Sets whether the image's colors are alpha premultiplied or not.

Parameters
valueThe value to assign, true (premultiplied) or false (not premultiplied).

◆ setCubeMap()

void nkImages::ImageBase::setCubeMap ( bool  value)

Sets whether the image is a cube map.

Parameters
valueThe value to assign, true (cube map) or false (not a cube map).

◆ getPixel()

nkMaths::Vector nkImages::ImageBase::getPixel ( unsigned int  x,
unsigned int  y,
unsigned int  z = 0u,
unsigned int  mip = 0u 
) const

Allows to retrieve a pixel at given coordinates. This function abstracts the memory access required to reach given pixel (alignment, sizes...).

Parameters
xThe x coordinate of the pixel.
yThe y coordinate of the pixel.
zThe z coordinate of the pixel, if the image has a depth. The array index, if the image is an array.
mipThe mip level to retrieve to pixel from.
Returns
The pixel, formatted as a vector to abstract different formats (chars, floats...) and channels given.
Remarks
If the image is from a supported compressed format, the pixel will get decompressed on-the-fly for access. The channel order respects the one from the image's format. For instance, RGB will get the red channel as x, while BGR will get its blue channel inside.

◆ setPixel()

void nkImages::ImageBase::setPixel ( nkMaths::Vector  v,
unsigned int  x,
unsigned int  y,
unsigned int  z = 0u,
unsigned int  mip = 0u 
)

Allows to set a pixel at given coordinates. This function abstracts the memory access required to reach given pixel (alignment, sizes...).

Parameters
vThe value to assign to the pixel, in the image's format.
xThe x coordinate of the pixel.
yThe y coordinate of the pixel.
zThe z coordinate of the pixel, if the image has a depth. The array index, if the image is an array.
mipThe mip level to alter to pixel from.
Remarks
This method does not support setting pixels for compressed formats, such as BC based formats or Y8U8Y8V8_422 and so on.

◆ decompress()

Image nkImages::ImageBase::decompress ( const AlignmentDescriptor alignmentDescriptor = AlignmentDescriptor()) const

Decompresses an image using a compressed format into a non-compressed format.

Parameters
alignmentDescriptorDescribes if any alignment constraint is required.
Returns
The corresponding decompressed image.
Remarks
Decompression supports all format for which a Compressor exists. See within the Data/Decompression/ folder.

◆ getDataPtr()

virtual unsigned char* nkImages::ImageBase::getDataPtr ( ) const
pure virtual
Returns
A pointer over the image data.

Implemented in nkImages::ImageView, and nkImages::Image.

◆ getDataByteSize()

virtual unsigned long long nkImages::ImageBase::getDataByteSize ( ) const
pure virtual
Returns
The total byte size of the image buffer.

Implemented in nkImages::ImageView, and nkImages::Image.

◆ getDataBuffer()

virtual nkMemory::BufferView nkImages::ImageBase::getDataBuffer ( ) const
pure virtual
Returns
A view over the raw image data.

Implemented in nkImages::ImageView, and nkImages::Image.

◆ isView()

virtual bool nkImages::ImageBase::isView ( ) const
pure virtual
Returns
Whether the image is a view over the data without ownership (true) or not (false).

Implemented in nkImages::ImageView, and nkImages::Image.

◆ operator=() [1/2]

ImageBase& nkImages::ImageBase::operator= ( const ImageBase other)
noexcept

Copy assignment operator.

Parameters
otherThe base to copy and assign.

◆ operator=() [2/2]

ImageBase& nkImages::ImageBase::operator= ( ImageBase &&  other)
noexcept

Move assignment operator.

Parameters
otherThe base to move and assign.

The documentation for this class was generated from the following file: