Module dds

Module dds 

Source
Expand description

DDS texture-container support. DDS (DirectDraw Surface) reader and writer.

This module provides container-level support for KotOR-era DDS files. Parsing and serialization are backed by ddsfile, but the public API is kept focused on D3D9-era headers and formats that KotOR actually uses.

§KotOR Notes

  • Reader support includes:
    • standard DDS containers (D3D9-era headers; canonical compressed formats are DXT1/DXT5).
    • a CResDDS prefix-header container variant used by vanilla resource paths.
  • Canonical KotOR compressed paths currently target DXT1 and DXT5.
  • Writer support currently emits standard DDS containers only.

§Format Layout

Standard DDS:
+------------------------------+ 0x0000
| Magic "DDS " (4 bytes)      |
+------------------------------+
| Header (124 bytes)           |
+------------------------------+
| Surface payload bytes        |
+------------------------------+

CResDDS prefix-header variant:
+------------------------------+ 0x0000
| Prefix metadata (20 bytes)   |
+------------------------------+
| Surface payload bytes        |
+------------------------------+

Prefix metadata layout (`0x14` bytes):
- `+0x00` `u32`: width
- `+0x04` `u32`: height
- `+0x08` `u8`: bytes-per-pixel code
- `+0x09..+0x0B`: reserved gap bytes
- `+0x0C` `u32`: base-level payload size
- `+0x10` `f32`: alpha-mean metadata float

Structs§

CResDdsHeader
Parsed CResDDS prefix metadata header.
Dds
In-memory DDS container.

Enums§

DdsBinaryError
Errors produced while parsing or serializing DDS data.
DdsSourceFlavor
DDS source container flavor.

Functions§

read_dds
Reads DDS data from a reader.
read_dds_from_bytes
Reads DDS data from bytes.
write_dds
Writes DDS data to a writer.
write_dds_to_vec
Serializes DDS data to a byte vector.

Type Aliases§

DdsCaps2
DDS caps2 bitflag re-export.
DdsD3dFormat
DDS D3D-format enum re-export.
DdsNewD3dParams
Constructor parameter set for D3D-style DDS creation.