Skip to content

Commit

Permalink
Check for animated image header bytes only
Browse files Browse the repository at this point in the history
  • Loading branch information
Aely0 committed Dec 17, 2024
1 parent d0fe935 commit 476e2a5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crates/egui/src/widgets/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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)
}

0 comments on commit 476e2a5

Please sign in to comment.