Skip to main content

ImageSource

Trait ImageSource 

Source
pub trait ImageSource: Any {
    // Required methods
    fn mime_type(&self) -> String;
    fn size(&self) -> Size;
    fn pictures(&self) -> ImagePictures;
    fn orientation(&self) -> ImageOrientation;
    fn metadata(&self) -> ImageMetadata;
    fn decode_pixels(
        &self,
        index: u32,
        max_size: Option<Size>,
    ) -> ImageFuture<PixelBuffer>;
}
Expand description

An image opened by the system’s codecs from its encoded bytes, as Apple’s CGImageSource and Android’s ImageDecoder.Source are: what it says of itself, read as it opened, and its pictures decoded as the app asks for them. A picture it does not have fails, as ImageErrorKind::Other.

A host gets its own type back from an image it is given by downcasting through Any.

Required Methods§

Source

fn mime_type(&self) -> String

Its format’s MIME type, one of the ImageCodecs::decoded_formats.

Source

fn size(&self) -> Size

Its size in pixels, upright, as its primary picture decodes at full size: a still image’s one, an animation’s frames, which all share it, or a document’s primary page.

Source

fn pictures(&self) -> ImagePictures

How its pictures go: one still picture, the frames of an animation, or the pages of a document.

Source

fn orientation(&self) -> ImageOrientation

How the file stores its primary picture turned from upright. It is decoded upright, and size is upright, so an app reads it to show it or to keep it.

Source

fn metadata(&self) -> ImageMetadata

What the file says of how its primary picture was taken.

Source

fn decode_pixels( &self, index: u32, max_size: Option<Size>, ) -> ImageFuture<PixelBuffer>

Picture index in the app’s memory, upright, scaled down to fit max_size, in pixels, keeping its shape, where given; in a layout the system picks, which the buffer names. The index is 0 for a still image, a frame’s for an animation and a page’s for a document (pictures).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§