1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

Add Image::uri() (#4720)

`uri()` for image

The advantages of this are :

1. No need for `ctx()` and `source()`
2. Displays `name.gif#0` as `name.gif`
This commit is contained in:
rustbasic
2024-07-05 15:20:20 +09:00
committed by GitHub
parent 9a4c46289e
commit ad597a8491

View File

@@ -283,6 +283,20 @@ impl<'a> Image<'a> {
}
}
/// Returns the URI of the image.
///
/// For GIFs, returns the URI without the frame number.
#[inline]
pub fn uri(&self) -> Option<&str> {
let uri = self.source.uri()?;
if let Ok((gif_uri, _index)) = decode_gif_uri(uri) {
Some(gif_uri)
} else {
Some(uri)
}
}
#[inline]
pub fn image_options(&self) -> &ImageOptions {
&self.image_options