pub struct ImageSource {
pub image: DynamicImage,
pub desired: Rect,
pub hash: u64,
pub background_color: Rgba<u8>,
}Expand description
Image source for crate::protocol::StatefulProtocols
A [StatefulProtocol] needs to resize the ImageSource to its state when the available area
changes. A [Protocol] only needs it once.
§Examples
use image::{DynamicImage, ImageBuffer, Rgb};
use ratatui_image::ImageSource;
let image: ImageBuffer::from_pixel(300, 200, Rgb::<u8>([255, 0, 0])).into();
let source = ImageSource::new(image, "filename.png", (7, 14));
assert_eq!((43, 14), (source.rect.width, source.rect.height));Fields§
§image: DynamicImageThe original image without resizing.
desired: RectThe area that the ImageSource::image covers, but not necessarily fills.
hash: u64TODO: document this; when image changes but it doesn’t need a resize, force a render.
background_color: Rgba<u8>The background color that should be used for padding or background when resizing.
Implementations§
Source§impl ImageSource
impl ImageSource
Sourcepub fn new(
image: DynamicImage,
font_size: FontSize,
background_color: Rgba<u8>,
) -> ImageSource
pub fn new( image: DynamicImage, font_size: FontSize, background_color: Rgba<u8>, ) -> ImageSource
Create a new image source
Trait Implementations§
Source§impl Clone for ImageSource
impl Clone for ImageSource
Source§fn clone(&self) -> ImageSource
fn clone(&self) -> ImageSource
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ImageSource
impl RefUnwindSafe for ImageSource
impl Send for ImageSource
impl Sync for ImageSource
impl Unpin for ImageSource
impl UnwindSafe for ImageSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more