pub struct PreloadedImageData {
    pub data: Cow<'static, [u8]>,
    pub width: u32,
    pub height: u32,
    pub mime: String,
}
Expand description

Use this struct to preload, decode and cache images for the upcoming rendering.

Fields§

§data: Cow<'static, [u8]>

The decoded image data. Make sure that if you submit the data directly it must be blended for semi transparent colors. Either a static slice or an owned vector. Povide a static slice that is pre-blended in case of static resource linking for rendering.

§width: u32

The width of image in pixels

§height: u32

The height of image in pixels

§mime: String

The image mime type (png/jpg)

Implementations§

source§

impl PreloadedImageData

source

pub fn blend_rgba_slice(rgba_slice: &[u8]) -> Vec<u8>

Converts raw rgba pixmap source to the rgba source with blended semi transparent colors.

source

pub fn new(mime: String, width: u32, height: u32, rgba_data: &[u8]) -> Self

Creates a new PreloadedImageData from the given rgba8 buffer and blends all the semi transparent colors.

source

pub fn new_blended( mime: String, width: u32, height: u32, rgba_data: &'static [u8] ) -> Arc<Self>

Creates a new PreloadedImageData from the given rgba8 buffer which is meant to be already blended for semi transparent colors.

You can use PreloadedImageData::blend_rgba_slice to blend the colors in advance.

Trait Implementations§

source§

impl Debug for PreloadedImageData

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for PreloadedImageData

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. 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
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.

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>,

§

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>,

§

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.