Plasma Engine  2.0
Loading...
Searching...
No Matches
plImageFormat Struct Reference

Enum describing the encoding format of the pixels of an image. More...

#include <ImageFormat.h>

Public Types

enum  Enum : plUInt16 {
  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 , NUM_FORMATS , Default = UNKNOWN
}
 Enum describing the encoding format of the pixels of an image. More...
 
using StorageType = plUInt16
 

Static Public Member Functions

static const char * GetName (Enum format)
 Returns the name of the given format.
 
static plUInt32 GetPlaneCount (Enum format)
 Returns number of planes in the format, or 1 for non-planar formats.
 
static plUInt32 GetBitsPerPixel (Enum format, plUInt32 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, plUInt32 uiPlaneIndex=0)
 Exact pixel size in bits. May be non-integral for some compressed formats.
 
static plUInt32 GetBitsPerBlock (Enum format, plUInt32 uiPlaneIndex=0)
 Returns the block size in bits. For uncompressed formats, a block is considered a single pixel.
 
static plUInt32 GetNumChannels (Enum format)
 Number of channels (r, g, b, a, depth, stencil) supported by this format.
 
static plUInt32 GetChannelMask (Enum format, plImageFormatChannel::Enum c)
 Bitmask of each channel of the format. This is not defined for some formats, and may return 0.
 
static plUInt32 GetBitsPerChannel (Enum format, plImageFormatChannel::Enum c)
 Returns the number of bits for each channel of the format.
 
static plUInt32 GetRedMask (Enum format)
 If applicable, returns a bitmask for the red component of the format.
 
static plUInt32 GetGreenMask (Enum format)
 If applicable, returns a bitmask for the green component of the format.
 
static plUInt32 GetBlueMask (Enum format)
 If applicable, returns a bitmask for the blue component of the format.
 
static plUInt32 GetAlphaMask (Enum format)
 If applicable, returns a bitmask for the alpha component of the format.
 
static plUInt32 GetBlockWidth (Enum format, plUInt32 uiPlaneIndex=0)
 Block width of a compressed format. Defaults to 1 for uncompressed formats.
 
static plUInt32 GetBlockHeight (Enum format, plUInt32 uiPlaneIndex=0)
 Block height of a compressed format. Defaults to 1 for uncompressed formats.
 
static plUInt32 GetBlockDepth (Enum format, plUInt32 uiPlaneIndex=0)
 Block depth of a compressed format. Defaults to 1 for uncompressed formats.
 
static plImageFormatDataType::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 plUInt32 GetNumBlocksX (Enum format, plUInt32 uiWidth, plUInt32 uiPlaneIndex=0)
 Computes the number of blocks in X direction (compressed) or pixels (if uncompressed) for a given width (in pixels).
 
static plUInt32 GetNumBlocksY (Enum format, plUInt32 uiHeight, plUInt32 uiPlaneIndex=0)
 Computes the number of blocks in Y direction (compressed) or pixels (if uncompressed) for a given height (in pixels).
 
static plUInt32 GetNumBlocksZ (Enum format, plUInt32 uiDepth, plUInt32 uiPlaneIndex=0)
 Computes the number of blocks in Z direction (compressed) or pixels (if uncompressed) for a given height (in pixels).
 
static plUInt64 GetRowPitch (Enum format, plUInt32 uiWidth, plUInt32 uiPlaneIndex=0)
 Computes the size in bytes of a row of blocks (compressed) or pixels (if uncompressed) of the given width.
 
static plUInt64 GetDepthPitch (Enum format, plUInt32 uiWidth, plUInt32 uiHeight, plUInt32 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 plImageFormatType::Enum GetType (Enum format)
 Returns the type of the image format.
 
static plImageFormat::Enum FromPixelMask (plUInt32 uiRedMask, plUInt32 uiGreenMask, plUInt32 uiBlueMask, plUInt32 uiAlphaMask, plUInt32 uiBitsPerPixel)
 Finds a format matching the given component masks.
 
static plImageFormat::Enum GetPlaneSubFormat (plImageFormat::Enum format, plUInt32 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

Enum describing the encoding format of the pixels of an image.

Member Enumeration Documentation

◆ Enum

enum plImageFormat::Enum : plUInt16

Enum describing the encoding format of the pixels of an image.

Image formats can be separated into three types: linear, block compressed, and planar. In linear formats, the various channels of each pixel (such as R, G, B) are stored interleaved in memory [RGBRGBRGB...]. This is in contrast to planar formats, where each channel is stored in a separate slice of memory [RRR...GGG...BBB...]. Planar formats are typically used for video formats with luma and chroma channels, and may also be partially planarized. For example, NV12 has a luma (Y) plane and a chroma (UV) plane, where the chroma plane again stores the two sub-channels linearly interleaved. For these formats, GetPlaneSubFormat() returns a description of the encoding within each plane. Block compressed formats use a different approach, where pixels are arranged in blocks of a fixed format-dependent size (from 4x4 for BC1-7 and up to 12x12 for some ASTC formats), with colors encoded with a fixed ratio compression.

Member Function Documentation

◆ GetName()

const char * plImageFormat::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: