ezEngine Release 26.3
Loading...
Searching...
No Matches
ezImageFormat Struct Reference

Comprehensive enumeration of all supported pixel formats with utility functions. More...

#include <ImageFormat.h>

Public Types

enum  Enum : ezUInt16 {
  UNKNOWN , R32G32B32A32_FLOAT , R32G32B32A32_UINT , R32G32B32A32_SINT ,
  R32G32B32_FLOAT , R32G32B32_UINT , R32G32B32_SINT , R16G16B16A16_FLOAT ,
  R16G16B16A16_UNORM , R16G16B16A16_UINT , R16G16B16A16_SNORM , R16G16B16A16_SINT ,
  R16G16B16_UNORM , R32G32_FLOAT , R32G32_UINT , R32G32_SINT ,
  D32_FLOAT_S8X24_UINT , R10G10B10A2_UNORM , R10G10B10A2_UINT , R11G11B10_FLOAT ,
  R8G8B8A8_UNORM , R8G8B8A8_UNORM_SRGB , R8G8B8A8_UINT , R8G8B8A8_SNORM ,
  R8G8B8A8_SINT , B8G8R8A8_UNORM , B8G8R8A8_UNORM_SRGB , B8G8R8X8_UNORM ,
  B8G8R8X8_UNORM_SRGB , R16G16_FLOAT , R16G16_UNORM , R16G16_UINT ,
  R16G16_SNORM , R16G16_SINT , D32_FLOAT , R32_FLOAT ,
  R32_UINT , R32_SINT , D24_UNORM_S8_UINT , R8G8B8_UNORM ,
  R8G8B8_UNORM_SRGB , B8G8R8_UNORM , B8G8R8_UNORM_SRGB , R8G8_UNORM ,
  R8G8_UINT , R8G8_SNORM , R8G8_SINT , R16_FLOAT ,
  D16_UNORM , R16_UNORM , R16_UINT , R16_SNORM ,
  R16_SINT , R8_UNORM , R8_UINT , R8_SNORM ,
  R8_SINT , BC1_UNORM , BC1_UNORM_SRGB , BC2_UNORM ,
  BC2_UNORM_SRGB , BC3_UNORM , BC3_UNORM_SRGB , BC4_UNORM ,
  BC4_SNORM , BC5_UNORM , BC5_SNORM , BC6H_UF16 ,
  BC6H_SF16 , BC7_UNORM , BC7_UNORM_SRGB , ASTC_4x4_UNORM ,
  ASTC_4x4_UNORM_SRGB , ASTC_5x4_UNORM , ASTC_5x4_UNORM_SRGB , ASTC_5x5_UNORM ,
  ASTC_5x5_UNORM_SRGB , ASTC_6x5_UNORM , ASTC_6x5_UNORM_SRGB , ASTC_6x6_UNORM ,
  ASTC_6x6_UNORM_SRGB , ASTC_8x5_UNORM , ASTC_8x5_UNORM_SRGB , ASTC_8x6_UNORM ,
  ASTC_8x6_UNORM_SRGB , ASTC_10x5_UNORM , ASTC_10x5_UNORM_SRGB , ASTC_10x6_UNORM ,
  ASTC_10x6_UNORM_SRGB , ASTC_8x8_UNORM , ASTC_8x8_UNORM_SRGB , ASTC_10x8_UNORM ,
  ASTC_10x8_UNORM_SRGB , ASTC_10x10_UNORM , ASTC_10x10_UNORM_SRGB , ASTC_12x10_UNORM ,
  ASTC_12x10_UNORM_SRGB , ASTC_12x12_UNORM , ASTC_12x12_UNORM_SRGB , B4G4R4A4_UNORM ,
  B4G4R4A4_UNORM_SRGB , A4B4G4R4_UNORM , A4B4G4R4_UNORM_SRGB , B5G6R5_UNORM ,
  B5G6R5_UNORM_SRGB , B5G5R5A1_UNORM , B5G5R5A1_UNORM_SRGB , B5G5R5X1_UNORM ,
  B5G5R5X1_UNORM_SRGB , A1B5G5R5_UNORM , A1B5G5R5_UNORM_SRGB , X1B5G5R5_UNORM ,
  X1B5G5R5_UNORM_SRGB , NV12 , P010 , NUM_FORMATS ,
  Default = UNKNOWN
}
 
using StorageType = ezUInt16
 

Static Public Member Functions

static const char * GetName (Enum format)
 Returns the name of the given format.
 
static ezUInt32 GetPlaneCount (Enum format)
 Returns number of planes in the format, or 1 for non-planar formats.
 
static ezUInt32 GetBitsPerPixel (Enum format, ezUInt32 uiPlaneIndex=0)
 Returns the number of bits per pixel of the given format. If the format's bpp is non-integral, the returned value rounded up to to the next integer.
 
static float GetExactBitsPerPixel (Enum format, ezUInt32 uiPlaneIndex=0)
 Exact pixel size in bits. May be non-integral for some compressed formats.
 
static ezUInt32 GetBitsPerBlock (Enum format, ezUInt32 uiPlaneIndex=0)
 Returns the block size in bits. For uncompressed formats, a block is considered a single pixel.
 
static ezUInt32 GetNumChannels (Enum format)
 Number of channels (r, g, b, a, depth, stencil) supported by this format.
 
static ezUInt32 GetChannelMask (Enum format, ezImageFormatChannel::Enum c)
 Bitmask of each channel of the format. This is not defined for some formats, and may return 0.
 
static ezUInt32 GetBitsPerChannel (Enum format, ezImageFormatChannel::Enum c)
 Returns the number of bits for each channel of the format.
 
static ezUInt32 GetRedMask (Enum format)
 If applicable, returns a bitmask for the red component of the format.
 
static ezUInt32 GetGreenMask (Enum format)
 If applicable, returns a bitmask for the green component of the format.
 
static ezUInt32 GetBlueMask (Enum format)
 If applicable, returns a bitmask for the blue component of the format.
 
static ezUInt32 GetAlphaMask (Enum format)
 If applicable, returns a bitmask for the alpha component of the format.
 
static ezUInt32 GetBlockWidth (Enum format, ezUInt32 uiPlaneIndex=0)
 Block width of a compressed format. Defaults to 1 for uncompressed formats.
 
static ezUInt32 GetBlockHeight (Enum format, ezUInt32 uiPlaneIndex=0)
 Block height of a compressed format. Defaults to 1 for uncompressed formats.
 
static ezUInt32 GetBlockDepth (Enum format, ezUInt32 uiPlaneIndex=0)
 Block depth of a compressed format. Defaults to 1 for uncompressed formats.
 
static ezImageFormatDataType::Enum GetDataType (Enum format)
 Returns the data type represented by a format.
 
static bool IsCompressed (Enum format)
 Returns true if the format is compressed.
 
static bool IsDepth (Enum format)
 Returns true if the format is a depth format.
 
static bool IsSrgb (Enum format)
 Returns whether the given format is an sRGB format.
 
static bool IsStencil (Enum format)
 Returns true if the format is a stencil format.
 
static Enum AsSrgb (Enum format)
 Returns the corresponding sRGB format if one exists; otherwise returns the unmodified format.
 
static Enum AsLinear (Enum format)
 Returns the corresponding linear format if one exists; otherwise returns the unmodified format.
 
static ezUInt32 GetNumBlocksX (Enum format, ezUInt32 uiWidth, ezUInt32 uiPlaneIndex=0)
 Computes the number of blocks in X direction (compressed) or pixels (if uncompressed) for a given width (in pixels).
 
static ezUInt32 GetNumBlocksY (Enum format, ezUInt32 uiHeight, ezUInt32 uiPlaneIndex=0)
 Computes the number of blocks in Y direction (compressed) or pixels (if uncompressed) for a given height (in pixels).
 
static ezUInt32 GetNumBlocksZ (Enum format, ezUInt32 uiDepth, ezUInt32 uiPlaneIndex=0)
 Computes the number of blocks in Z direction (compressed) or pixels (if uncompressed) for a given height (in pixels).
 
static ezUInt64 GetRowPitch (Enum format, ezUInt32 uiWidth, ezUInt32 uiPlaneIndex=0)
 Computes the size in bytes of a row of blocks (compressed) or pixels (if uncompressed) of the given width.
 
static ezUInt64 GetDepthPitch (Enum format, ezUInt32 uiWidth, ezUInt32 uiHeight, ezUInt32 uiPlaneIndex=0)
 Computes the size in bytes of a 2D slice of blocks (compressed) or pixels (if uncompressed) of the given width and height.
 
static ezImageFormatType::Enum GetType (Enum format)
 Returns the type of the image format.
 
static ezImageFormat::Enum FromPixelMask (ezUInt32 uiRedMask, ezUInt32 uiGreenMask, ezUInt32 uiBlueMask, ezUInt32 uiAlphaMask, ezUInt32 uiBitsPerPixel)
 Finds a format matching the given component masks.
 
static ezImageFormat::Enum GetPlaneSubFormat (ezImageFormat::Enum format, ezUInt32 uiPlaneIndex)
 Returns the format of a subplane of a given format.
 
static bool IsCompatible (Enum left, Enum right)
 Returns true if the data formats are compatible, i.e. can be copied into one another.
 
static bool RequiresFirstLevelBlockAlignment (Enum format)
 Returns true if the most high-res miplevel requires block alignment.
 

Detailed Description

Comprehensive enumeration of all supported pixel formats with utility functions.

This struct provides both format enumeration and extensive utility functions for working with different pixel formats. It handles format conversion queries, memory layout calculations, and format property inspection.

Format Categories:

  • Linear formats: Channels stored interleaved per pixel (e.g., RGBARGBARGBA...)
  • Block compressed: Pixels grouped into compressed blocks (BC1-7, ASTC formats)
  • Planar formats: Channels stored in separate memory planes (YUV video formats)

Common Usage Patterns:

// Query format properties
bool isCompressed = ezImageFormat::IsCompressed(ezImageFormat::BC1_UNORM);
ezUInt32 bitsPerPixel = ezImageFormat::GetBitsPerPixel(format);
// Calculate memory requirements
ezUInt64 rowPitch = ezImageFormat::GetRowPitch(format, width);
ezUInt64 slicePitch = ezImageFormat::GetDepthPitch(format, width, height);
// Format conversion queries
bool canConvert = ezImageFormat::IsCompatible(sourceFormat, targetFormat);
ezImageFormat::Enum srgbVersion = ezImageFormat::AsSrgb(linearFormat);
static bool IsCompatible(Enum left, Enum right)
Returns true if the data formats are compatible, i.e. can be copied into one another.
Definition ImageFormat.cpp:542
static ezUInt64 GetRowPitch(Enum format, ezUInt32 uiWidth, ezUInt32 uiPlaneIndex=0)
Computes the size in bytes of a row of blocks (compressed) or pixels (if uncompressed) of the given w...
Definition ImageFormat.cpp:791
static bool IsCompressed(Enum format)
Returns true if the format is compressed.
Definition ImageFormat.cpp:746
static Enum AsSrgb(Enum format)
Returns the corresponding sRGB format if one exists; otherwise returns the unmodified format.
Definition ImageFormat.cpp:766
static ezUInt32 GetBitsPerPixel(Enum format, ezUInt32 uiPlaneIndex=0)
Returns the number of bits per pixel of the given format. If the format's bpp is non-integral,...
Definition ImageFormat.cpp:476
static ezUInt64 GetDepthPitch(Enum format, ezUInt32 uiWidth, ezUInt32 uiHeight, ezUInt32 uiPlaneIndex=0)
Computes the size in bytes of a 2D slice of blocks (compressed) or pixels (if uncompressed) of the gi...
Definition ImageFormat.cpp:796

Block Compressed Formats: Block compressed formats store pixels in fixed-size blocks (4x4 for BC formats, variable for ASTC). This provides significant memory savings but requires special handling during processing.

Planar Formats: Planar formats like NV12 store different channels in separate memory planes. For example, NV12 has a luma (Y) plane and an interleaved chroma (UV) plane. Use GetPlaneSubFormat() to get the format description for individual planes.

Member Function Documentation

◆ GetName()

const char * ezImageFormat::GetName ( Enum  format)
static

Returns the name of the given format.

The returned string is guaranteed to be stable across engine versions and thus suitable for serialization.


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