[][src]Struct png_pong::Raster

pub struct Raster<F> where
    F: Format
{ /* fields omitted */ }

Raster image representing a two-dimensional array of pixels.

Create a Raster with a solid color rectangle

let mut raster = RasterBuilder::<Rgb8>::new().with_clear(10, 10);
raster.set_region((2, 4, 3, 3), Rgb8::new(0xFF, 0xFF, 0x00));

Methods

impl<F> Raster<F> where
    F: Format
[src]

pub fn width(&self) -> u32[src]

Get width of Raster.

pub fn height(&self) -> u32[src]

Get height of Raster.

pub fn pixel(&self, x: u32, y: u32) -> F[src]

Get one pixel value.

pub fn set_pixel<P>(&mut self, x: u32, y: u32, p: P) where
    F: From<P>, 
[src]

Set one pixel value.

pub fn clear(&mut self)[src]

Clear all pixels to Format default.

pub fn region(&self) -> Region[src]

Get Region of entire Raster.

pub fn region_iter<R>(&self, reg: R) -> RasterIter<F> where
    R: Into<Region>, 
[src]

Get an Iterator of pixels within a Region.

  • reg Region within Raster.

pub fn set_region<C, R, I, P, H>(&mut self, reg: R, it: I) where
    C: Channel + From<H>,
    F: Format<Chan = C>,
    H: Channel,
    I: Iterator<Item = P> + PixModes,
    P: Format<Chan = H>,
    R: Into<Region>, 
[src]

Set a Region using a pixel Iterator.

  • reg Region within Raster.
  • it Iterator of pixels in Region.

Set entire raster to one color

let mut r = RasterBuilder::<Rgb32>::new().with_clear(360, 240);
r.set_region(r.region(), Rgb32::new(0.5, 0.2, 0.8));

Set rectangle to solid color

let mut raster = RasterBuilder::<Rgb8>::new().with_clear(100, 100);
raster.set_region((20, 40, 25, 50), Rgb8::new(0xDD, 0x96, 0x70));

Copy part of one Raster to another, converting pixel format

let mut rgb = RasterBuilder::<Rgb8>::new().with_clear(100, 100);
let mut gray = RasterBuilder::<Gray16>::new().with_clear(50, 50);
// ... load image data
let src = gray.region().intersection((20, 10, 25, 25));
let dst = rgb.region().intersection((40, 40, 25, 25));
// Regions must have the same shape!
rgb.set_region(dst, gray.region_iter(src));

pub fn as_slice(&self) -> &[F][src]

Get view of pixels as a slice.

pub fn as_slice_mut(&mut self) -> &mut [F][src]

Get view of pixels as a mutable slice.

pub fn as_slice_row(&self, y: u32) -> &[F][src]

Get view of a row of pixels as a slice.

pub fn as_slice_row_mut(&mut self, y: u32) -> &mut [F][src]

Get view of a row of pixels as a mutable slice.

pub fn as_u8_slice_row(&self, y: u32) -> &[u8][src]

Get view of a row of pixels as a u8 slice.

pub fn as_u8_slice(&self) -> &[u8][src]

Get view of pixels as a u8 slice.

pub fn as_u8_slice_mut(&mut self) -> &mut [u8][src]

Get view of pixels as a mutable u8 slice.

Trait Implementations

impl<F> Into<Box<[F]>> for Raster<F> where
    F: Format
[src]

fn into(self) -> Box<[F]>[src]

Get internal pixel data as boxed slice.

impl<F> Into<Vec<F>> for Raster<F> where
    F: Format
[src]

fn into(self) -> Vec<F>[src]

Get internal pixel data as Vec of pixels.

Auto Trait Implementations

impl<F> Sync for Raster<F> where
    F: Sync

impl<F> Send for Raster<F> where
    F: Send

impl<F> Unpin for Raster<F>

impl<F> RefUnwindSafe for Raster<F> where
    F: RefUnwindSafe

impl<F> UnwindSafe for Raster<F> where
    F: UnwindSafe

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]