VTFParser
Simple and modern library for parsing the Valve Texture Format
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
VtfParser::Vtf Class Reference

#include <vtf.hpp>

Classes

struct  HighResImageExtent
 
struct  LowResImageExtent
 

Public Member Functions

 Vtf (std::shared_ptr< std::vector< std::byte > > data)
 
ImageFormat getHighResImageFormat () const
 
HighResImageExtent getHighResImageExtent (uint8_t mipLevel=0) const
 
uint8_t getFaces () const
 
uint8_t getMipLevels () const
 
uint16_t getFrames () const
 
uint16_t getFirstFrame () const
 
std::span< const std::byte > getHighResImageData () const
 
size_t getImageSliceOffset (const uint8_t mipLevel=0, const uint16_t frame=0, const uint8_t face=0, const uint16_t depth=0) const
 
ImageFormat getLowResImageFormat () const
 
LowResImageExtent getLowResImageExtent () const
 
std::span< const std::byte > getLowResImageData () const
 

Detailed Description

Abstracts parsing and accessing the contents of the Valve Texture Format (VTF).

Constructor & Destructor Documentation

◆ Vtf()

VtfParser::Vtf::Vtf ( std::shared_ptr< std::vector< std::byte > >  data)
explicit

Loads the VTF given by the binary data into an easily accessible structure.

Parameters
data

Member Function Documentation

◆ getFaces()

uint8_t VtfParser::Vtf::getFaces ( ) const

Gets the number of cubemap faces in the image.

Returns
6 or 7 for cubemaps (depending on version) and 1 for anything else

◆ getFirstFrame()

uint16_t VtfParser::Vtf::getFirstFrame ( ) const

Gets the frame of animation to start on.

Returns
First frame of the animation.

◆ getFrames()

uint16_t VtfParser::Vtf::getFrames ( ) const

Gets the number of frames of animation in the image.

Returns
Number of frames.

◆ getHighResImageData()

std::span< const std::byte > VtfParser::Vtf::getHighResImageData ( ) const

Gets the high resolution image data.

Returns
View over the high-res data.

◆ getHighResImageExtent()

Vtf::HighResImageExtent VtfParser::Vtf::getHighResImageExtent ( uint8_t  mipLevel = 0) const

Gets the extents (size on each axis) of the high resolution image data at the given mip level.

Parameters
mipLevelMipmap to get the extents of.
Returns
Width, height and depth of the image's mip level.

◆ getHighResImageFormat()

ImageFormat VtfParser::Vtf::getHighResImageFormat ( ) const

Gets the format of the high resolution image data.

Returns
ImageFormat enum.

◆ getImageSliceOffset()

size_t VtfParser::Vtf::getImageSliceOffset ( const uint8_t  mipLevel = 0,
const uint16_t  frame = 0,
const uint8_t  face = 0,
const uint16_t  depth = 0 
) const

Gets the offset to an image slice at the given mipmap level, animation frame, cubemap face and depth in the high res image data.

Remarks
Each image slice is a regular 2D image and may be in any of the supported formats,
including compressed formats using DXT1, DXT3 or DXT5. All slices have the same format.
Parameters
mipLevelLevel of the mipmap chain.
frameFrame of animation.
faceFace of a cubemap.
depthDepth or Z value of a volumetric texture.
Returns
Offset (in bytes) into the data returned by getHighResImageData().

◆ getLowResImageData()

std::span< const std::byte > VtfParser::Vtf::getLowResImageData ( ) const

Gets the low resolution image data.

Returns
View over the low res data.

◆ getLowResImageExtent()

Vtf::LowResImageExtent VtfParser::Vtf::getLowResImageExtent ( ) const

Gets the extents (size on each axis) of the low resolution image data.

Remarks
Unlike the high resolution image, the low res image has no mipmaps.
Returns
Width and height of the low resolution image.

◆ getLowResImageFormat()

ImageFormat VtfParser::Vtf::getLowResImageFormat ( ) const

Gets the format of the low resolution image data.

Remarks
This is almost always DXT1.
Returns
ImageFormat enum.

◆ getMipLevels()

uint8_t VtfParser::Vtf::getMipLevels ( ) const

Gets the number of levels in the image's mipmap chain.

Returns
Number of mipmap levels.

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