Skip to main content

ImageFile

Struct ImageFile 

Source
pub struct ImageFile {
    pub id: ImageId,
    pub bytes: Vec<u8>,
    pub width: u32,
    pub height: u32,
    pub pixels: Arc<Vec<u8>>,
    pub pixels_width: u32,
    pub pixels_height: u32,
}
Expand description

A decoded image file: its bytes, its own size, and the pixels it is drawn from — the file’s own, or resampled to at most MAX_IMAGE_SIDE a side.

Fields§

§id: ImageId§bytes: Vec<u8>§width: u32

The file’s size in pixels: what an Image hugs by.

§height: u32§pixels: Arc<Vec<u8>>

Straight-alpha RGBA, pixels_width × pixels_height.

§pixels_width: u32§pixels_height: u32

Implementations§

Source§

impl ImageFile

Source

pub fn new(bytes: Vec<u8>) -> Result<ImageFile, String>

Decodes bytes, a PNG or JPEG file, or says why it can’t.

Source

pub fn with_id(id: ImageId, bytes: Vec<u8>) -> Result<ImageFile, String>

Decodes bytes, already known to be the file id.

Source

pub fn image_data(&self) -> ImageData

The pixels as an image for one drawing to paint, under a blob of its own that shares the pixels: see render::Renderer::drawing.

Trait Implementations§

Source§

impl Debug for ImageFile

Source§

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

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

impl PartialEq for ImageFile

Image files compare by their identity, which is their bytes.

Source§

fn eq(&self, other: &ImageFile) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. 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> ErasedDestructor for T
where T: 'static,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.