[]Trait iconwriter::GenericImage

pub trait GenericImage {
    type Pixel: Pixel;
    pub fn dimensions(&self) -> (u32, u32);
pub fn bounds(&self) -> (u32, u32, u32, u32);
pub fn get_pixel(&self, x: u32, y: u32) -> Self::Pixel;
pub fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut Self::Pixel;
pub fn put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel);
pub fn blend_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel); pub fn width(&self) -> u32 { ... }
pub fn height(&self) -> u32 { ... }
pub fn in_bounds(&self, x: u32, y: u32) -> bool { ... }
pub unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> Self::Pixel { ... }
pub unsafe fn unsafe_put_pixel(
        &mut self,
        x: u32,
        y: u32,
        pixel: Self::Pixel
    ) { ... }
pub fn pixels(&self) -> Pixels<'_, Self> { ... }
pub fn pixels_mut(&mut self) -> MutPixels<'_, Self> { ... }
pub fn copy_from<O>(&mut self, other: &O, x: u32, y: u32) -> bool
    where
        O: GenericImage<Pixel = Self::Pixel>
, { ... }
pub fn sub_image(
        &mut self,
        x: u32,
        y: u32,
        width: u32,
        height: u32
    ) -> SubImage<'_, Self>
    where
        Self: 'static,
        <Self::Pixel as Pixel>::Subpixel: 'static,
        Self::Pixel: 'static
, { ... } }

A trait for manipulating images.

Associated Types

type Pixel: Pixel

The type of pixel.

Loading content...

Required methods

pub fn dimensions(&self) -> (u32, u32)

The width and height of this image.

pub fn bounds(&self) -> (u32, u32, u32, u32)

The bounding rectangle of this image.

pub fn get_pixel(&self, x: u32, y: u32) -> Self::Pixel

Returns the pixel located at (x, y)

Panics

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

TODO: change this signature to &P

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

Puts a pixel at location (x, y)

Panics

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

pub 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.

pub 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.

Loading content...

Provided methods

pub fn width(&self) -> u32

The width of this image.

pub fn height(&self) -> u32

The height of this image.

pub fn in_bounds(&self, x: u32, y: u32) -> bool

Returns true if this x, y coordinate is contained inside the image.

pub unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> Self::Pixel

Returns the pixel located at (x, y)

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

pub 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.

pub fn pixels(&self) -> Pixels<'_, Self>

Returns an Iterator over the pixels of this image. The iterator yields the coordinates of each pixel along with their value

pub fn pixels_mut(&mut self) -> MutPixels<'_, Self>

👎 Deprecated:

This cannot be implemented safely in Rust. Please use the image buffer directly.

Returns an Iterator over mutable pixels of this image. The iterator yields the coordinates of each pixel along with a mutable reference to them.

pub fn copy_from<O>(&mut self, other: &O, x: u32, y: u32) -> bool where
    O: GenericImage<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 sub_image.

Returns

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

pub fn sub_image(
    &mut self,
    x: u32,
    y: u32,
    width: u32,
    height: u32
) -> SubImage<'_, Self> where
    Self: 'static,
    <Self::Pixel as Pixel>::Subpixel: 'static,
    Self::Pixel: 'static, 

Returns a subimage that is a view into this image.

Loading content...

Implementations on Foreign Types

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

type Pixel = P

pub unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> P

Returns the pixel located at (x, y), ignoring bounds checking.

pub unsafe fn unsafe_put_pixel(&mut self, x: u32, y: u32, pixel: P)

Puts a pixel at location (x, y), ignoring bounds checking.

pub fn blend_pixel(&mut self, x: u32, y: u32, p: P)

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

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

impl<'a, I> GenericImage for SubImage<'a, I> where
    I: 'static + GenericImage,
    <I as GenericImage>::Pixel: 'static,
    <<I as GenericImage>::Pixel as Pixel>::Subpixel: 'static, 

type Pixel = <I as GenericImage>::Pixel

pub fn blend_pixel(&mut self, x: u32, y: u32, pixel: <I as GenericImage>::Pixel)

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

Loading content...

Implementors

impl GenericImage for DynamicImage

type Pixel = Rgba<u8>

pub fn blend_pixel(&mut self, x: u32, y: u32, pixel: Rgba<u8>)

DEPRECATED: Use iterator pixels_mut to blend the pixels directly.

pub fn get_pixel_mut(&mut self, u32, u32) -> &mut Rgba<u8>

DEPRECATED: Do not use is function: It is unimplemented!

Loading content...