Enum egui::widgets::ImageSource
source · pub enum ImageSource<'a> {
Uri(Cow<'a, str>),
Texture(SizedTexture),
Bytes {
uri: Cow<'static, str>,
bytes: Bytes,
},
}Expand description
This type tells the Ui how to load an image.
This is used by Image::new and Ui::image.
Variants§
Uri(Cow<'a, str>)
Load the image from a URI, e.g. https://example.com/image.png.
This could be a file:// path, https:// url, bytes:// identifier, or some other scheme.
How the URI will be turned into a texture for rendering purposes is up to the registered loaders to handle.
See crate::load for more information.
Texture(SizedTexture)
Load the image from an existing texture.
The user is responsible for loading the texture, determining its size,
and allocating a TextureId for it.
Bytes
Load the image from some raw bytes.
The Bytes may be:
'static, obtained frominclude_bytes!or similar- Anything that can be converted to
Arc<[u8]>
This instructs the Ui to cache the raw bytes, which are then further processed by any registered loaders.
See also include_image for an easy way to load and display static images.
See crate::load for more information.
Implementations§
source§impl<'a> ImageSource<'a>
impl<'a> ImageSource<'a>
sourcepub fn texture_size(&self) -> Option<Vec2>
pub fn texture_size(&self) -> Option<Vec2>
Size of the texture, if known.
sourcepub fn load(
self,
ctx: &Context,
texture_options: TextureOptions,
size_hint: SizeHint,
) -> TextureLoadResult
pub fn load( self, ctx: &Context, texture_options: TextureOptions, size_hint: SizeHint, ) -> TextureLoadResult
§Errors
Failure to load the texture.
sourcepub fn uri(&self) -> Option<&str>
pub fn uri(&self) -> Option<&str>
Get the uri that this image was constructed from.
This will return None for Self::Texture.
Trait Implementations§
source§impl<'a> Clone for ImageSource<'a>
impl<'a> Clone for ImageSource<'a>
source§fn clone(&self) -> ImageSource<'a>
fn clone(&self) -> ImageSource<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<'a> Debug for ImageSource<'a>
impl<'a> Debug for ImageSource<'a>
source§impl<'a> From<&'a String> for ImageSource<'a>
impl<'a> From<&'a String> for ImageSource<'a>
source§impl<'a> From<&'a str> for ImageSource<'a>
impl<'a> From<&'a str> for ImageSource<'a>
source§impl From<String> for ImageSource<'static>
impl From<String> for ImageSource<'static>
source§impl<T: Into<SizedTexture>> From<T> for ImageSource<'static>
impl<T: Into<SizedTexture>> From<T> for ImageSource<'static>
Auto Trait Implementations§
impl<'a> Freeze for ImageSource<'a>
impl<'a> RefUnwindSafe for ImageSource<'a>
impl<'a> Send for ImageSource<'a>
impl<'a> Sync for ImageSource<'a>
impl<'a> Unpin for ImageSource<'a>
impl<'a> UnwindSafe for ImageSource<'a>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)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>
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>
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