ezEngine  Milestone 9
ezImage Class Reference

A class containing image data and associated meta data. More...

#include <Image.h>

Inheritance diagram for ezImage:

Public Member Functions

 EZ_DECLARE_MEM_RELOCATABLE_TYPE ()
 
 ezImage ()
 Constructs an empty image.
 
 ezImage (ezImage &&other)
 Move constructor.
 
void operator= (ezImage &&rhs)
 
void Clear ()
 Constructs an empty image. If the image is attached to an external storage, the attachment is discarded.
 
void ResetAndAlloc (const ezImageHeader &header)
 Constructs an image with the given header and ensures sufficient storage is allocated. More...
 
void ResetAndUseExternalStorage (const ezImageHeader &header, ezArrayPtr< void > externalData)
 Constructs an image with the given header and attaches to the user-supplied external storage. More...
 
void ResetAndMove (ezImage &&other)
 Moves the given data into this object. More...
 
void ResetAndCopy (const ezImageView &other)
 Constructs from an image view. Copies the image data to internal storage. More...
 
ezResult LoadFrom (const char *szFileName, ezLogInterface *pLog=ezLog::GetThreadLocalLogSystem())
 Convenience function to load the image from the given file.
 
ezResult Convert (ezImageFormat::Enum targetFormat)
 Convenience function to convert the image to the given format.
 
template<typename T >
ezArrayPtr< T > GetArrayPtr ()
 Returns a view to the entire data contained in this image.
 
ezImage GetSubImageView (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0)
 Returns a view to the given sub-image.
 
ezImage GetSliceView (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 z=0)
 Returns a view to z slice of the image.
 
ezImage GetRowView (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 y=0, ezUInt32 z=0)
 Returns a view to a row of pixels resp. blocks.
 
template<typename T >
T * GetPixelPointer (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 x=0, ezUInt32 y=0, ezUInt32 z=0)
 Returns a pointer to a given pixel or block contained in a sub-image.
 
template<typename T >
ezArrayPtr< const T > GetArrayPtr () const
 Returns a view to the entire data contained in this image.
 
ezImageView GetSubImageView (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0) const
 Returns a view to the given sub-image.
 
ezImageView GetSliceView (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 z=0) const
 Returns a view to z slice of the image.
 
ezImageView GetRowView (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 y=0, ezUInt32 z=0) const
 Returns a view to a row of pixels resp. blocks.
 
template<typename T >
const T * GetPixelPointer (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 x=0, ezUInt32 y=0, ezUInt32 z=0) const
 Returns a pointer to a given pixel or block contained in a sub-image.
 
- Public Member Functions inherited from ezImageView
 ezImageView ()
 Constructs an empty image view.
 
 ezImageView (const ezImageHeader &header, ezArrayPtr< const void > imageData)
 Constructs an image view with the given header and image data.
 
void Clear ()
 Constructs an empty image view.
 
bool IsValid () const
 Returns false if the image view does not reference any data yet.
 
void ResetAndViewExternalStorage (const ezImageHeader &header, ezArrayPtr< const void > imageData)
 Constructs an image view with the given header and image data.
 
ezResult SaveTo (const char *szFileName, ezLogInterface *pLog=ezLog::GetThreadLocalLogSystem()) const
 Convenience function to save the image to the given file.
 
const ezImageHeaderGetHeader () const
 Returns the header this image was constructed from.
 
template<typename T >
ezArrayPtr< const T > GetArrayPtr () const
 Returns a view to the entire data contained in this image.
 
ezImageView GetSubImageView (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0) const
 Returns a view to the given sub-image.
 
ezImageView GetSliceView (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 z=0) const
 Returns a view to z slice of the image.
 
ezImageView GetRowView (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 y=0, ezUInt32 z=0) const
 Returns a view to a row of pixels resp. blocks.
 
template<typename T >
const T * GetPixelPointer (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 x=0, ezUInt32 y=0, ezUInt32 z=0) const
 Returns a pointer to a given pixel or block contained in a sub-image.
 
void ReinterpretAs (ezImageFormat::Enum format)
 Reinterprets the image with a given format; the format must have the same size in bits per pixel as the current one.
 
ezUInt32 GetDepth (ezUInt32 uiMipLevel=0) const
 Returns the image depth for a given mip level, clamped to 1.
 
ezUInt32 GetHeight (ezUInt32 uiMipLevel=0) const
 Returns the image height for a given mip level, clamped to 1.
 
ezUInt32 GetWidth (ezUInt32 uiMipLevel=0) const
 Returns the image width for a given mip level, clamped to 1.
 
ezUInt32 GetNumArrayIndices () const
 Returns the number of array indices.
 
ezUInt32 GetNumFaces () const
 Returns the number of cubemap faces, or 1 for a non-cubemap.
 
ezUInt32 GetNumMipLevels () const
 Returns the number of mip levels, including the full-size image.
 
ezImageFormat::Enum GetImageFormat () const
 Returns the image format.
 
ezUInt32 GetNumBlocksX (ezUInt32 uiMipLevel=0) const
 Returns the number of blocks contained in a given mip level in the horizontal direction.
 
ezUInt32 GetNumBlocksY (ezUInt32 uiMipLevel=0) const
 Returns the number of blocks contained in a given mip level in the horizontal direction.
 
ezUInt32 GetNumBlocksZ (ezUInt32 uiMipLevel=0) const
 Returns the number of blocks contained in a given mip level in the depth direction.
 
ezUInt32 GetDepthPitch (ezUInt32 uiMipLevel=0) const
 Returns the offset in bytes between two subsequent depth slices of the given mip level.
 
ezUInt32 GetRowPitch (ezUInt32 uiMipLevel=0) const
 Returns the offset in bytes between two subsequent rows of the given mip level.
 

Additional Inherited Members

- Protected Member Functions inherited from ezImageView
ezUInt32 ComputeLayout ()
 
void ValidateSubImageIndices (ezUInt32 uiMipLevel, ezUInt32 uiFace, ezUInt32 uiArrayIndex) const
 
template<typename T >
void ValidateDataTypeAccessor () const
 
const ezUInt32 & GetSubImageOffset (ezUInt32 uiMipLevel, ezUInt32 uiFace, ezUInt32 uiArrayIndex) const
 
- Protected Member Functions inherited from ezImageHeader
 ezImageHeader ()
 Constructs an image using an unknown format and zero size.
 
void Clear ()
 Constructs an image using an unknown format and zero size.
 
void SetImageFormat (const ezImageFormat::Enum &format)
 Sets the image format.
 
ezImageFormat::Enum GetImageFormat () const
 Returns the image format.
 
void SetWidth (ezUInt32 uiWidth)
 Sets the image width.
 
ezUInt32 GetWidth (ezUInt32 uiMipLevel=0) const
 Returns the image width for a given mip level, clamped to 1.
 
void SetHeight (ezUInt32 uiHeight)
 Sets the image height.
 
ezUInt32 GetHeight (ezUInt32 uiMipLevel=0) const
 Returns the image height for a given mip level, clamped to 1.
 
void SetDepth (ezUInt32 uiDepth)
 Sets the image depth. The default is 1.
 
ezUInt32 GetDepth (ezUInt32 uiMipLevel=0) const
 Returns the image depth for a given mip level, clamped to 1.
 
void SetNumMipLevels (ezUInt32 uiNumMipLevels)
 Sets the number of mip levels, including the full-size image. More...
 
ezUInt32 GetNumMipLevels () const
 Returns the number of mip levels, including the full-size image.
 
void SetNumFaces (ezUInt32 uiNumFaces)
 Sets the number of cubemap faces. Use 1 for a non-cubemap. More...
 
ezUInt32 GetNumFaces () const
 Returns the number of cubemap faces, or 1 for a non-cubemap.
 
void SetNumArrayIndices (ezUInt32 uiNumArrayIndices)
 Sets the number of array indices. More...
 
ezUInt32 GetNumArrayIndices () const
 Returns the number of array indices.
 
ezUInt32 GetNumBlocksX (ezUInt32 uiMipLevel=0) const
 Returns the number of blocks contained in a given mip level in the horizontal direction.
 
ezUInt32 GetNumBlocksY (ezUInt32 uiMipLevel=0) const
 Returns the number of blocks contained in a given mip level in the horizontal direction.
 
ezUInt32 GetNumBlocksZ (ezUInt32 uiMipLevel=0) const
 Returns the number of blocks contained in a given mip level in the depth direction.
 
ezUInt32 GetRowPitch (ezUInt32 uiMipLevel=0) const
 Returns the offset in bytes between two subsequent rows of the given mip level.
 
ezUInt32 GetDepthPitch (ezUInt32 uiMipLevel=0) const
 Returns the offset in bytes between two subsequent depth slices of the given mip level.
 
ezUInt32 ComputeDataSize () const
 Computes the data size required for an image with the header's format and dimensions.
 
ezUInt32 ComputeNumberOfMipMaps () const
 Computes the number of mip maps in the full mip chain.
 
- Protected Attributes inherited from ezImageView
ezHybridArray< ezUInt32, 16 > m_subImageOffsets
 
ezArrayPtr< ezUInt8 > m_dataPtr
 
- Protected Attributes inherited from ezImageHeader
ezUInt32 m_uiNumMipLevels
 
ezUInt32 m_uiNumFaces
 
ezUInt32 m_uiNumArrayIndices
 
ezUInt32 m_uiWidth
 
ezUInt32 m_uiHeight
 
ezUInt32 m_uiDepth
 
ezImageFormat::Enum m_format
 

Detailed Description

A class containing image data and associated meta data.

This class is a lightweight container for image data and the description required for interpreting the data, such as the image format, its dimensions, number of sub-images (i.e. cubemap faces, mip levels and array sub-images). However, it does not provide any methods for interpreting or modifying of the image data.

The sub-images are stored in a predefined order compatible with the layout of DDS files, that is, it first stores the mip chain for each image, then all faces in a case of a cubemap, then the individual images of an image array.

Member Function Documentation

◆ ResetAndAlloc()

void ezImage::ResetAndAlloc ( const ezImageHeader header)

Constructs an image with the given header and ensures sufficient storage is allocated.

Note
If this ezImage was previously attached to external storage, this will reuse that storage. However, if the external storage is not sufficiently large, ResetAndAlloc() will detach from it and allocate internal storage.

◆ ResetAndCopy()

void ezImage::ResetAndCopy ( const ezImageView other)

Constructs from an image view. Copies the image data to internal storage.

If the image is currently attached to external storage, the attachment is discarded.

◆ ResetAndMove()

void ezImage::ResetAndMove ( ezImage &&  other)

Moves the given data into this object.

If other is attached to an external storage, this object will also be attached to it, so life-time requirements for the external storage are now bound to this instance.

◆ ResetAndUseExternalStorage()

void ezImage::ResetAndUseExternalStorage ( const ezImageHeader header,
ezArrayPtr< void >  externalData 
)

Constructs an image with the given header and attaches to the user-supplied external storage.

The user is responsible to keep the external storage alive as long as this ezImage is alive.


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