Expand description
ctt — a texture compression and conversion library.
§Quick start
ⓘ
use ctt::{convert, ConvertSettings, Container, TargetFormat, Format, Image, Surface, ColorSpace, AlphaMode, TextureKind};
use ctt::encoders::Encoder;
let surface = Surface {
data: pixel_bytes,
width: 512,
height: 512,
depth: 1,
stride: 512 * 4,
slice_stride: 0,
format: Format::R8G8B8A8_UNORM,
color_space: ColorSpace::Srgb,
alpha: AlphaMode::Straight,
};
let image = Image {
surfaces: vec![vec![surface]],
kind: TextureKind::Texture2D,
};
let ktx2_bytes = convert(image, ConvertSettings {
format: Some(TargetFormat::Compressed {
format: Format::BC7_UNORM_BLOCK,
encoder: Encoder::Auto,
}),
container: Container::ktx2(),
..Default::default()
})?;Use parse_format to build a TargetFormat from a string like "bc7",
"intel_bc7", or "rgba8unorm".
Modules§
Structs§
- Convert
Settings - Settings for the high-level
convertfunction. - Format
- Vulkan
VkFormatvalues for the texture’s texel format. - Image
- Multi-layer, multi-mip image.
- Surface
- A single image surface — either raw pixels or compressed blocks.
- Swizzle
- A 4-component swizzle pattern.
Enums§
- Alpha
Mode - Channel
Kind - Channel data type for uncompressed formats.
- Color
Space - Color space metadata for a surface.
- Container
- Output container format.
- Cubemap
Input - Input for cubemap face extraction.
- Error
- Ktx2
Supercompression - Supercompression to apply when writing KTX2 files.
- Mipmap
Filter - Filter types for mipmap downsampling.
- Pipeline
Output - Output of
crate::convert::convert. - Quality
- Universal quality preset all encoders understand.
- Swizzle
Channel - A single channel source for swizzling.
- Target
Format - The target format for a conversion operation.
- Texture
Kind - Texture topology — distinguishes 2D, cubemap, and 3D textures.
Traits§
Functions§
- convert
- Convert an image.
- format_
short_ name - Short display name for a compressed format (used in encoder listings).
- parse_
format - Parse a format string that may be compressed or uncompressed.
- split_
cubemap - Split a cubemap input into its 6 individual faces.