pub struct PngImage {
pub width: usize,
pub height: usize,
pub data: Vec<u8>,
}
Expand description
A PNG image. Currently only supports RGB and RGBA color types
Fields§
§width: usize
The width of the image
height: usize
The height of the image
data: Vec<u8>
The data in the image, stored in chunks of 4 per pixel, containing the image in RGBA order
Implementations§
Source§impl PngImage
impl PngImage
Sourcepub fn load_from_path<R: Read>(r: R) -> Result<Self, DecodingError>
pub fn load_from_path<R: Read>(r: R) -> Result<Self, DecodingError>
Load an image from a specified source.
Sourcepub fn load_from_path_transform<R: Read, F: Fn(Color) -> Color>(
r: R,
transform: F,
) -> Result<Self, DecodingError>
pub fn load_from_path_transform<R: Read, F: Fn(Color) -> Color>( r: R, transform: F, ) -> Result<Self, DecodingError>
Load an image and apply a function to each pixel. Mostly used by LatexObj
to fix alpha
Trait Implementations§
Source§impl Drawable for PngImage
impl Drawable for PngImage
Source§fn content_mut(&mut self) -> Vec<&mut dyn Drawable>
fn content_mut(&mut self) -> Vec<&mut dyn Drawable>
What this object contains, mutably
Source§fn draw(
&self,
canvas: &mut Canvas<Window>,
pos: &Position,
_settings: DrawSettings,
)
fn draw( &self, canvas: &mut Canvas<Window>, pos: &Position, _settings: DrawSettings, )
Draw everything
Source§fn step(&mut self)
fn step(&mut self)
When the user presses space, the state of the presentation is advanced. This
method is what is called.
Source§impl ImageContainer for PngImage
impl ImageContainer for PngImage
Source§fn as_knownsize(&self) -> &dyn KnownSize
fn as_knownsize(&self) -> &dyn KnownSize
Convert the object to a dynamic KnownSize object, as rust doesn’t support calling KnownSize
-methods directly on this object
Auto Trait Implementations§
impl Freeze for PngImage
impl RefUnwindSafe for PngImage
impl Send for PngImage
impl Sync for PngImage
impl Unpin for PngImage
impl UnwindSafe for PngImage
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more