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
impl CompressorImageRef
Sourcepub fn invalidate(&mut self)
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.)
Sourcepub fn resize(&mut self, width: u32, height: u32)
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
Sourcepub fn resize_with_pitch(&mut self, width: u32, height: u32, pitch: u32)
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
Sourcepub fn init(&mut self, data: &[u8], width: u32, height: u32, channel_count: u8)
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)
Sourcepub fn pixel_at(&self, width: u32, height: u32) -> Option<ColorU8>
pub fn pixel_at(&self, width: u32, height: u32) -> Option<ColorU8>
Returns the pixel value at a given x,y
Sourcepub unsafe fn pixel_at_unchecked(&self, width: u32, height: u32) -> ColorU8
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
Sourcepub fn pitch(&self) -> u32
pub fn pitch(&self) -> u32
Returns the pitch of the image in pixels, which represents the offset between rows
Sourcepub fn total_pixels(&self) -> u32
pub fn total_pixels(&self) -> u32
Returns the total number of pixels in the image
Sourcepub fn block_width(&self, w: u32) -> u32
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
Sourcepub fn block_height(&self, h: u32) -> u32
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
Sourcepub fn total_blocks(&self, w: u32, h: u32) -> u32
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
Sourcepub fn pixel_data_mut(&mut self) -> &mut [ColorU8]
pub fn pixel_data_mut(&mut self) -> &mut [ColorU8]
Returns a mutable reference to the pixel data as a slice of ColorU8
Sourcepub fn pixel_data_u8_mut(&mut self) -> &mut [u8] ⓘ
pub fn pixel_data_u8_mut(&mut self) -> &mut [u8] ⓘ
Returns a mutable reference to the pixel data as a slice of u8
Sourcepub fn pixel_data_u32_mut(&mut self) -> &mut [u32]
pub fn pixel_data_u32_mut(&mut self) -> &mut [u32]
Returns a mutable reference to the pixel data as a slice of u32