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
Fields
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 more