Skip to main content

Image

Trait Image 

Source
pub trait Image {
    // Required method
    unsafe fn as_bytes(&self) -> &[u8];

    // Provided methods
    fn sub(&self, p: Point, s: Size) -> SubImage<'_> { ... }
    fn transparency(&self) -> Color { ... }
    fn pixels(&self) -> usize { ... }
    fn width(&self) -> u16 { ... }
    fn height(&self) -> u16 { ... }
    fn size(&self) -> Size { ... }
}
Expand description

A loaded image file.

Required Methods§

Source

unsafe fn as_bytes(&self) -> &[u8]

Get the raw image representation.

§Safety

Don’t use it. The internal image representation might change in the future and so should not be relied upon.

Provided Methods§

Source

fn sub(&self, p: Point, s: Size) -> SubImage<'_>

Get a rectangle subregion of the image.

Source

fn transparency(&self) -> Color

The color used for transparency. If no transparency, returns Color::None.

Source

fn pixels(&self) -> usize

The number of pixels the image has.

Source

fn width(&self) -> u16

The image width in pixels.

Source

fn height(&self) -> u16

The image height in pixels.

Source

fn size(&self) -> Size

The image size in pixels.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Image for ImageBuf

Available on crate feature alloc only.
Source§

impl Image for ImageRef<'_>

Source§

impl<T: Canvas> Image for T