[][src]Struct pix::RasterBuilder

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

Builder for Raster images.

Create with Raster::new

let rb = Raster::<Rgb8>::new(100, 100);

To build a Raster, use one of the with_ methods:

Methods

impl<F: Format> RasterBuilder<F>[src]

pub fn alpha_mode(self, alpha_mode: AlphaMode) -> Self[src]

Set the alpha mode. The default value is Separated.

pub fn gamma_mode(self, gamma_mode: GammaMode) -> Self[src]

Set the gamma mode. The default value is Srgb.

pub fn with_empty(self) -> Raster<F>[src]

Build a Raster with empty pixel data.

pub fn with_pixels<B>(self, pixels: B) -> Raster<F> where
    B: Into<Box<[F]>>, 
[src]

Build a Raster with owned pixel data. You can get ownership of the pixel data back from the Raster as either a Vec<F> or a Box<[F]> by calling into().

  • F Pixel Format.
  • pixels Pixel data.

Panics

Panics if pixels length is not equal to width * height.

Example

use pix::*;
let p = vec![Rgb8::new(255, 0, 255); 16];     // vec of magenta pix
let mut r = Raster::new(4, 4).with_pixels(p); // convert to raster
let clr = Rgb8::new(0x00, 0xFF, 0x00);        // green
r.set_region((2, 0, 1, 3), clr);              // make stripe
let p2 = Into::<Vec<Rgb8>>::into(r);          // convert back to vec

pub fn with_u8_buffer<B>(self, buffer: B) -> Raster<F> where
    B: Into<Box<[u8]>>,
    F: Format<Chan = Ch8>, 
[src]

Build a Raster from a u8 buffer.

  • F Pixel Format.
  • buffer Buffer of pixel data.

Panics

Panics if buffer length is not equal to width * height * std::mem::size_of::<F>().

pub fn with_u16_buffer<B>(self, buffer: B) -> Raster<F> where
    B: Into<Box<[u16]>>,
    F: Format<Chan = Ch16>, 
[src]

Build a Raster from a u16 buffer.

  • F Pixel Format.
  • buffer Buffer of pixel data (in native-endian byte order).

Panics

Panics if buffer length is not equal to width * height * std::mem::size_of::<F>().

Auto Trait Implementations

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

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

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]