Struct Ktx2

Source
pub struct Ktx2<'a, 'b: 'a> { /* private fields */ }
Expand description

KTX2-specific Texture functionality.

Implementations§

Source§

impl<'a, 'b: 'a> Ktx2<'a, 'b>

Source

pub fn handle(&self) -> *mut ktxTexture2

Returns a pointer to the underlying (C-allocated) sys::ktxTexture2.

SAFETY: Pointers are harmless. Dereferencing them is not!

Source

pub fn vk_format(&self) -> u32

Returns the Vulkan format of the texture’s data (e.g. VK_R8G8B8A8_UNORM).

Source

pub fn supercompression_scheme(&self) -> SuperCompressionScheme

Returns the supercompression scheme in use for this texture’s data.

Source

pub fn is_video(&self) -> bool

Is this a video texture?

Source

pub fn duration(&self) -> u32

Returns the duration of the video texture (if Self::is_video).

Source

pub fn timescale(&self) -> u32

Returns the timescale of the video texture (if Self::is_video).

Source

pub fn loop_count(&self) -> u32

Returns the loop count of the video texture (if Self::is_video).

Source

pub fn needs_transcoding(&self) -> bool

Will this KTX2 need transcoding?

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn component_info(&self) -> (u32, u32)

Returns the number of components of the KTX2 and the size in bytes of each components.

Source

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.

See sys::ktxTexture2_GetNumComponents.

Source

pub fn oetf(&self) -> u32

Source

pub fn premultiplied_alpha(&self) -> bool

Does this KTX2 have premultiplied alpha?

Source

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!

Auto Trait Implementations§

§

impl<'a, 'b> Freeze for Ktx2<'a, 'b>

§

impl<'a, 'b> !RefUnwindSafe for Ktx2<'a, 'b>

§

impl<'a, 'b> !Send for Ktx2<'a, 'b>

§

impl<'a, 'b> !Sync for Ktx2<'a, 'b>

§

impl<'a, 'b> Unpin for Ktx2<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for Ktx2<'a, 'b>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.