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]
fn area(&self) -> Area
Get the area.
fn width(&self) -> u32
Get the width.
fn height(&self) -> u32
Get the height.
fn get(&self, x: u32, y: u32) -> P
Get the Pixel
at the given coordinates.
Panics
Requires that x < self.width()
and y < self.height()
, otherwise it will panic.
fn set(&mut self, x: u32, y: u32, pixel: &P)
Set the Pixel
at the given coordinates.
Panics
Requires that x < self.width()
and y < self.height()
, otherwise it will panic.
fn readable(&self, area: Builder) -> Read<C, P>
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.
fn writable(&mut self, area: Builder) -> Write<C, P>
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.
fn view(&mut self, area: Builder) -> View<C, P>
Get a mutable view of the given area.
Panics
Requires that x + width <= self.width()
and y + height <= self.height()
, otherwise it will panic.
fn fill(&mut self, pixel: &P)
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
fn pixels(&self) -> Pixels<C, P>
Get a mutable Iterator
over the pixels.
fn pixels_mut(&mut self) -> PixelsMut<C, P>
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
fn into_owned(&self) -> Buffer<C, P, Vec<C>>
Create a Buffer
from the View
.
fn convert<CO, PO>(&self) -> Buffer<CO, PO, Vec<CO>> where CO: Channel, PO: Write<CO>, P: Into<PO>
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]
fn eq(&self, __arg_0: &View<'a, C, P>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &View<'a, C, P>) -> bool
This method tests for !=
.