pub struct Image {
pub bytes: Bytes,
pub mime: &'static str,
}Expand description
An image ready to embed: PNG or JPEG bytes, or a WebP image a glTF document holds, which is re-encoded as PNG only when it’s written.
Fields§
§bytes: BytesThe encoded image. Shared: an image read from a document’s buffer points into it, and clones point at the same bytes.
mime: &'static strimage/png or image/jpeg; or image/webp for a WebP image Document::flatten
took from a glTF document as it is, which Mesh::to_glb writes as PNG and
Image::into_png_or_jpeg turns into PNG.
Implementations§
Source§impl Image
impl Image
Sourcepub fn png_or_jpeg(bytes: &[u8]) -> Option<Self>
pub fn png_or_jpeg(bytes: &[u8]) -> Option<Self>
bytes as an image when they are PNG or JPEG, the formats glTF embeds without an
extension.
Sourcepub fn from_png_or_jpeg(bytes: impl Into<Bytes>) -> Option<Self>
pub fn from_png_or_jpeg(bytes: impl Into<Bytes>) -> Option<Self>
Image::png_or_jpeg, taking the bytes (a Vec<u8> or Bytes)
without a copy.
Sourcepub fn decode(bytes: impl Into<Bytes>) -> Option<Self>
pub fn decode(bytes: impl Into<Bytes>) -> Option<Self>
bytes as an image: PNG and JPEG as they are, and WebP, BMP, GIF, TIFF, PSD and DDS
re-encoded as PNG, each with the feature of its name. TGA has no signature, so only one
with a version 2 footer is found here; Image::decode_named also goes by its name.
Sourcepub fn decode_named(bytes: impl Into<Bytes>, name: &Path) -> Option<Self>
pub fn decode_named(bytes: impl Into<Bytes>, name: &Path) -> Option<Self>
bytes, a file named name (a path, or just its extension’s worth, as x.tga), as an
image, as Image::decode makes one; the name finds TGA files without a footer. PNG and
JPEG bytes are kept as they are, without a copy.
Sourcepub fn into_png_or_jpeg(self) -> Option<Self>
pub fn into_png_or_jpeg(self) -> Option<Self>
The image as PNG or JPEG: PNG and JPEG as they are, and a WebP image (see
Image::mime) re-encoded as PNG. None for a WebP image that doesn’t decode.
Trait Implementations§
impl Eq for Image
impl StructuralPartialEq for Image
Auto Trait Implementations§
impl !Freeze for Image
impl Forget for Image
impl Move for Image
impl RefUnwindSafe for Image
impl Send for Image
impl Sync for Image
impl Unpin for Image
impl UnsafeUnpin for Image
impl UnwindSafe for Image
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.