ezEngine  Milestone 7
ezImage Class Reference

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

#include <Image.h>

Inheritance diagram for ezImage:

Classes

struct  SubImage
 

Public Member Functions

 ezImage ()
 Constructs an empty image.
 
ezResult LoadFrom (const char *szFileName, ezLogInterface *pLog=ezGlobalLog::GetInstance())
 Convenience function to load the image from the given file.
 
ezResult SaveTo (const char *szFileName, ezLogInterface *pLog=ezGlobalLog::GetInstance())
 Convenience function to save the image to the given file.
 
ezUInt32 GetNumBlocksX (ezUInt32 uiMipLevel=0) const
 Returns the number of blocks contained in a given mip level in the horizontal direction. More...
 
ezUInt32 GetNumBlocksY (ezUInt32 uiMipLevel=0) const
 Returns the number of blocks contained in a given mip level in the vertical direction. More...
 
ezUInt32 GetDataSize () const
 Returns the size of the allocated image data. More...
 
template<typename T >
T * GetDataPointer ()
 Returns a pointer to the beginning of the data contained in this image.
 
template<typename T >
const T * GetDataPointer () const
 Returns a pointer to the beginning of the data contained in this image.
 
template<typename T >
const T * GetSubImagePointer (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0) const
 Returns a pointer to the beginning of a given sub-image.
 
template<typename T >
T * GetSubImagePointer (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0)
 Returns a pointer to the beginning of a given sub-image.
 
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 contained in a sub-image. More...
 
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 contained in a sub-image. More...
 
template<typename T >
const T * GetBlockPointer (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 uiBlockX=0, ezUInt32 uiBlockY=0, ezUInt32 z=0) const
 Returns a pointer to a given block contained in a sub-image. More...
 
template<typename T >
T * GetBlockPointer (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0, ezUInt32 uiBlockX=0, ezUInt32 uiBlockY=0, ezUInt32 z=0)
 Returns a pointer to a given block contained in a sub-image. More...
 
void AllocateImageData ()
 Allocates the storage space required for the configured number of sub-images. More...
 
ezUInt32 GetRowPitch (ezUInt32 uiMipLevel=0) const
 Returns the offset in bytes between two subsequent rows of the given mip level. More...
 
ezUInt32 GetDepthPitch (ezUInt32 uiMipLevel=0) const
 Returns the offset in bytes between two subsequent depth slices of the given mip level.
 
ezUInt32 GetDataOffSet (ezUInt32 uiMipLevel=0, ezUInt32 uiFace=0, ezUInt32 uiArrayIndex=0) const
 Returns the position in bytes in the data array of the given sub-image.
 
- Public Member Functions inherited from ezImageHeader
 ezImageHeader ()
 Constructs an image using an unknown format and zero size.
 
void SetImageFormat (const ezImageFormat::Enum &format)
 Sets the image format.
 
const ezImageFormat::EnumGetImageFormat () 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.
 

Private Member Functions

void ValidateSubImageIndices (ezUInt32 uiMipLevel, ezUInt32 uiFace, ezUInt32 uiArrayIndex) const
 
SubImageGetSubImage (ezUInt32 uiMipLevel, ezUInt32 uiFace, ezUInt32 uiArrayIndex)
 
const SubImageGetSubImage (ezUInt32 uiMipLevel, ezUInt32 uiFace, ezUInt32 uiArrayIndex) const
 

Private Attributes

ezHybridArray< SubImage, 16 > m_subImages
 
ezDynamicArray< ezUInt8 > m_data
 

Additional Inherited Members

- 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

void ezImage::AllocateImageData ( )

Allocates the storage space required for the configured number of sub-images.

When creating an image, call this method after setting the dimensions and number of mip levels, faces and array indices. Changing the image dimensions or number of sub-images will not automatically reallocate the data.

template<typename T >
const T * ezImage::GetBlockPointer ( ezUInt32  uiMipLevel = 0,
ezUInt32  uiFace = 0,
ezUInt32  uiArrayIndex = 0,
ezUInt32  uiBlockX = 0,
ezUInt32  uiBlockY = 0,
ezUInt32  z = 0 
) const

Returns a pointer to a given block contained in a sub-image.

This method is only valid to use when the image format is a block compressed format.

template<typename T >
T * ezImage::GetBlockPointer ( ezUInt32  uiMipLevel = 0,
ezUInt32  uiFace = 0,
ezUInt32  uiArrayIndex = 0,
ezUInt32  uiBlockX = 0,
ezUInt32  uiBlockY = 0,
ezUInt32  z = 0 
)

Returns a pointer to a given block contained in a sub-image.

This method is only valid to use when the image format is a block compressed format.

ezUInt32 ezImage::GetDataSize ( ) const
inline

Returns the size of the allocated image data.

In addition to the returned size, 16 additional bytes will be allocated, which can be exploited to simplify copying or modification at aligned boundaries.

ezUInt32 ezImage::GetNumBlocksX ( ezUInt32  uiMipLevel = 0) const
inline

Returns the number of blocks contained in a given mip level in the horizontal direction.

This method is only valid to call for block-compressed formats.

ezUInt32 ezImage::GetNumBlocksY ( ezUInt32  uiMipLevel = 0) const
inline

Returns the number of blocks contained in a given mip level in the vertical direction.

This method is only valid to call for block-compressed formats.

template<typename T >
const T * ezImage::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 contained in a sub-image.

This method is only valid to use when the image format is a linear pixel format.

template<typename T >
T * ezImage::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 contained in a sub-image.

This method is only valid to use when the image format is a linear pixel format.

ezUInt32 ezImage::GetRowPitch ( ezUInt32  uiMipLevel = 0) const
inline

Returns the offset in bytes between two subsequent rows of the given mip level.

This method is only valid to use when the image format is a linear pixel format.


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