basis_universal::encoding

Struct Compressor

Source
pub struct Compressor(pub *mut Compressor);
Expand description

Used to encode raw image data to basis-universal form

Tuple Fields§

§0: *mut Compressor

Implementations§

Source§

impl Compressor

Source

pub fn new(total_thread_count: u32) -> Self

total_thread_count is passed directly to basisu::job_pool total_thread_count is the TOTAL number of job pool threads, including the calling thread! So 2=1 new thread, 3=2 new threads, etc.

Call encoder_init

Source

pub unsafe fn init(&mut self, params: &CompressorParams) -> bool

Configure the compressor to compress images. CompressorParams includes both the image data and parameters that affect compression (such as quality or whether mipmaps should be generated)

§Safety

Passing invalid parameters may cause undefined behavior. (The underlying C++ library does not thoroughly validate parameters)

Source

pub unsafe fn process(&mut self) -> Result<(), CompressorErrorCode>

Encodes the images as configured when calling init()

§Safety

Compressing with invalid parameters may cause undefined behavior. (The underlying C++ library does not thoroughly validate parameters)

Source

pub fn basis_file(&self) -> &[u8]

Access the compressed data. May be empty if process() was not yet called

Source

pub fn basis_file_size(&self) -> u32

Return the size of the encoded basis-universal data

Source

pub fn bits_per_texel(&self) -> f64

Returns the number of bits required per texel

Source

pub fn any_source_image_has_alpha(&self) -> bool

Returns if any source image has alpha

Trait Implementations§

Source§

impl Default for Compressor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Compressor

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Compressor

Auto Trait Implementations§

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.