pub struct BitMapBackend<'a, P = RGBPixel>where
P: PixelFormat,{ /* private fields */ }
Expand description
The backend that drawing a bitmap
Warning
You should call .present()?
on a
BitMapBackend
, not just drop
it or allow it to go out of scope.
If the BitMapBackend
is just dropped, it will make a best effort attempt to write the
generated charts to the output file, but any errors that occcur (such as inability to
create the output file) will be silently ignored.
Implementations§
§impl<'a> BitMapBackend<'a>
impl<'a> BitMapBackend<'a>
pub fn new<T>(path: &'a T, _: (u32, u32)) -> BitMapBackend<'a>
pub fn new<T>(path: &'a T, _: (u32, u32)) -> BitMapBackend<'a>
Create a new bitmap backend
pub fn gif<T>(
path: T,
_: (u32, u32),
frame_delay: u32
) -> Result<BitMapBackend<'a>, BitMapBackendError>
pub fn gif<T>( path: T, _: (u32, u32), frame_delay: u32 ) -> Result<BitMapBackend<'a>, BitMapBackendError>
Create a new bitmap backend that generate GIF animation
When this is used, the bitmap backend acts similar to a real-time rendering backend.
When the program finished drawing one frame, use present
function to flush the frame
into the GIF file.
path
: The path to the GIF file to createdimension
: The size of the GIF imagespeed
: The amount of time for each frame to display
pub fn with_buffer(buf: &'a mut [u8], _: (u32, u32)) -> BitMapBackend<'a>
pub fn with_buffer(buf: &'a mut [u8], _: (u32, u32)) -> BitMapBackend<'a>
Create a new bitmap backend which only lives in-memory
When this is used, the bitmap backend will write to a user provided u8 array (or Vec
Note: This function provides backward compatibility for those code that assumes Plotters
uses RGB pixel format and maniuplates the in-memory framebuffer.
For more pixel format option, use with_buffer_and_format
instead.
buf
: The buffer to operatedimension
: The size of the image in pixels- returns: The newly created bitmap backend
§impl<'a, P> BitMapBackend<'a, P>where
P: PixelFormat,
impl<'a, P> BitMapBackend<'a, P>where
P: PixelFormat,
pub fn with_buffer_and_format(
buf: &'a mut [u8],
_: (u32, u32)
) -> Result<BitMapBackend<'a, P>, BitMapBackendError>
pub fn with_buffer_and_format( buf: &'a mut [u8], _: (u32, u32) ) -> Result<BitMapBackend<'a, P>, BitMapBackendError>
Create a new bitmap backend with a in-memory buffer with specific pixel format.
Note: This can be used as a way to manipulate framebuffer, mmap
can be used on the top of this
as well.
buf
: The buffer to operatedimension
: The size of the image in pixels- returns: The newly created bitmap backend
pub fn split(&mut self, area_size: &[u32]) -> Vec<BitMapBackend<'_, P>>
pub fn split(&mut self, area_size: &[u32]) -> Vec<BitMapBackend<'_, P>>
Split a bitmap backend vertically into several sub drawing area which allows multi-threading rendering.
area_size
: The size of the area- returns: The splitted backends that can be rendered in parallel
Trait Implementations§
§impl<'a, P> DrawingBackend for BitMapBackend<'a, P>where
P: PixelFormat,
impl<'a, P> DrawingBackend for BitMapBackend<'a, P>where
P: PixelFormat,
§fn ensure_prepared(
&mut self
) -> Result<(), DrawingErrorKind<BitMapBackendError>>
fn ensure_prepared( &mut self ) -> Result<(), DrawingErrorKind<BitMapBackendError>>
§fn present(&mut self) -> Result<(), DrawingErrorKind<BitMapBackendError>>
fn present(&mut self) -> Result<(), DrawingErrorKind<BitMapBackendError>>
ensure_prepared
is called
it checks if it needs a fresh buffer and present
is called rendering all the
pending changes on the screen.