Struct BitMapElement

Source
pub struct BitMapElement<'a, Coord, P: PixelFormat = RGBPixel> { /* private fields */ }
Expand description

The element that contains a bitmap on it

Implementations§

Source§

impl<'a, Coord, P: PixelFormat> BitMapElement<'a, Coord, P>

Source

pub fn new(pos: Coord, size: (u32, u32)) -> Self

Create a new empty bitmap element. This can be use as the draw and blit pattern.

  • pos: The left upper coordinate for the element
  • size: The size of the bitmap
Source

pub fn with_owned_buffer( pos: Coord, size: (u32, u32), buf: Vec<u8>, ) -> Option<Self>

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 elelent
  • size: The size of the bitmap
  • buf: The buffer to use
  • returns: The newly created image element, if the buffer isn’t fit the image dimension, this will returns an None.
Source

pub fn with_mut(pos: Coord, size: (u32, u32), buf: &'a mut [u8]) -> Option<Self>

Create a new bitmap element with a mut borrow to an existing buffer

  • pos: The left upper coordinate of the elelent
  • size: The size of the bitmap
  • buf: The buffer to use
  • returns: The newly created image element, if the buffer isn’t fit the image dimension, this will returns an None.
Source

pub fn with_ref(pos: Coord, size: (u32, u32), buf: &'a [u8]) -> Option<Self>

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 elelent
  • size: The size of the bitmap
  • buf: The buffer to use
  • returns: The newly created image element, if the buffer isn’t fit the image dimension, this will returns an None.
Source

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
Source

pub fn move_to(&mut self, pos: Coord)

Move the existing bitmap element to a new position

  • pos: The new position
Source

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§

Source§

impl<'a, Coord, DB: DrawingBackend> Drawable<DB> for BitMapElement<'a, Coord>

Source§

fn draw<I: Iterator<Item = BackendCoord>>( &self, points: I, backend: &mut DB, _: (u32, u32), ) -> Result<(), DrawingErrorKind<DB::ErrorType>>

Actually draws the element. The key points is already translated into the image coordinate and can be used by DC directly
Source§

impl<'a, Coord> From<(Coord, DynamicImage)> for BitMapElement<'a, Coord, RGBPixel>

Source§

fn from((pos, image): (Coord, DynamicImage)) -> Self

Converts to this type from the input type.
Source§

impl<'a, Coord> From<(Coord, DynamicImage)> for BitMapElement<'a, Coord, BGRXPixel>

Source§

fn from((pos, image): (Coord, DynamicImage)) -> Self

Converts to this type from the input type.
Source§

impl<'a, 'b, Coord> PointCollection<'a, Coord> for &'a BitMapElement<'b, Coord>

Source§

type Borrow = &'a Coord

The item in point iterator
Source§

type IntoIter = Once<&'a Coord>

The point iterator
Source§

fn point_iter(self) -> Self::IntoIter

framework to do the coordinate mapping

Auto Trait Implementations§

§

impl<'a, Coord, P> Freeze for BitMapElement<'a, Coord, P>
where Coord: Freeze,

§

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§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Component + Float, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, U> ConvertInto<U> for T
where U: ConvertFrom<T>,

Source§

fn convert_into(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

fn convert_unclamped_into(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

fn try_convert_into(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'b, T, DB, Coord> IntoDynElement<'b, DB, Coord> for T
where T: Drawable<DB> + 'b, &'a T: for<'a> PointCollection<'a, Coord>, Coord: Clone, DB: DrawingBackend,

Source§

fn into_dyn(self) -> DynElement<'b, DB, Coord>

Make the conversion
Source§

impl<T> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.