SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
vtfpp::ImageFormatDetails Namespace Reference

Functions

constexpr int8_t red (ImageFormat format)
 Get the number of bits of precision of the red channel in the given format.
constexpr int8_t decompressedRed (ImageFormat format)
 Get the number of bits of precision of the red channel in the given format regardless of compression.
constexpr int8_t green (ImageFormat format)
 Get the number of bits of precision of the green channel in the given format.
constexpr int8_t decompressedGreen (ImageFormat format)
 Get the number of bits of precision of the green channel in the given format regardless of compression.
constexpr int8_t blue (ImageFormat format)
 Get the number of bits of precision of the blue channel in the given format.
constexpr int8_t decompressedBlue (ImageFormat format)
 Get the number of bits of precision of the blue channel in the given format regardless of compression.
constexpr int8_t alpha (ImageFormat format)
 Get the number of bits of precision of the alpha channel in the given format.
constexpr int8_t decompressedAlpha (ImageFormat format)
 Get the number of bits of precision of the alpha channel in the given format regardless of compression.
constexpr uint8_t bpp (ImageFormat format)
 Find the bits per pixel of the given format.
constexpr ImageFormat containerFormat (ImageFormat format)
 Find a container format for the given format, a format that is more commonly understood within this library and can represent the input texture without losing data.
constexpr bool large (ImageFormat format)
 Check if the given format is representable by RGBA8888 without losing data.
constexpr bool decimal (ImageFormat format)
 Checks if the given format stores floating points in its channels.
constexpr bool compressed (ImageFormat format)
 Check if the given format is a compressed format (DXT1, DXT3, DXT5, ATI1N, ATI2N, BC7, BC6H).
constexpr bool transparent (ImageFormat format)
 Check if the given format can store transparency.
constexpr bool opaque (ImageFormat format)
 Check if the given format cannot store transparency.
constexpr bool console (ImageFormat format)
 Check if the given format is exclusively used on console platforms.
constexpr uint32_t getDataLength (ImageFormat format, uint16_t width, uint16_t height, uint16_t depth=1)
 Calculate the amount of data required to store a texture with the given format and dimensions.
constexpr uint32_t getDataLength (ImageFormat format, uint8_t mipCount, uint16_t frameCount, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t depth=1)
 Calculate the amount of data required to store a texture with the given format, mip/frame/face count, and dimensions.
constexpr uint32_t getDataLengthXBOX (bool padded, ImageFormat format, uint8_t mipCount, uint16_t frameCount, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t depth=1)
 Calculate the amount of data required to store an XBOX platform texture with the given format, mip/frame/face count, and dimensions.
constexpr bool getDataPosition (uint32_t &offset, uint32_t &length, ImageFormat format, uint8_t mip, uint8_t mipCount, uint16_t frame, uint16_t frameCount, uint8_t face, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t slice=0, uint16_t depth=1)
 Find the position of a specific mip, frame, face, and slice within a texture.
constexpr bool getDataPositionXbox (uint32_t &offset, uint32_t &length, bool padded, ImageFormat format, uint8_t mip, uint8_t mipCount, uint16_t frame, uint16_t frameCount, uint8_t face, uint8_t faceCount, uint16_t width, uint16_t height, uint16_t slice=0, uint16_t depth=1)
 Find the position of a specific mip, frame, face, and slice within an XBOX platform texture.

Function Documentation

◆ alpha()

int8_t vtfpp::ImageFormatDetails::alpha ( ImageFormat format)
nodiscardconstexpr

Get the number of bits of precision of the alpha channel in the given format.

Parameters
formatThe format to get the number of bits of precision in this channel from.
Returns
The number of bits of precision the alpha channel has in the given format. -1 is returned if the given format is compressed.

Definition at line 390 of file ImageFormats.h.

◆ blue()

int8_t vtfpp::ImageFormatDetails::blue ( ImageFormat format)
nodiscardconstexpr

Get the number of bits of precision of the blue channel in the given format.

Parameters
formatThe format to get the number of bits of precision in this channel from.
Returns
The number of bits of precision the blue channel has in the given format. -1 is returned if the given format is compressed.

Definition at line 290 of file ImageFormats.h.

◆ bpp()

uint8_t vtfpp::ImageFormatDetails::bpp ( ImageFormat format)
nodiscardconstexpr

Find the bits per pixel of the given format.

Note this is bits per pixel, not bytes per pixel. The DXT1 format is 0.5 bytes per pixel, which cannot be stored in a uint8_t.

Parameters
formatThe format to find the bits per pixel of.
Returns
The bits per pixel of the given format.

Definition at line 492 of file ImageFormats.h.

◆ compressed()

bool vtfpp::ImageFormatDetails::compressed ( ImageFormat format)
nodiscardconstexpr

Check if the given format is a compressed format (DXT1, DXT3, DXT5, ATI1N, ATI2N, BC7, BC6H).

Parameters
formatThe format to check.
Returns
True if the given format is compressed.

Definition at line 658 of file ImageFormats.h.

◆ console()

bool vtfpp::ImageFormatDetails::console ( ImageFormat format)
nodiscardconstexpr

Check if the given format is exclusively used on console platforms.

Parameters
formatThe format to check.
Returns
True if the format is exclusively used on console platforms.

Definition at line 718 of file ImageFormats.h.

◆ containerFormat()

ImageFormat vtfpp::ImageFormatDetails::containerFormat ( ImageFormat format)
nodiscardconstexpr

Find a container format for the given format, a format that is more commonly understood within this library and can represent the input texture without losing data.

Parameters
formatThe format to find the container format of.
Returns
The container format of the given format. If the given format is representable with RGBA8888, that is used. RGBA16161616 is used if the given format is representable with that. RGBA32323232F is used for formats that are too large for both the previous two.

Definition at line 570 of file ImageFormats.h.

◆ decimal()

bool vtfpp::ImageFormatDetails::decimal ( ImageFormat format)
nodiscardconstexpr

Checks if the given format stores floating points in its channels.

Parameters
formatThe format to check.
Returns
True if the given format stores floating points.

Definition at line 649 of file ImageFormats.h.

◆ decompressedAlpha()

int8_t vtfpp::ImageFormatDetails::decompressedAlpha ( ImageFormat format)
nodiscardconstexpr

Get the number of bits of precision of the alpha channel in the given format regardless of compression.

Parameters
formatThe format to get the number of bits of precision in this channel from.
Returns
The number of bits of precision the alpha channel has in the given format.

Definition at line 464 of file ImageFormats.h.

◆ decompressedBlue()

int8_t vtfpp::ImageFormatDetails::decompressedBlue ( ImageFormat format)
nodiscardconstexpr

Get the number of bits of precision of the blue channel in the given format regardless of compression.

Parameters
formatThe format to get the number of bits of precision in this channel from.
Returns
The number of bits of precision the blue channel has in the given format.

Definition at line 364 of file ImageFormats.h.

◆ decompressedGreen()

int8_t vtfpp::ImageFormatDetails::decompressedGreen ( ImageFormat format)
nodiscardconstexpr

Get the number of bits of precision of the green channel in the given format regardless of compression.

Parameters
formatThe format to get the number of bits of precision in this channel from.
Returns
The number of bits of precision the green channel has in the given format.

Definition at line 264 of file ImageFormats.h.

◆ decompressedRed()

int8_t vtfpp::ImageFormatDetails::decompressedRed ( ImageFormat format)
nodiscardconstexpr

Get the number of bits of precision of the red channel in the given format regardless of compression.

Parameters
formatThe format to get the number of bits of precision in this channel from.
Returns
The number of bits of precision the red channel has in the given format.

Definition at line 163 of file ImageFormats.h.

◆ getDataLength() [1/2]

uint32_t vtfpp::ImageFormatDetails::getDataLength ( ImageFormat format,
uint16_t width,
uint16_t height,
uint16_t depth = 1 )
nodiscardconstexpr

Calculate the amount of data required to store a texture with the given format and dimensions.

Parameters
formatThe format of the texture.
widthThe width of the texture.
heightThe height of the texture.
depthThe depth of the texture.
Returns
The length in bytes of a texture containing the given format, width, height, and depth.

Definition at line 842 of file ImageFormats.h.

◆ getDataLength() [2/2]

uint32_t vtfpp::ImageFormatDetails::getDataLength ( ImageFormat format,
uint8_t mipCount,
uint16_t frameCount,
uint8_t faceCount,
uint16_t width,
uint16_t height,
uint16_t depth = 1 )
nodiscardconstexpr

Calculate the amount of data required to store a texture with the given format, mip/frame/face count, and dimensions.

Parameters
formatThe format of the texture.
mipCountThe mip count of the texture.
frameCountThe frame count of the texture.
faceCountThe face count of the texture.
widthThe width of the texture.
heightThe height of the texture.
depthThe depth of the texture.
Returns
The length in bytes of a texture containing the given format, mip count, frame count, face count, width, height, and depth.

Definition at line 861 of file ImageFormats.h.

◆ getDataLengthXBOX()

uint32_t vtfpp::ImageFormatDetails::getDataLengthXBOX ( bool padded,
ImageFormat format,
uint8_t mipCount,
uint16_t frameCount,
uint8_t faceCount,
uint16_t width,
uint16_t height,
uint16_t depth = 1 )
nodiscardconstexpr

Calculate the amount of data required to store an XBOX platform texture with the given format, mip/frame/face count, and dimensions.

XBOX platform textures have padding between frames to attempt to align each one to 512 bytes (this explanation is simplified from the actual padding algorithm but is mostly correct).

Parameters
paddedWhether to add padding after some frames. Some parts of an XBOX platform texture expect this padding and some do not.
formatThe format of the texture.
mipCountThe mip count of the texture.
frameCountThe frame count of the texture.
faceCountThe face count of the texture.
widthThe width of the texture.
heightThe height of the texture.
depthThe depth of the texture.
Returns
The length in bytes of an XBOX platform texture containing the given format, mip count, frame count, face count, width, height, and depth; possibly with padding after some frames.

Definition at line 886 of file ImageFormats.h.

◆ getDataPosition()

bool vtfpp::ImageFormatDetails::getDataPosition ( uint32_t & offset,
uint32_t & length,
ImageFormat format,
uint8_t mip,
uint8_t mipCount,
uint16_t frame,
uint16_t frameCount,
uint8_t face,
uint8_t faceCount,
uint16_t width,
uint16_t height,
uint16_t slice = 0,
uint16_t depth = 1 )
nodiscardconstexpr

Find the position of a specific mip, frame, face, and slice within a texture.

Parameters
offsetSet to the offset of the section of the texture being searched for.
lengthSet to the length of the section of the texture being searched for.
formatThe format of the texture.
mipThe mip level to search for within the texture.
mipCountThe mip count of the texture.
frameThe frame to search for within the texture.
frameCountThe frame count of the texture.
faceThe face to search for within the texture.
faceCountThe face count of the texture.
widthThe width of the texture.
heightThe height of the texture.
sliceThe slice to search for within the texture.
depthThe depth of the texture.
Returns
True if the section of the texture was successfully found.

Definition at line 917 of file ImageFormats.h.

◆ getDataPositionXbox()

bool vtfpp::ImageFormatDetails::getDataPositionXbox ( uint32_t & offset,
uint32_t & length,
bool padded,
ImageFormat format,
uint8_t mip,
uint8_t mipCount,
uint16_t frame,
uint16_t frameCount,
uint8_t face,
uint8_t faceCount,
uint16_t width,
uint16_t height,
uint16_t slice = 0,
uint16_t depth = 1 )
nodiscardconstexpr

Find the position of a specific mip, frame, face, and slice within an XBOX platform texture.

XBOX platform textures are laid out in the inverse of a regular texture in DDS mip layout and have padding between some frames.

Parameters
offsetSet to the offset of the section of the texture being searched for.
lengthSet to the length of the section of the texture being searched for.
paddedWhether to add padding after some frames. Some parts of an XBOX platform texture expect this padding and some do not.
formatThe format of the texture.
mipThe mip level to search for within the texture.
mipCountThe mip count of the texture.
frameThe frame to search for within the texture.
frameCountThe frame count of the texture.
faceThe face to search for within the texture.
faceCountThe face count of the texture.
widthThe width of the texture.
heightThe height of the texture.
sliceThe slice to search for within the texture.
depthThe depth of the texture.
Returns
True if the section of the texture was successfully found.

Definition at line 959 of file ImageFormats.h.

◆ green()

int8_t vtfpp::ImageFormatDetails::green ( ImageFormat format)
nodiscardconstexpr

Get the number of bits of precision of the green channel in the given format.

Parameters
formatThe format to get the number of bits of precision in this channel from.
Returns
The number of bits of precision the green channel has in the given format. -1 is returned if the given format is compressed.

Definition at line 189 of file ImageFormats.h.

◆ large()

bool vtfpp::ImageFormatDetails::large ( ImageFormat format)
nodiscardconstexpr

Check if the given format is representable by RGBA8888 without losing data.

Parameters
formatThe format to check.
Returns
True if the given format cannot be represented by RGBA8888 without losing data.

Definition at line 640 of file ImageFormats.h.

◆ opaque()

bool vtfpp::ImageFormatDetails::opaque ( ImageFormat format)
nodiscardconstexpr

Check if the given format cannot store transparency.

Parameters
formatThe format to check.
Returns
True if the format cannot store transparency.

Definition at line 709 of file ImageFormats.h.

◆ red()

int8_t vtfpp::ImageFormatDetails::red ( ImageFormat format)
nodiscardconstexpr

Get the number of bits of precision of the red channel in the given format.

Parameters
formatThe format to get the number of bits of precision in this channel from.
Returns
The number of bits of precision the red channel has in the given format. -1 is returned if the given format is compressed.

Definition at line 89 of file ImageFormats.h.

◆ transparent()

bool vtfpp::ImageFormatDetails::transparent ( ImageFormat format)
nodiscardconstexpr

Check if the given format can store transparency.

Parameters
formatThe format to check.
Returns
True if the format can store transparency.

Definition at line 667 of file ImageFormats.h.