Struct picto::View [] [src]

pub struct View<'a, C, P> where C: Channel, P: Read<C> + Write<C> { /* fields omitted */ }

A view into a Buffer.

Methods

impl<'a, C, P> View<'a, C, P> where C: Channel, P: Read<C> + Write<C>
[src]

Get the area.

Get the width.

Get the height.

Get the Pixel at the given coordinates.

Panics

Requires that x < self.width() and y < self.height(), otherwise it will panic.

Set the Pixel at the given coordinates.

Panics

Requires that x < self.width() and y < self.height(), otherwise it will panic.

Get a read-only view of the given area.

Panics

Requires that x + width <= self.width() and y + height <= self.height(), otherwise it will panic.

Get a write-only view of the given area.

Panics

Requires that x + width <= self.width() and y + height <= self.height(), otherwise it will panic.

Get a mutable view of the given area.

Panics

Requires that x + width <= self.width() and y + height <= self.height(), otherwise it will panic.

Fill the view with the given pixel.

Example

use picto::read;
use picto::Area;
use picto::color::Rgb;

let mut image = read::from_path::<u8, Rgb, _>("tests/boat.xyz").unwrap();
let mut view  = image.view(Area::new().x(10).y(10).width(20).height(30));

// Make a 20x20 pixel area black at offset 10,10.
view.fill(&Rgb::new(0.0, 0.0, 0.0));Run

Get a mutable Iterator over the pixels.

Get a mutable Iterator over the pixels.

Example

use picto::read;
use picto::Area;
use picto::color::{Mix, Rgb};

let mut image = read::from_path::<u8, Rgb, _>("tests/boat.xyz").unwrap();
let mut view  = image.view(Area::new().x(50).y(20));

for (_, _, mut px) in view.pixels_mut() {
    // Get the pixel value.
    let p = px.get();

    // Mix the color with red.
    let p = p.mix(&Rgb::new(1.0, 0.0, 0.0), 0.5);

    // Set the pixel value.
    px.set(&p);
}Run

Create a Buffer from the View.

Convert the View to a Buffer with different channel and pixel type.

Example

use picto::read;
use picto::Area;
use picto::color::{Rgb, Rgba};

let mut image = read::from_path::<u8, Rgba, _>("tests/rainbow.png").unwrap();
let     view  = image.view(Area::new().x(10).y(10).width(20).height(20));

// Convert the 20x20 area from Rgba to Rgb.
view.convert::<u8, Rgb>();Run

Trait Implementations

impl<'a, C: PartialEq, P: PartialEq> PartialEq for View<'a, C, P> where C: Channel, P: Read<C> + Write<C>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'a, C: Debug, P: Debug> Debug for View<'a, C, P> where C: Channel, P: Read<C> + Write<C>
[src]

Formats the value using the given formatter.

impl<'a, C, P> From<&'a mut View<'a, C, P>> for View<'a, C, P> where C: Channel, P: Read<C> + Write<C>
[src]

Performs the conversion.

impl<'a, C, P, D> From<&'a mut Buffer<C, P, D>> for View<'a, C, P> where C: Channel, P: Write<C> + Read<C>, D: DerefMut<Target=[C]>
[src]

Performs the conversion.