TEX file

TEX

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.

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.

inline TexHeader tex_header() const noexcept

Get the TexHeader object.

Returns:

A TexHeader object.

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.