From 8d6c60fd2b103ec0ac26dcabf7ffb9d4f37d1873 Mon Sep 17 00:00:00 2001 From: jprochazk <1665677+jprochazk@users.noreply.github.com> Date: Tue, 12 Sep 2023 09:16:02 +0200 Subject: [PATCH] add `.size()` to `Image` --- crates/egui/src/widgets/image.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/egui/src/widgets/image.rs b/crates/egui/src/widgets/image.rs index 037e5c43008..cc98559d0a7 100644 --- a/crates/egui/src/widgets/image.rs +++ b/crates/egui/src/widgets/image.rs @@ -210,6 +210,13 @@ impl<'a> Image<'a> { self.size.get(available_size, image_size) } + pub fn size(&self) -> Option { + match &self.source { + ImageSource::Texture(texture) => Some(texture.size), + ImageSource::Uri(_) | ImageSource::Bytes(_, _) => None, + } + } + pub fn source(&self) -> &ImageSource<'a> { &self.source }