GenericImage

Trait GenericImage 

Source
pub trait GenericImage: GenericImageView {
    type InnerImage: GenericImage<Pixel = Self::Pixel>;

    // Required methods
    fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut Self::Pixel;
    fn put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel);
    fn blend_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel);
    fn inner_mut(&mut self) -> &mut Self::InnerImage;

    // Provided methods
    unsafe fn unsafe_put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel) { ... }
    fn copy_from<O>(
        &mut self,
        other: &O,
        x: u32,
        y: u32,
    ) -> Result<(), ImageError>
       where O: GenericImageView<Pixel = Self::Pixel> { ... }
    fn copy_within(&mut self, source: Rect, x: u32, y: u32) -> bool { ... }
    fn sub_image(
        &mut self,
        x: u32,
        y: u32,
        width: u32,
        height: u32,
    ) -> SubImage<&mut Self::InnerImage> { ... }
}
Expand description

A trait for manipulating images.

Required Associated Types§

Source

type InnerImage: GenericImage<Pixel = Self::Pixel>

Underlying image type. This is mainly used by SubImages in order to always have a reference to the original image. This allows for less indirections and it eases the use of nested SubImages.

Required Methods§

Source

fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut Self::Pixel

Gets a reference to the mutable pixel at location (x, y)

§Panics

Panics if (x, y) is out of bounds.

Source

fn put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel)

Put a pixel at location (x, y)

§Panics

Panics if (x, y) is out of bounds.

Source

fn blend_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel)

Put a pixel at location (x, y), taking into account alpha channels

DEPRECATED: This method will be removed. Blend the pixel directly instead.

Source

fn inner_mut(&mut self) -> &mut Self::InnerImage

Returns a mutable reference to the underlying image.

Provided Methods§

Source

unsafe fn unsafe_put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel)

Puts a pixel at location (x, y)

This function can be implemented in a way that ignores bounds checking.

Source

fn copy_from<O>(&mut self, other: &O, x: u32, y: u32) -> Result<(), ImageError>
where O: GenericImageView<Pixel = Self::Pixel>,

Copies all of the pixels from another image into this image.

The other image is copied with the top-left corner of the other image placed at (x, y).

In order to copy only a piece of the other image, use GenericImageView::view.

You can use FlatSamples to source pixels from an arbitrary regular raster of channel values, for example from a foreign interface or a fixed image.

§Returns

Returns an error if the image is too large to be copied at the given position

Source

fn copy_within(&mut self, source: Rect, x: u32, y: u32) -> bool

Copies all of the pixels from one part of this image to another part of this image.

The destination rectangle of the copy is specified with the top-left corner placed at (x, y).

§Returns

true if the copy was successful, false if the image could not be copied due to size constraints.

Source

fn sub_image( &mut self, x: u32, y: u32, width: u32, height: u32, ) -> SubImage<&mut Self::InnerImage>

Returns a mutable subimage that is a view into this image. If you want an immutable subimage instead, use GenericImageView::view

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl GenericImage for DynamicImage

Source§

impl<Buffer, P> GenericImage for ViewMut<Buffer, P>
where P: Pixel, Buffer: AsMut<[<P as Pixel>::Subpixel]> + AsRef<[<P as Pixel>::Subpixel]>,

Source§

type InnerImage = ViewMut<Buffer, P>

Source§

impl<I> GenericImage for SubImage<I>
where I: DerefMut, <I as Deref>::Target: Sized + GenericImage,

Source§

impl<P, Container> GenericImage for ImageBuffer<P, Container>
where P: Pixel + 'static, Container: Deref<Target = [<P as Pixel>::Subpixel]> + DerefMut, <P as Pixel>::Subpixel: 'static,

Source§

type InnerImage = ImageBuffer<P, Container>