[−][src]Struct pix::Raster
A raster image with owned pixel data. If the pixel data must be owned elsewhere, consider using RasterB.
Example
use pix::{Raster, Alpha8, Rgba8}; let mut raster: Raster<Rgba8> = Raster::new(10, 10); let mut matte: Raster<Alpha8> = Raster::new(10, 10); matte.set_pixel(2, 4, Alpha8::new(255)); matte.set_pixel(2, 5, Alpha8::new(128)); raster.mask_over(&matte, 0, 0, Rgba8::new(128, 208, 208, 200)); let p = raster.as_u8_slice(); // work with pixel data...
Methods
impl<F: PixFmt> Raster<F>
[src]
pub fn new(width: u32, height: u32) -> Raster<F>
[src]
Create a new raster image.
F
Pixel format.width
Width in pixels.height
Height in pixels.
pub fn width(&self) -> u32
[src]
Get raster width.
pub fn height(&self) -> u32
[src]
Get raster height.
pub fn pixel(&self, x: u32, y: u32) -> F
[src]
Get one pixel value.
pub fn set_pixel(&mut self, x: u32, y: u32, p: F)
[src]
Set one pixel value.
pub fn as_slice(&self) -> &[F]
[src]
Get the pixels as a slice.
pub fn as_slice_mut(&mut self) -> &mut [F]
[src]
Get the pixels as a mutable slice.
pub fn as_u8_slice(&self) -> &[u8]
[src]
Get the pixels as a u8 slice.
pub fn as_u8_slice_mut(&mut self) -> &mut [u8]
[src]
Get the pixels as a mutable u8 slice.
pub fn clear(&mut self)
[src]
Clear all pixels.
pub fn set_rect(&mut self, x: u32, y: u32, w: u32, h: u32, clr: F)
[src]
Set a rectangle to specified color.
x
Left position of rectangle.y
Top position of rectangle.w
Width of rectangle.h
Height of rectangle.clr
Color to set.
pub fn mask_over(&mut self, mask: &Raster<Alpha8>, x: i32, y: i32, clr: F)
[src]
Blend pixels with an alpha mask.
mask
Alpha mask for compositing.x
Left position of alpha mask.y
Top position of alpha mask.clr
Color to composite.
Trait Implementations
impl<F: Clone + PixFmt> Clone for Raster<F>
[src]
fn clone(&self) -> Raster<F>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<F: Debug + PixFmt> Debug for Raster<F>
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom 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 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 for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut 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,