pub struct BitMapElement<'a, Coord, P = RGBPixel>where
P: PixelFormat,{ /* private fields */ }
Expand description
The element that contains a bitmap on it
Implementations
sourceimpl<'a, Coord, P> BitMapElement<'a, Coord, P>where
P: PixelFormat,
impl<'a, Coord, P> BitMapElement<'a, Coord, P>where
P: PixelFormat,
sourcepub fn new(pos: Coord, size: (u32, u32)) -> BitMapElement<'a, Coord, P>
pub fn new(pos: Coord, size: (u32, u32)) -> BitMapElement<'a, Coord, P>
Create a new empty bitmap element. This can be use as the draw and blit pattern.
pos
: The left upper coordinate for the elementsize
: The size of the bitmap
sourcepub fn with_owned_buffer(
pos: Coord,
size: (u32, u32),
buf: Vec<u8, Global>
) -> Option<BitMapElement<'a, Coord, P>>
pub fn with_owned_buffer(
pos: Coord,
size: (u32, u32),
buf: Vec<u8, Global>
) -> Option<BitMapElement<'a, Coord, P>>
Create a new bitmap element with an pre-allocated owned buffer, this function will take the ownership of the buffer.
pos
: The left upper coordinate of the elelentsize
: The size of the bitmapbuf
: The buffer to use- returns: The newly created image element, if the buffer isn’t fit the image
dimension, this will returns an
None
.
sourcepub fn with_mut(
pos: Coord,
size: (u32, u32),
buf: &'a mut [u8]
) -> Option<BitMapElement<'a, Coord, P>>
pub fn with_mut(
pos: Coord,
size: (u32, u32),
buf: &'a mut [u8]
) -> Option<BitMapElement<'a, Coord, P>>
Create a new bitmap element with a mut borrow to an existing buffer
pos
: The left upper coordinate of the elelentsize
: The size of the bitmapbuf
: The buffer to use- returns: The newly created image element, if the buffer isn’t fit the image
dimension, this will returns an
None
.
sourcepub fn with_ref(
pos: Coord,
size: (u32, u32),
buf: &'a [u8]
) -> Option<BitMapElement<'a, Coord, P>>
pub fn with_ref(
pos: Coord,
size: (u32, u32),
buf: &'a [u8]
) -> Option<BitMapElement<'a, Coord, P>>
Create a new bitmap element with a shared borrowed buffer. This means if we want to modifiy the content of the image, the buffer is automatically copied
pos
: The left upper coordinate of the elelentsize
: The size of the bitmapbuf
: The buffer to use- returns: The newly created image element, if the buffer isn’t fit the image
dimension, this will returns an
None
.
sourcepub fn copy_to<Coord2>(&self, pos: Coord2) -> BitMapElement<'_, Coord2, P>
pub fn copy_to<Coord2>(&self, pos: Coord2) -> BitMapElement<'_, Coord2, P>
Copy the existing bitmap element to another location
pos
: The new location to copy
sourcepub fn move_to(&mut self, pos: Coord)
pub fn move_to(&mut self, pos: Coord)
Move the existing bitmap element to a new position
pos
: The new position
sourcepub fn as_bitmap_backend(&mut self) -> BitMapBackend<'_, P>
pub fn as_bitmap_backend(&mut self) -> BitMapBackend<'_, P>
Make the bitmap element as a bitmap backend, so that we can use plotters drawing functionality on the bitmap element
Trait Implementations
sourceimpl<'a, Coord, DB> Drawable<DB, BackendCoordOnly> for BitMapElement<'a, Coord, RGBPixel>where
DB: DrawingBackend,
impl<'a, Coord, DB> Drawable<DB, BackendCoordOnly> for BitMapElement<'a, Coord, RGBPixel>where
DB: DrawingBackend,
sourcefn draw<I>(
&self,
points: I,
backend: &mut DB,
(u32, u32)
) -> Result<(), DrawingErrorKind<<DB as DrawingBackend>::ErrorType>>where
I: Iterator<Item = (i32, i32)>,
fn draw<I>(
&self,
points: I,
backend: &mut DB,
(u32, u32)
) -> Result<(), DrawingErrorKind<<DB as DrawingBackend>::ErrorType>>where
I: Iterator<Item = (i32, i32)>,
Actually draws the element. The key points is already translated into the
image coordinate and can be used by DC directly Read more
sourceimpl<'a, Coord> From<(Coord, DynamicImage)> for BitMapElement<'a, Coord, BGRXPixel>
impl<'a, Coord> From<(Coord, DynamicImage)> for BitMapElement<'a, Coord, BGRXPixel>
sourcefn from((Coord, DynamicImage)) -> BitMapElement<'a, Coord, BGRXPixel>
fn from((Coord, DynamicImage)) -> BitMapElement<'a, Coord, BGRXPixel>
Converts to this type from the input type.
sourceimpl<'a, Coord> From<(Coord, DynamicImage)> for BitMapElement<'a, Coord, RGBPixel>
impl<'a, Coord> From<(Coord, DynamicImage)> for BitMapElement<'a, Coord, RGBPixel>
sourcefn from((Coord, DynamicImage)) -> BitMapElement<'a, Coord, RGBPixel>
fn from((Coord, DynamicImage)) -> BitMapElement<'a, Coord, RGBPixel>
Converts to this type from the input type.
sourceimpl<'a, 'b, Coord> PointCollection<'a, Coord, BackendCoordOnly> for &'a BitMapElement<'b, Coord, RGBPixel>
impl<'a, 'b, Coord> PointCollection<'a, Coord, BackendCoordOnly> for &'a BitMapElement<'b, Coord, RGBPixel>
sourcefn point_iter(
self
) -> <&'a BitMapElement<'b, Coord, RGBPixel> as PointCollection<'a, Coord, BackendCoordOnly>>::IntoIter
fn point_iter(
self
) -> <&'a BitMapElement<'b, Coord, RGBPixel> as PointCollection<'a, Coord, BackendCoordOnly>>::IntoIter
framework to do the coordinate mapping
Auto Trait Implementations
impl<'a, Coord, P> RefUnwindSafe for BitMapElement<'a, Coord, P>where
Coord: RefUnwindSafe,
P: RefUnwindSafe,
impl<'a, Coord, P> Send for BitMapElement<'a, Coord, P>where
Coord: Send,
P: Send,
impl<'a, Coord, P> Sync for BitMapElement<'a, Coord, P>where
Coord: Sync,
P: Sync,
impl<'a, Coord, P> Unpin for BitMapElement<'a, Coord, P>where
Coord: Unpin,
P: Unpin,
impl<'a, Coord, P = RGBPixel> !UnwindSafe for BitMapElement<'a, Coord, P>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<'b, T, DB, Coord> IntoDynElement<'b, DB, Coord> for Twhere
T: 'b + Drawable<DB, BackendCoordOnly>,
&'a T: for<'a> PointCollection<'a, Coord, BackendCoordOnly>,
Coord: Clone,
DB: DrawingBackend,
impl<'b, T, DB, Coord> IntoDynElement<'b, DB, Coord> for Twhere
T: 'b + Drawable<DB, BackendCoordOnly>,
&'a T: for<'a> PointCollection<'a, Coord, BackendCoordOnly>,
Coord: Clone,
DB: DrawingBackend,
sourcefn into_dyn(self) -> DynElement<'b, DB, Coord>
fn into_dyn(self) -> DynElement<'b, DB, Coord>
Make the conversion