VTFParser
Simple and modern library for parsing the Valve Texture Format
Loading...
Searching...
No Matches
vtf.hpp
1#pragma once
2
3#include "file-format-objects/header.hpp"
4#include <cstdint>
5#include <memory>
6#include <span>
7#include <vector>
8
9namespace VtfParser {
13 class Vtf {
14 public:
22 uint8_t width;
26 uint8_t height;
27 };
28
36 uint16_t width;
40 uint16_t height;
44 uint16_t depth;
45 };
46
51 explicit Vtf(std::shared_ptr<std::vector<std::byte>> data);
52
57 [[nodiscard]] ImageFormat getHighResImageFormat() const;
58
64 [[nodiscard]] HighResImageExtent getHighResImageExtent(uint8_t mipLevel = 0) const;
65
70 [[nodiscard]] uint8_t getFaces() const;
71
76 [[nodiscard]] uint8_t getMipLevels() const;
77
82 [[nodiscard]] uint16_t getFrames() const;
87 [[nodiscard]] uint16_t getFirstFrame() const;
88
93 [[nodiscard]] TextureFlags getFlags() const;
94
99 [[nodiscard]] std::span<const std::byte> getHighResImageData() const;
100
111 [[nodiscard]] size_t getImageSliceOffset(
112 const uint8_t mipLevel = 0, const uint16_t frame = 0, const uint8_t face = 0, const uint16_t depth = 0
113 ) const;
114
120 [[nodiscard]] ImageFormat getLowResImageFormat() const;
121
127 [[nodiscard]] LowResImageExtent getLowResImageExtent() const;
128
133 [[nodiscard]] std::span<const std::byte> getLowResImageData() const;
134
135 private:
136 Header header;
137
138 std::shared_ptr<std::vector<std::byte>> data;
139 std::span<const std::byte> highResImageData;
140 std::span<const std::byte> lowResImageData;
141 };
142}
Definition: vtf.hpp:13
LowResImageExtent getLowResImageExtent() const
Definition: vtf.cpp:260
ImageFormat getHighResImageFormat() const
Definition: vtf.cpp:184
uint16_t getFrames() const
Definition: vtf.cpp:208
TextureFlags getFlags() const
Definition: vtf.cpp:216
std::span< const std::byte > getHighResImageData() const
Definition: vtf.cpp:220
uint8_t getMipLevels() const
Definition: vtf.cpp:204
std::span< const std::byte > getLowResImageData() const
Definition: vtf.cpp:267
HighResImageExtent getHighResImageExtent(uint8_t mipLevel=0) const
Definition: vtf.cpp:188
uint8_t getFaces() const
Definition: vtf.cpp:196
size_t getImageSliceOffset(const uint8_t mipLevel=0, const uint16_t frame=0, const uint8_t face=0, const uint16_t depth=0) const
Definition: vtf.cpp:224
uint16_t getFirstFrame() const
Definition: vtf.cpp:212
ImageFormat getLowResImageFormat() const
Definition: vtf.cpp:256
Definition: VTFParser.hpp:6
TextureFlags
Definition: enums.hpp:44
ImageFormat
Definition: enums.hpp:10
Definition: header.hpp:125
uint16_t depth
Definition: vtf.hpp:44
uint16_t height
Definition: vtf.hpp:40
uint16_t width
Definition: vtf.hpp:36
Definition: vtf.hpp:18
uint8_t width
Definition: vtf.hpp:22
uint8_t height
Definition: vtf.hpp:26