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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.