[−][src]Struct png_pong::RasterBuilder
Builder for Raster images.
After creating a RasterBuilder
, the AlphaMode and
GammaMode can be configured. To finish building a
Raster
, use one of the with_ methods:
Create a Raster
let r = RasterBuilder::<Rgb8>::new().with_clear(100, 100);
Methods
impl<F> RasterBuilder<F> where
F: Format,
[src]
F: Format,
pub fn new() -> RasterBuilder<F>
[src]
Create a new raster builder.
F
Pixel Format.
pub fn alpha_mode(self, alpha_mode: AlphaMode) -> RasterBuilder<F>
[src]
Set the alpha mode. The default value is Separated.
pub fn gamma_mode(self, gamma_mode: GammaMode) -> RasterBuilder<F>
[src]
Set the gamma mode. The default value is Srgb.
pub fn with_clear(self, width: u32, height: u32) -> Raster<F>
[src]
Build a Raster
with all pixels clear.
Examples
let r1 = RasterBuilder::<Gray8>::new().with_clear(20, 20); let r2 = RasterBuilder::<Mask8>::new().with_clear(64, 64); let r3 = RasterBuilder::<Rgb16>::new().with_clear(10, 10); let r4 = RasterBuilder::<GrayAlpha32>::new().with_clear(100, 250);
pub fn with_color(self, width: u32, height: u32, clr: F) -> Raster<F>
[src]
Build a Raster
with all pixels set to one color.
Example
let clr = Rgb8::new(0x40, 0xAA, 0xBB); let r = RasterBuilder::<Rgb8>::new().with_clear(15, 15);
pub fn with_raster<C, H, P>(self, o: &Raster<P>) -> Raster<F> where
C: Channel + From<H>,
F: Format<Chan = C>,
H: Channel,
P: Format<Chan = H>,
[src]
C: Channel + From<H>,
F: Format<Chan = C>,
H: Channel,
P: Format<Chan = H>,
Build a Raster
by copying another Raster
.
C
DestinationChannel
.H
SourceChannel
.P
SourceFormat
.
Convert from Rgb8 to Rgba16
let mut r0 = RasterBuilder::<Rgb8>::new().with_clear(50, 50); // load pixels into raster let r1 = RasterBuilder::<Rgba16>::new().with_raster(&r0);
pub fn with_pixels<B>(self, width: u32, height: u32, pixels: B) -> Raster<F> where
B: Into<Box<[F]>>,
[src]
B: Into<Box<[F]>>,
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()
.
B
Owned pixed type (Vec
or boxed slice).width
Width ofRaster
.height
Height ofRaster
.pixels
Pixel data.
Panics
Panics if pixels
length is not equal to width
* height
.
Example
let p = vec![Rgb8::new(255, 0, 255); 16]; // vec of magenta pix let mut r = RasterBuilder::new() // convert to raster .with_pixels(4, 4, p); 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, width: u32, height: u32, buffer: B) -> Raster<F> where
B: Into<Box<[u8]>>,
F: Format<Chan = Ch8>,
[src]
B: Into<Box<[u8]>>,
F: Format<Chan = Ch8>,
Build a Raster
from a u8
buffer.
B
Owned pixed type (Vec
or boxed slice).width
Width ofRaster
.height
Height ofRaster
.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, width: u32, height: u32, buffer: B) -> Raster<F> where
B: Into<Box<[u16]>>,
F: Format<Chan = Ch16>,
[src]
B: Into<Box<[u16]>>,
F: Format<Chan = Ch16>,
Build a Raster
from a u16
buffer.
B
Owned pixed type (Vec
or boxed slice).width
Width ofRaster
.height
Height ofRaster
.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> Sync for RasterBuilder<F> where
F: Sync,
F: Sync,
impl<F> Unpin for RasterBuilder<F> where
F: Unpin,
F: Unpin,
impl<F> Send for RasterBuilder<F> where
F: Send,
F: Send,
impl<F> UnwindSafe for RasterBuilder<F> where
F: UnwindSafe,
F: UnwindSafe,
impl<F> RefUnwindSafe for RasterBuilder<F> where
F: RefUnwindSafe,
F: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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,