Struct BitmapImage

pub struct BitmapImage(/* private fields */);
Expand description

Image is the basic runtime primitive to load, hold, and convert image data in memory. Each image has width, height, pixel format, image data in memory, and can contain mipmap images.

To display an image, you must create a texture instance from that image. When you do so, you must transfer the ownership of the image to the texture instance using TextureCreateInfo.

Implementations§

§

impl BitmapImage

pub const fn as_ptr(&self) -> *mut BitmapImageWrapper

pub fn get_native(&self) -> Result<NonNull<c_void>, Error>

Gets a pointer to the backing C++ instance.

§

impl BitmapImage

pub fn create_empty( domain: &Domain, width: u32, height: u32, format: GraphicsFormat, name: impl AsRef<KanziStr>, ) -> Result<BitmapImage, Error>

Creates a new empty image.

pub fn create_from_memory( domain: &Domain, width: u32, height: u32, format: GraphicsFormat, data: &[u8], name: impl AsRef<KanziStr>, ) -> Result<BitmapImage, Error>

Creates a new image from the data slice.

§Errors

Returns an INVALID_ARGUMENT error if the length of the data slice isn’t equal to the value returned by ::kanzi::getDataSizeBytes(width, height, format) C++ function.

pub unsafe fn create_from_memory_unchecked( domain: &Domain, width: u32, height: u32, format: GraphicsFormat, data: &[u8], name: impl AsRef<KanziStr>, ) -> Result<BitmapImage, Error>

Creates a new image from the data slice.

§Safety

The caller must ensure that the length of the data slice is equal to the value returned by ::kanzi::getDataSizeBytes(width, height, format) C++ function.

pub fn get_width(&self) -> Result<u32, Error>

Returns the width of an image in pixels.

pub fn get_width_by_mipmap_level(&self, mipmap_level: u64) -> Result<u32, Error>

Returns the width of a an image in pixels at specific mipmap level.

§Arguments
  • mipmap_level - The wanted mipmap level, 0 being base level.
§Errors

Returns an INDEX_OUT_OF_BOUNDS error if the specified mipmap level exceeds the total number of available mipmap levels.

pub fn get_height(&self) -> Result<u32, Error>

Returns the height of an image in pixels.

pub fn get_height_by_mipmap_level( &self, mipmap_level: u64, ) -> Result<u32, Error>

Returns the height of a an image in pixels at specific mipmap level.

§Arguments
  • mipmap_level - The wanted mipmap level, 0 being base level.
§Errors

Returns an INDEX_OUT_OF_BOUNDS error if the specified mipmap level exceeds the total number of available mipmap levels.

pub fn reset_data( &self, new_width: u32, new_height: u32, new_format: GraphicsFormat, ) -> Result<(), Error>

Resets an image with a new width, height, and data format. This function discards the current image data.

§Arguments
  • new_width - New width of the image in pixels.
  • new_height - New height of the image in pixels.
  • new_format - New pixel format for the image.

pub fn get_data_format(&self) -> Result<GraphicsFormat, Error>

Returns the pixel data format of an image.

pub fn get_data(&self) -> Result<Vec<u8>, Error>

Returns a vector containing the copy of the image data in memory.

pub fn get_mipmap_level_count(&self) -> Result<u64, Error>

Returns the count of mipmap levels held by this image. For the images that have only the base level and no mipmaps, the level count is 1. This function never returns 0.

pub fn premultiply_alpha(&self) -> Result<(), Error>

Premultiplies the color and luminance channels by the alpha channel.

Trait Implementations§

§

impl Drop for BitmapImage

§

fn drop(&mut self)

Executes the destructor for this type. Read more

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
§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

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.

§

impl<T> Inherits<T> for T

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

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.