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

Functions

constexpr uint16_t getMipDim (uint8_t mip, uint16_t dim, bool addCompressedFormatPadding=false)
 Get the dimension at a given mip level.
constexpr std::pair< uint16_t, uint16_t > getMipDims (uint8_t mip, uint16_t width, uint16_t height, bool addCompressedFormatPadding=false)
 Get the width and height at a given mip level.
constexpr std::tuple< uint16_t, uint16_t, uint16_t > getMipDims (uint8_t mip, uint16_t width, uint16_t height, uint16_t depth, bool addCompressedFormatPadding=false)
 Get the width, height, and depth at a given mip level.
constexpr uint8_t getMaximumMipCount (uint16_t width, uint16_t height, uint16_t depth=1)
 Calculate the largest mip count a texture with the given width, height, and depth can contain.

Function Documentation

◆ getMaximumMipCount()

uint8_t vtfpp::ImageDimensions::getMaximumMipCount ( uint16_t width,
uint16_t height,
uint16_t depth = 1 )
nodiscardconstexpr

Calculate the largest mip count a texture with the given width, height, and depth can contain.

On console platforms, since there is no mip count field in the header, this determines the actual mip count if the texture contains mips.

Parameters
widthThe width of the largest mip in the texture.
heightThe height of the largest mip in the texture.
depthThe depth of the largest mip in the texture.
Returns
The largest mip count possible for the texture to contain.

Definition at line 817 of file ImageFormats.h.

◆ getMipDim()

uint16_t vtfpp::ImageDimensions::getMipDim ( uint8_t mip,
uint16_t dim,
bool addCompressedFormatPadding = false )
nodiscardconstexpr

Get the dimension at a given mip level.

Does not include padding added by compressed formats by default.

Parameters
mipThe mip level. This should not be enabled if the input dimension is depth, as compressed formats are compressed on 2D slices. Otherwise, it should be enabled if ImageFormatDetails::compressed(format) is true.
dimThe dimension of the largest mip in the texture. Can be width, height, or depth.
addCompressedFormatPaddingAligns the output dimension to 4 pixels.
Returns
The dimension at the given mip level.

Definition at line 753 of file ImageFormats.h.

◆ getMipDims() [1/2]

std::pair< uint16_t, uint16_t > vtfpp::ImageDimensions::getMipDims ( uint8_t mip,
uint16_t width,
uint16_t height,
bool addCompressedFormatPadding = false )
nodiscardconstexpr

Get the width and height at a given mip level.

Does not include padding added by compressed formats by default.

Parameters
mipThe mip level.
widthThe width of the largest mip in the texture.
heightThe height of the largest mip in the texture.
addCompressedFormatPaddingAligns the output width and height to 4 pixels.
Returns
The width and height at the given mip level.

Definition at line 774 of file ImageFormats.h.

◆ getMipDims() [2/2]

std::tuple< uint16_t, uint16_t, uint16_t > vtfpp::ImageDimensions::getMipDims ( uint8_t mip,
uint16_t width,
uint16_t height,
uint16_t depth,
bool addCompressedFormatPadding = false )
nodiscardconstexpr

Get the width, height, and depth at a given mip level.

Does not include padding added by compressed formats by default.

Parameters
mipThe mip level.
widthThe width of the largest mip in the texture.
heightThe height of the largest mip in the texture.
depthThe depth of the largest mip in the texture.
addCompressedFormatPaddingAligns the output width and height to 4 pixels.
Returns
The width, height, and depth at the given mip level.

Definition at line 795 of file ImageFormats.h.