Struct basis_universal::encoding::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_imageImplementations§
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