pub struct Header {
pub format: Option<Format>,
pub type_size: u32,
pub pixel_width: u32,
pub pixel_height: u32,
pub pixel_depth: u32,
pub layer_count: u32,
pub face_count: u32,
pub level_count: u32,
pub supercompression_scheme: Option<SupercompressionScheme>,
pub index: Index,
}Expand description
Container-level metadata (dimensions, format, layout) from the 80-byte KTX2 file header.
Fields§
§format: Option<Format>Vulkan VkFormat enum value. None means VK_FORMAT_UNDEFINED,
used for supercompressed universal formats (e.g. Basis Universal)
where the actual format is determined at transcode time.
type_size: u32Size in bytes of the data type used for GPU upload, for endian conversion on big-endian systems (all image data in KTX2 is little-endian).
Must be 1 when format is None (VK_FORMAT_UNDEFINED) or for
block-compressed formats (_BLOCK suffix). For packed formats
(_PACKxx), equals the byte size of the packed unit xx / 8
(e.g. 4 for _PACK32). For unpacked formats, equals the byte size
of a single component (e.g. 2 for R16G16B16_UNORM). For combined
depth/stencil: 2 for D16_UNORM_S8_UINT, 4 for all others.
pixel_width: u32Texture width in texels. Always non-zero.
pixel_height: u32Texture height in texels. 0 for 1D textures.
pixel_depth: u32Texture depth in texels. 0 for non-3D textures.
layer_count: u32Number of array layers. 0 means a non-array texture (1 implicit
layer). Use layer_count.max(1) when allocating storage.
face_count: u32Number of cubemap faces. 6 for cubemaps, 1 otherwise.
level_count: u32Number of mip levels. 0 means the full mip chain should be
generated from level 0 by the application if needed.
Use level_count.max(1) when iterating stored levels.
supercompression_scheme: Option<SupercompressionScheme>Compression applied to mip level data. None means uncompressed.
When set, each Level::data must be decompressed before use.
index: IndexRaw byte offsets/lengths for the DFD, KVD, and SGD sections.
For most use cases, prefer Reader::dfd_blocks,
Reader::key_value_data, and
Reader::supercompression_global_data instead.
Implementations§
Source§impl Header
impl Header
Sourcepub const LENGTH: usize = 80
pub const LENGTH: usize = 80
Size of the KTX2 header in bytes (12-byte magic + 68-byte fields).
Sourcepub fn from_bytes(data: &[u8; 80]) -> Result<Self, ParseError>
pub fn from_bytes(data: &[u8; 80]) -> Result<Self, ParseError>
Decode a header from exactly 80 bytes. Validates the magic bytes and
rejects zero pixel_width or zero face_count.