Texture index format

The armaio.texheaders module provides support for reading and also writing the format used by the texHeaders.bin texture index file. The implementations are based on the information on the Community Wiki texHeaders.bin page.

Examples

Reading

from armaio.texheaders import TexHeadersFile

data = TexHeadersFile.read_file("texHeaders.bin")
for tex in data.textures:
    print(f"{tex.path} ({tex.mipmaps[0].width} x {tex.mipmaps[0].height})")

Creating

from armaio.texheaders import TexHeadersFile

data = TexHeadersFile.from_directory(
    "pbo/directory",
    strict=True
)
data.write_file("texHeaders.bin")

Exceptions

class armaio.texheaders.TexHeadersError

Exception raised upon TexHeaders file errors.

Enumerations

class armaio.texheaders.TexHeadersTextureFormat(*values)

Pixel color encoding.

ARGB1555 = 3

5-bit RGB channels with 1-bit alpha.

ARGB4444 = 4

4-bit RGBA channels.

ARGB8888 = 5

8-bit RGBA channels.

DXT1 = 6

S3TC BC1/DXT1 compressed.

DXT2 = 7

S3TC BC2/DXT2 compressed with premultiplied alpha.

DXT3 = 8

S3TC BC2/DXT3 compressed.

DXT4 = 9

S3TC BC3/DXT4 compressed with premultiplied alpha.

DXT5 = 10

S3TC BC3/DXT5 compressed.

GRAY = 1

8-bit gray with 8-bit alpha.

INDEXED = 0

Palette indexed.

RGB565 = 2

5-bit red and green channels with 6-bit green channel.

class armaio.texheaders.TexHeadersTextureSuffix(*values)

Texture suffix type.

DETAIL = 2

Detail texture in linear space (_dt, _cdt, etc.).

DETAIL_SPECULAR = 11

Detail specular map (_dtsmdi).

DIFFUSE = 0

Diffuse color in sRGB space.

DIFFUSE_LINEAR = 1

Diffuse color in linear space (_sky, _lco, etc.).

DITHERING = 10

Dithering map.

IRRADIANCE = 4

Irradiance map.

MACRO = 7

Macro overlay texture in sRGB space (_mc, etc.).

MASK = 12

Multi material mask (_mask).

NORMAL = 3

Normal map.

RANDOM = 5

Random or procedural values.

SHADOW = 8

Ambient shadow map (_as, etc.).

SPECULAR = 9

Specular map (_sm, _smdi, etc.).

THERMAL = 13

Thermal imaging texture (_ti).

TREECROWN = 6

Treecrown texture.

Classes

class armaio.texheaders.TexHeadersColor(red: _T, green: _T, blue: _T, alpha: _T)

RGBA color value.

Create new instance of TexHeadersColor(red, green, blue, alpha)

alpha: _T

Alpha value.

blue: _T

Blue value.

green: _T

Green value.

red: _T

Red value.

class armaio.texheaders.TexHeadersMipmap(width: int, height: int, format: TexHeadersTextureFormat, offset: int)

Texture mipmap record.

classmethod read(stream: IO[bytes]) Self

Reads a mipmap record from a binary stream.

Parameters:

stream (IO[bytes]) – Source binary stream

Returns:

Mipmap data

Return type:

Self

write(stream: IO[bytes]) None

Writes a mipmap record to a binary stream.

Parameters:

stream (IO[bytes]) – Target binary stream

format: TexHeadersTextureFormat

Pixel color encoding.

height: int

Texture height.

offset: int

Byte offset to mipmap in texture file.

width: int

Texture width.

class armaio.texheaders.TexHeadersRecord(color_average_float: TexHeadersColor[float], color_average: TexHeadersColor[int], color_max: TexHeadersColor[int], maxcolor_defined: bool, alpha_interpolated: bool, alpha_binary: bool, non_opaque: bool, format: TexHeadersTextureFormat, is_paa: bool, path: str, suffix: TexHeadersTextureSuffix, mipmaps: tuple[TexHeadersMipmap, ...], filesize: int)

Texture data record.

classmethod from_paa(filepath: str | PathLike[str], root: str | PathLike[str], paa: PaaFile) Self

Creates a texture record from PAA data.

Parameters:
  • filepath (StrPath) – Path to the PAA file

  • root (StrPath) – Path to root texture index file

  • paa (PaaFile) – Texture data

Raises:

TexHeadersError – PAA data did not contain the necessary data

Returns:

Texture record

Return type:

Self

classmethod read(stream: IO[bytes]) Self

Reads a texture record from a binary stream.

Parameters:

stream (IO[bytes]) – Source binary stream

Raises:

TexHeadersError – Color palette indexed file data was found

Returns:

Texture data

Return type:

Self

write(stream: IO[bytes]) None

Writes a texture record to a binary stream.

Parameters:

stream (IO[bytes]) – Target binary stream

alpha_binary: bool

Alpha channel is not interpolated, simple transparency.

alpha_interpolated: bool

Alpha channel is interpolated for smooth transparency.

color_average: TexHeadersColor[int]

8-bit average texture color.

color_average_float: TexHeadersColor[float]

Float encoded average texture color.

color_max: TexHeadersColor[int]

8-bit maximum texture color.

filesize: int

File size in bytes.

format: TexHeadersTextureFormat

Pixel color encoding.

is_paa: bool

File is a PAA (not PAC).

maxcolor_defined: bool

Texture has maximum color TAGG.

mipmaps: tuple[TexHeadersMipmap, ...]

Mipmap records.

non_opaque: bool

Interpolated alpha and average alpha is below 127.

path: str

Path to texture file relative to texHeaders.bin file.

suffix: TexHeadersTextureSuffix

Texture type.

class armaio.texheaders.TexHeadersFile

Texture index file.

classmethod from_directory(dirpath: str | PathLike[str], *, strict: bool = False, ignore_dirs: str | None = '^[\\._].*$') Self

Iterates the contents of a directory recursively, and creates a texture index from the PAA files found within.

Parameters:
  • dirpath (StrPath) – Path to directory

  • strict (bool, optional) – Stop on internal errors, defaults to False

  • ignore_dirs (str | None, optional) – Regex pattern to ignore unwanted (eg. hidden) directories, defaults to r"^[\._].*$"

Raises:

Exception – An error occured while processing a file

Returns:

New texture index

Return type:

Self

classmethod read(stream: IO[bytes]) Self

Reads texture index data from a binary stream.

Parameters:

stream (IO[bytes]) – Source binary stream

Raises:

TexHeadersError – Invalid or unsupported file

Returns:

Texture index data

Return type:

Self

classmethod read_file(filepath: str | PathLike[str] | bytes | PathLike[bytes]) Self

Reads texture index data from a texHeaders.bin file.

Parameters:

filepath (StrOrBytesPath) – Path to texHeaders.bin file

Returns:

Texture index data

Return type:

Self

add_texture(tex: TexHeadersRecord) None

Adds texture record to texture index.

Parameters:

tex (TexHeadersRecord) – Record to add

Raises:

ValueError – Path already recorded

pop_texture(idx: int) TexHeadersRecord

Remove and return the record at the given index.

Parameters:

idx (int) – Index to remove

Returns:

Removed record

Return type:

TexHeadersRecord

write(stream: IO[bytes]) None

Writes texture index data to a binary stream.

Parameters:

stream (IO[bytes]) – Target binary stream

write_file(filepath: str | PathLike[str] | bytes | PathLike[bytes]) None

Writes texture index data to a file.

Parameters:

filepath (StrOrBytesPath) – Path to target file

property source: str | bytes | None
Returns:

Path to source file (None if not read from file)

Return type:

str | bytes | None

property textures: tuple[TexHeadersRecord, ...]
Returns:

Texture records

Return type:

tuple[TexHeadersRecord, …]