pub struct Ktx2<'a, 'b: 'a> { /* private fields */ }
Expand description
KTX2-specific Texture
functionality.
Implementations§
Source§impl<'a, 'b: 'a> Ktx2<'a, 'b>
impl<'a, 'b: 'a> Ktx2<'a, 'b>
Sourcepub fn handle(&self) -> *mut ktxTexture2
pub fn handle(&self) -> *mut ktxTexture2
Returns a pointer to the underlying (C-allocated) sys::ktxTexture2
.
SAFETY: Pointers are harmless. Dereferencing them is not!
Sourcepub fn vk_format(&self) -> u32
pub fn vk_format(&self) -> u32
Returns the Vulkan format of the texture’s data (e.g. VK_R8G8B8A8_UNORM
).
Sourcepub fn supercompression_scheme(&self) -> SuperCompressionScheme
pub fn supercompression_scheme(&self) -> SuperCompressionScheme
Returns the supercompression scheme in use for this texture’s data.
Sourcepub fn duration(&self) -> u32
pub fn duration(&self) -> u32
Returns the duration of the video texture (if Self::is_video
).
Sourcepub fn timescale(&self) -> u32
pub fn timescale(&self) -> u32
Returns the timescale of the video texture (if Self::is_video
).
Sourcepub fn loop_count(&self) -> u32
pub fn loop_count(&self) -> u32
Returns the loop count of the video texture (if Self::is_video
).
Sourcepub fn needs_transcoding(&self) -> bool
pub fn needs_transcoding(&self) -> bool
Will this KTX2 need transcoding?
Sourcepub fn compress_basis(&mut self, quality: u32) -> Result<(), KtxError>
pub fn compress_basis(&mut self, quality: u32) -> Result<(), KtxError>
Compresses a uncompressed KTX2 texture with Basis Universal.
quality
is 1-255; 0 -> the default quality, 128. Lower quality
means better (but slower) compression.
Sourcepub fn deflate_zstd(&mut self, level: u32) -> Result<(), KtxError>
pub fn deflate_zstd(&mut self, level: u32) -> Result<(), KtxError>
Compresses the KTX2 texture’s data with ZStandard compression.
level
is 1-22; lower is faster (hence, worse compression).
Values over 20 may consume significant memory.
Sourcepub fn compress_astc(&mut self, quality: u32) -> Result<(), KtxError>
pub fn compress_astc(&mut self, quality: u32) -> Result<(), KtxError>
Compresses the KTX2’s image data with ASTC.
This is a simplified version of Ktx2::compress_astc_ex
.
Sourcepub fn compress_astc_ex(&mut self, params: AstcParams) -> Result<(), KtxError>
pub fn compress_astc_ex(&mut self, params: AstcParams) -> Result<(), KtxError>
Compresses the KTX2’s image data with ASTC.
This is an extended version of Ktx2::compress_astc
.
Sourcepub fn component_info(&self) -> (u32, u32)
pub fn component_info(&self) -> (u32, u32)
Returns the number of components of the KTX2 and the size in bytes of each components.
Sourcepub fn num_components(&self) -> u32
pub fn num_components(&self) -> u32
Returns the number of components of the KTX2, also considering compression.
This may differ from values returned by Self::component_info
:
- For uncompressed formats: this is the number of image components, as from
Self::component_info
. - For block-compressed formats: 1 or 2, according to the DFD color model.
- For Basis Universal-compressed textures: obtained by parsing channel IDs before any encoding and deflation.
Sourcepub fn oetf(&self) -> u32
pub fn oetf(&self) -> u32
Returns the Opto-Electrical Transfer Function (OETF) for this KTX2, in KHR_DF format.
See https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.inline.html#_emphasis_role_strong_emphasis_transferfunction_emphasis_emphasis.
Sourcepub fn premultiplied_alpha(&self) -> bool
pub fn premultiplied_alpha(&self) -> bool
Does this KTX2 have premultiplied alpha?
Sourcepub fn transcode_basis(
&mut self,
format: TranscodeFormat,
flags: TranscodeFlags,
) -> Result<(), KtxError>
pub fn transcode_basis( &mut self, format: TranscodeFormat, flags: TranscodeFlags, ) -> Result<(), KtxError>
Transcodes this KTX2 to the given format by using ETC1S (from Basis Universal) or UASTC.
- BasisLZ supercompressed textures are turned back to ETC1S, then transcoded.
- UASTC-compressed images are inflated (possibly, even deflating any ZStandard supercompression), then transcoded.
- All internal data of the texture may change, including the DFD!