pub struct ImageMeta {
pub kind: ImageType,
pub dimensions: (u32, u32),
pub size: u32,
}
Expand description
Stores the type of image and some basic meta-data.
Fields§
§kind: ImageType
What kind of image it is; PNG, JPEG, etc
dimensions: (u32, u32)
The width and height of the image
size: u32
The length of the image in bytes
Implementations§
Source§impl ImageMeta
impl ImageMeta
Sourcepub fn from_bytes<T: AsRef<[u8]>>(buf: T) -> Option<Self>
pub fn from_bytes<T: AsRef<[u8]>>(buf: T) -> Option<Self>
Returns an ImageMeta
from the supplied buffer slice. If it is unable to detect an image type it will return None
§Examples
let info = match ImageMeta::from_bytes(&png_image) {
Some(x) => x,
None => panic!("Unknown image format!");
};
assert_eq!(ImageMeta::Png, info.kind);
assert_eq!( (1920, 1080), info.dimensions);
Trait Implementations§
impl Copy for ImageMeta
Auto Trait Implementations§
impl Freeze for ImageMeta
impl RefUnwindSafe for ImageMeta
impl Send for ImageMeta
impl Sync for ImageMeta
impl Unpin for ImageMeta
impl UnwindSafe for ImageMeta
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