Trait GenericImageView

Source
pub trait GenericImageView {
    type Pixel: Pixel;

    // Required methods
    fn dimensions(&self) -> (u32, u32);
    fn get_pixel(&self, x: u32, y: u32) -> Self::Pixel;

    // Provided methods
    fn width(&self) -> u32 { ... }
    fn height(&self) -> u32 { ... }
    fn in_bounds(&self, x: u32, y: u32) -> bool { ... }
    unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> Self::Pixel { ... }
    fn pixels(&self) -> Pixels<'_, Self> 
       where Self: Sized { ... }
    fn view(&self, x: u32, y: u32, width: u32, height: u32) -> SubImage<&Self>
       where Self: Sized { ... }
}
Expand description

Trait to inspect an image.

use image::{GenericImageView, Rgb, RgbImage};

let buffer = RgbImage::new(10, 10);
let image: &dyn GenericImageView<Pixel = Rgb<u8>> = &buffer;

Required Associated Types§

Source

type Pixel: Pixel

The type of pixel.

Required Methods§

Source

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

The width and height of this image.

Source

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

Returns the pixel located at (x, y). Indexed from top left.

§Panics

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

Provided Methods§

Source

fn width(&self) -> u32

The width of this image.

Source

fn height(&self) -> u32

The height of this image.

Source

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

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

Source

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

Returns the pixel located at (x, y). Indexed from top left.

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

§Safety

The coordinates must be in_bounds of the image.

Source

fn pixels(&self) -> Pixels<'_, Self>
where Self: Sized,

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

Source

fn view(&self, x: u32, y: u32, width: u32, height: u32) -> SubImage<&Self>
where Self: Sized,

Returns a subimage that is an immutable view into this image. You can use GenericImage::sub_image if you need a mutable view instead. The coordinates set the position of the top left corner of the view.

Implementors§

Source§

impl GenericImageView for DynamicImage

Source§

impl<Buffer, P: Pixel> GenericImageView for View<Buffer, P>
where Buffer: AsRef<[P::Subpixel]>,

Source§

type Pixel = P

Source§

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

Source§

type Pixel = P

Source§

impl<P, Container> GenericImageView for ImageBuffer<P, Container>
where P: Pixel, Container: Deref<Target = [P::Subpixel]> + Deref,

Source§

type Pixel = P

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy