basis_universal::encoding

Struct CompressorImageRef

Source
pub struct CompressorImageRef(pub *mut basisu_image);
Expand description

A reference to an image being stored by CompressorParams. Generally used to insert the source data that is to be encoded by a Compressor.

Tuple Fields§

§0: *mut basisu_image

Implementations§

Source§

impl CompressorImageRef

Source

pub fn invalidate(&mut self)

Sets the image to be completely empty (i.e. 0 width, 0 height). (This was called clear in the upstream API.)

Source

pub fn resize(&mut self, width: u32, height: u32)

Resizes the image to the given width/height

By default the pitch will be equal to the width. To customize this, use resize_with_pitch

Source

pub fn resize_with_pitch(&mut self, width: u32, height: u32, pitch: u32)

Resize the image to the given width/height with a custom “pitch”. The pitch is the offset between rows and is not needed for all formats. By default, the pitch will be equal to the width

Source

pub fn init(&mut self, data: &[u8], width: u32, height: u32, channel_count: u8)

Resize the image and populate it with the given data.

channel_count should be the number of channels in the image (so >=1 and <= 4)

Source

pub fn pixel_at(&self, width: u32, height: u32) -> Option<ColorU8>

Returns the pixel value at a given x,y

Source

pub unsafe fn pixel_at_unchecked(&self, width: u32, height: u32) -> ColorU8

Returns teh pixel value at a given x,y without doing bounds checking

§Safety

Accessing pixel out of bounds of the image will result in undefined behavior

Source

pub fn width(&self) -> u32

Returns the width of the image in pixels

Source

pub fn height(&self) -> u32

Returns the height of the image in pixels

Source

pub fn pitch(&self) -> u32

Returns the pitch of the image in pixels, which represents the offset between rows

Source

pub fn total_pixels(&self) -> u32

Returns the total number of pixels in the image

Source

pub fn block_width(&self, w: u32) -> u32

Returns how many blocks wide the image is, given w, the width of a block in pixels

Source

pub fn block_height(&self, h: u32) -> u32

Returns how many blocks high the image is, given h, the height of a block in pixels

Source

pub fn total_blocks(&self, w: u32, h: u32) -> u32

Returns the number of blocks required to store the image, given w and h, the width and height of a block in pixels

Source

pub fn pixel_data_mut(&mut self) -> &mut [ColorU8]

Returns a mutable reference to the pixel data as a slice of ColorU8

Source

pub fn pixel_data_u8_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the pixel data as a slice of u8

Source

pub fn pixel_data_u32_mut(&mut self) -> &mut [u32]

Returns a mutable reference to the pixel data as a slice of u32

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.