TEX file¶
Used in only the PC games for 2x resolution fonts and UI elements.
Layout¶
Offset (Bytes) |
Size (Bytes) |
Name |
Description |
|---|---|---|---|
0 |
108 |
m_tex_header |
The main TEX header |
108 |
80 |
m_tex_pixel_format_header |
The pixel format header |
188 |
48 |
m_tex_header2 |
The second part of the TEX header |
236 |
4 or 0 |
m_tex_header2_version2 |
The third part of the TEX header (FF8) |
236 or 240 |
Varies |
m_palette_data |
The palette data |
Varies |
Varies |
m_image_data |
The image data |
-
struct Tex¶
A structure representing a TEX file.
The Tex structure represents a texture file used in the FF7 and FF8 games. It consists of several headers and data fields describing the texture and its format.
See also
https://github.com/MaKiPL/FF8_Rinoa_s_Toolset/blob/master/SerahToolkit_SharpGL/FF8_Core/TEX.cs
Public Functions
-
Tex() = default¶
Default constructor.
-
inline explicit Tex(std::span<const char> buffer)¶
Construct a Tex object from a buffer.
- Parameters:
buffer – A span containing the TEX file data.
-
inline auto get_colors([[maybe_unused]] std::uint32_t palette_row = 0U) const¶
Get the colors of the texture.
- Parameters:
palette_row – Optional palette row number (default is 0).
- Returns:
A vector of Color32 objects in RGBA format.
-
inline void save(std::filesystem::path filename) const¶
Save the TEX file as an image file (PPM and PNG) with optional palette support.
- Parameters:
filename – The output filename.
-
Tex() = default¶
Header¶
Part 1¶
Total Size: 108 bytes
Offset (bytes) |
Size (bytes) |
Name |
Description |
|---|---|---|---|
0 |
4 |
m_version |
Version (must be 1 for FF7 or 2 for FF8) |
4 |
4 |
m_unknown_1 |
Unknown 1 |
8 |
4 |
m_color_key_flag |
Color Key Flag |
12 |
4 |
m_unknown_2 |
Unknown 2 |
16 |
4 |
m_unknown_3 |
Unknown 3 |
20 |
4 |
m_min_bits_per_color |
Minimum Number of Bits per Color |
24 |
4 |
m_max_bits_per_color |
Maximum Number of Bits per Color |
28 |
4 |
m_min_alpha_bits |
Minimum Number of Alpha Bits |
32 |
4 |
m_max_alpha_bits |
Maximum Number of Alpha Bits |
36 |
4 |
m_min_bits_per_pixel |
Minimum Number of Bits per Pixel |
40 |
4 |
m_max_bits_per_pixel |
Maximum Number of Bits per Pixel |
44 |
4 |
m_unknown_4 |
Unknown 4 |
48 |
4 |
m_num_palettes |
Number of Palettes |
52 |
4 |
m_num_colors_per_palette |
Number of Colors per Palette |
56 |
4 |
m_bit_depth |
Bit Depth |
60 |
4 |
m_image_width |
Image Width |
64 |
4 |
m_image_height |
Image Height |
68 |
4 |
m_bytes_per_row |
Bytes per Row (usually ignored) |
72 |
4 |
m_unknown_5 |
Unknown 5 |
76 |
4 |
m_palette_flag |
Palette Flag (indicates the presence of a palette) |
80 |
4 |
m_bits_per_index |
Bits per Index (always 0 for non-paletted images) |
84 |
4 |
m_indexed_to_8_bit_flag |
Indexed_to_8bit Flag (never used in FF7) |
88 |
4 |
m_palette_size |
Palette Size |
92 |
4 |
m_num_colors_per_palette_dup |
Number of Colors per Palette (duplicate) |
96 |
4 |
m_runtime_data_1 |
Runtime Data 1 (ignored on load) |
100 |
4 |
m_bits_per_pixel |
Number of Bits per Pixel |
104 |
4 |
m_bytes_per_pixel |
Number of Bytes per Pixel |
-
struct TexHeader¶
Header see version to know if the extra value is present in header 2. Tells how the data is laid out in the file.
Public Functions
-
inline auto version() const noexcept¶
Test for valid values.
- Returns:
Version (must be 1 for ff7 or 2 for ff8)
-
inline const auto &unknown_1() const noexcept¶
Unknown 1
-
inline const auto &color_key_flag() const noexcept¶
Color Key Flag
-
inline const auto &unknown_2() const noexcept¶
Unknown 2
-
inline const auto &unknown_3() const noexcept¶
Unknown 3
-
inline const auto &min_bits_per_color() const noexcept¶
Minimum Number of Bits per Color
-
inline const auto &max_bits_per_color() const noexcept¶
Maximum Number of Bits per Color
-
inline const auto &min_alpha_bits() const noexcept¶
Minimum Number of Alpha Bits
-
inline const auto &max_alpha_bits() const noexcept¶
Maximum Number of Alpha Bits
-
inline const auto &min_bits_per_pixel() const noexcept¶
Minimum Number of Bits per Pixel
-
inline const auto &max_bits_per_pixel() const noexcept¶
Maximum Number of Bits per Pixel
-
inline const auto &unknown_4() const noexcept¶
Unknown 4
-
inline const auto &num_palettes() const noexcept¶
Number of Palettes
-
inline const auto &num_colors_per_palette() const noexcept¶
Number of Colors per Palette
-
inline const auto &bit_depth() const noexcept¶
Bit Depth
-
inline const auto &image_width() const noexcept¶
Image Width
-
inline const auto &image_height() const noexcept¶
Image Height
-
inline const auto &bytes_per_row() const noexcept¶
Bytes per Row (usually ignored and assumed to be bytes per pixel * width)
-
inline auto unknown_5() const noexcept¶
Unknown 5
-
inline bool palette_flag() const noexcept¶
Palette Flag (indicates the presence of a palette)
-
inline const auto &bits_per_index() const noexcept¶
Bits per Index (always 0 for non_paletted images)
-
inline const auto &indexed_to_8_bit_flag() const noexcept¶
Indexed_to_8bit Flag (never used in FF7)
-
inline const auto &palette_size() const noexcept¶
Palette Size (always number of palettes * colors per palette)
-
inline const auto &num_colors_per_palette_dup() const noexcept¶
Number of Colors per Palette again (may be 0 sometimes; the first value will be used anyway)
-
inline const auto &runtime_data_1() const noexcept¶
Runtime Data 1 (ignored on load)
-
inline const auto &bits_per_pixel() const noexcept¶
Number of Bits per Pixel
-
inline const auto &bytes_per_pixel() const noexcept¶
Number of Bytes per Pixel
-
inline std::size_t image_area() const noexcept¶
Area of image
- Returns:
Height * Width
-
inline bool check() const noexcept¶
Test for valid values.
- Returns:
-
inline auto version() const noexcept¶
Part 2 - Pixel Format¶
Total Size: 80 bytes
Offset (bytes) |
Size (bytes) |
Name |
Description |
|---|---|---|---|
0 |
4 |
m_num_red_bits |
Number of Red Bits |
4 |
4 |
m_num_green_bits |
Number of Green Bits |
8 |
4 |
m_num_blue_bits |
Number of Blue Bits |
12 |
4 |
m_num_alpha_bits |
Number of Alpha Bits |
16 |
4 |
m_red_bitmask |
Red Bitmask |
20 |
4 |
m_green_bitmask |
Green Bitmask |
24 |
4 |
m_blue_bitmask |
Blue Bitmask |
28 |
4 |
m_alpha_bitmask |
Alpha Bitmask |
32 |
4 |
m_red_shift |
Red Shift |
36 |
4 |
m_green_shift |
Green Shift |
40 |
4 |
m_blue_shift |
Blue Shift |
44 |
4 |
m_alpha_shift |
Alpha Shift |
48 |
4 |
m_minus_8_num_red_bits |
8 - Number of Red Bits (ignored) |
52 |
4 |
m_minus_8_num_green_bits |
8 - Number of Green Bits (ignored) |
56 |
4 |
m_minus_8_num_blue_bits |
8 - Number of Blue Bits (ignored) |
60 |
4 |
m_minus_8_num_alpha_bits |
8 - Number of Alpha Bits (ignored) |
64 |
4 |
m_red_max |
Red Max |
68 |
4 |
m_green_max |
Green Max |
72 |
4 |
m_blue_max |
Blue Max |
76 |
4 |
m_alpha_max |
Alpha Max |
-
struct TexPixelFormatHeader¶
Pixel format header. This tells how the colors are laid out. These are usually always the same.
Public Functions
-
inline auto num_red_bits() const noexcept¶
Number of Red Bits
-
inline auto num_green_bits() const noexcept¶
Number of Green Bits
-
inline auto num_blue_bits() const noexcept¶
Number of Blue Bits
-
inline auto num_alpha_bits() const noexcept¶
Number of Alpha Bits
-
inline auto red_bitmask() const noexcept¶
Red Bitmask
-
inline auto green_bitmask() const noexcept¶
Green Bitmask
-
inline auto blue_bitmask() const noexcept¶
Blue Bitmask
-
inline auto alpha_bitmask() const noexcept¶
Alpha Bitmask
-
inline auto red_shift() const noexcept¶
Red Shift
-
inline auto green_shift() const noexcept¶
Green Shift
-
inline auto blue_shift() const noexcept¶
Blue Shift
-
inline auto alpha_shift() const noexcept¶
Alpha Shift
-
inline auto minus_8_num_red_bits() const noexcept¶
8 _ Number of Red Bits (always ignored)
-
inline auto minus_8_num_green_bits() const noexcept¶
8 _ Number of Green Bits (always ignored)
-
inline auto minus_8_num_blue_bits() const noexcept¶
8 _ Number of Blue Bits (always ignored)
-
inline auto minus_8_num_alpha_bits() const noexcept¶
8 _ Number of Alpha Bits (always ignored)
- inline auto() red_max () const noexcept
Red Max
- inline auto() green_max () const noexcept
Green Max
- inline auto() blue_max () const noexcept
Blue Max
- inline auto() alpha_max () const noexcept
Alpha Max
-
inline auto num_red_bits() const noexcept¶
Part 3¶
Total Size: 48 bytes
Offset (bytes) |
Size (bytes) |
Name |
Description |
|---|---|---|---|
0 |
4 |
m_color_key_array_flag |
Color Key Array Flag |
4 |
4 |
m_runtime_data_2 |
Runtime Data 2 |
8 |
4 |
m_reference_alpha |
Reference Alpha |
12 |
4 |
m_runtime_data_3 |
Runtime Data 3 |
16 |
4 |
m_unknown_6 |
Unknown 6 |
20 |
4 |
m_palette_index |
Palette Index (Runtime Data) |
24 |
4 |
m_runtime_data_4 |
Runtime Data 4 |
28 |
4 |
m_runtime_data_5 |
Runtime Data 5 |
32 |
4 |
m_unknown_7 |
Unknown 7 |
36 |
4 |
m_unknown_8 |
Unknown 8 |
40 |
4 |
m_unknown_9 |
Unknown 9 |
44 |
4 |
m_unknown_10 |
Unknown 10 |
-
struct TexHeader2¶
texHeader2 contains extra values
Public Functions
-
inline auto color_key_array_flag() const noexcept¶
Color Key Array Flag
-
inline auto runtime_data_2() const noexcept¶
Runtime Data 2
-
inline auto reference_alpha() const noexcept¶
Reference Alpha
-
inline auto runtime_data_3() const noexcept¶
Runtime Data 3
-
inline auto unknown_6() const noexcept¶
Unknown 6
-
inline auto palette_index() const noexcept¶
Palette Index (Runtime Data)
-
inline auto runtime_data_4() const noexcept¶
Runtime Data 4
-
inline auto runtime_data_5() const noexcept¶
Runtime Data 5
-
inline auto unknown_7() const noexcept¶
Unknown 7
-
inline auto unknown_8() const noexcept¶
Unknown 8
-
inline auto unknown_9() const noexcept¶
Unknown 9
-
inline auto unknown_10() const noexcept¶
Unknown 10
-
inline auto color_key_array_flag() const noexcept¶
Part 4 - Tex version 2 only¶
Total Size: 4 bytes
Offset (bytes) |
Size (bytes) |
Name |
Description |
|---|---|---|---|
0 |
4 |
m_unknown_11 |
Unknown 11 (TEX version 2 only) |
Palette¶
This contains the 32-bit BGRA values of colors organized in cols and rows.
Image¶
8 bpp¶
This contains the 8-bit color keys in cols and rows. You reference the Palette to get the color. Max 256
colors.
16 bpp¶
This contains the 16-bit ABGR values of colors organized in cols and rows.
32 bpp¶
This contains the 32-bit BGRA values of colors organized in cols and rows.