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
impl BitmapImage
§impl BitmapImage
impl BitmapImage
pub fn create_empty(
domain: &Domain,
width: u32,
height: u32,
format: GraphicsFormat,
name: impl AsRef<KanziStr>,
) -> Result<BitmapImage, Error>
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>
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>
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_by_mipmap_level(&self, mipmap_level: u64) -> Result<u32, Error>
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>
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>
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>
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>
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>
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>
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>
pub fn premultiply_alpha(&self) -> Result<(), Error>
Premultiplies the color and luminance channels by the alpha channel.