pub struct BasisuEncoder { /* private fields */ }encoder and extra only.Expand description
Encoder that used to compress SourceImage to basis universal ktx2 file.
Implementations§
Source§impl BasisuEncoder
impl BasisuEncoder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a encoder. Panic if basisu_encoder_init hasn’t been called.
Sourcepub fn set_image(
&mut self,
image: SourceImage<'_>,
) -> Result<(), BasisuEncodeError>
pub fn set_image( &mut self, image: SourceImage<'_>, ) -> Result<(), BasisuEncodeError>
Set the input image of the encoder and clear other image set before.
All the layers of the image will be set. To compress it as a cubemap or texture array,
you will need to add flag to BasisuEncoderParams::flags_and_quality by calling BasisuEncoderParams::with_tex_type.
If you already have continuous data for the cubemap or texture array, this should be faster than Self::set_image_slice .
Sourcepub fn clear_image(&mut self)
pub fn clear_image(&mut self)
Clear the input image of encoder that was set.
Sourcepub fn set_image_slice(
&mut self,
index: u32,
image: SourceImage<'_>,
) -> Result<(), BasisuEncodeError>
pub fn set_image_slice( &mut self, index: u32, image: SourceImage<'_>, ) -> Result<(), BasisuEncodeError>
Set a image slice at index. Other image set before is not cleared.
After set all the layers of the image, to compress it as a cubemap or texture array,
you will need to add flag to BasisuEncoderParams::flags_and_quality by calling BasisuEncoderParams::with_tex_type.
The input image array layer count must be 1, otherwise an error will be returned.
If you already have continuous data for the cubemap or texture array, Self::set_image should faster.
Sourcepub fn compress(
&mut self,
params: BasisuEncoderParams,
) -> Result<Vec<u8>, BasisuEncodeError>
pub fn compress( &mut self, params: BasisuEncoderParams, ) -> Result<Vec<u8>, BasisuEncodeError>
Compress the inputted image and return the bytes of ktx2 file result.