[−][src]Struct png_pong::Raster
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]
F: Format,
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]
F: From<P>,
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]
R: Into<Region>,
Get an Iterator
of pixels within a Region
.
reg
Region withinRaster
.
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]
C: Channel + From<H>,
F: Format<Chan = C>,
H: Channel,
I: Iterator<Item = P> + PixModes,
P: Format<Chan = H>,
R: Into<Region>,
Set a Region
using a pixel Iterator
.
reg
Region withinRaster
.it
Iterator
of pixels inRegion
.
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<Vec<F>> for Raster<F> where
F: Format,
[src]
F: Format,
impl<F> Into<Box<[F]>> for Raster<F> where
F: Format,
[src]
F: Format,
Auto Trait Implementations
impl<F> Unpin for Raster<F>
impl<F> Sync for Raster<F> where
F: Sync,
F: Sync,
impl<F> Send for Raster<F> where
F: Send,
F: Send,
impl<F> UnwindSafe for Raster<F> where
F: UnwindSafe,
F: UnwindSafe,
impl<F> RefUnwindSafe for Raster<F> where
F: RefUnwindSafe,
F: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,