From 476e2a52c1a67038708f89bc16fa7a9c4659777b Mon Sep 17 00:00:00 2001 From: Aely0 <29923178+Aely0@users.noreply.github.com> Date: Tue, 17 Dec 2024 09:17:13 +0200 Subject: [PATCH] Check for animated image header bytes only --- crates/egui/src/widgets/image.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/egui/src/widgets/image.rs b/crates/egui/src/widgets/image.rs index 4c61c1a6358..7380eaac26e 100644 --- a/crates/egui/src/widgets/image.rs +++ b/crates/egui/src/widgets/image.rs @@ -312,7 +312,7 @@ impl<'a> Image<'a> { ImageSource::Uri(Cow::Owned(frame_uri)) } - ImageSource::Bytes { uri, bytes } if are_animated_image_bytes(uri, bytes) => { + ImageSource::Bytes { uri, bytes } if are_animated_image_bytes(bytes) => { let frame_uri = encode_animated_image_uri(uri, animated_image_frame_index(ctx, uri)); ctx.include_bytes(uri.clone(), bytes.clone()); @@ -882,6 +882,6 @@ fn is_animated_image_uri(uri: &str) -> bool { is_gif_uri(uri) || is_webp_uri(uri) } -fn are_animated_image_bytes(uri: &str, bytes: &[u8]) -> bool { - (is_gif_uri(uri) && has_gif_magic_header(bytes)) || (is_webp_uri(uri) && has_webp_header(bytes)) +fn are_animated_image_bytes(bytes: &[u8]) -> bool { + has_gif_magic_header(bytes) || has_webp_header(bytes) }