mirror of
https://github.com/RGBCube/serenity
synced 2025-06-28 21:22:08 +00:00
LibGUI: Animate any image in ImageWidget, not just *.gif
The image decoder already tells us whether the image is animated and it can provide more than one frame, let's not put this behind an artificial "file path must end with lowercase .gif" barrier.
This commit is contained in:
parent
961137ea4c
commit
41e5155467
1 changed files with 5 additions and 7 deletions
|
@ -103,13 +103,11 @@ void ImageWidget::load_from_file(const StringView& path)
|
|||
|
||||
set_bitmap(bitmap);
|
||||
|
||||
if (path.ends_with(".gif")) {
|
||||
if (m_image_decoder->is_animated() && m_image_decoder->frame_count() > 1) {
|
||||
const auto& first_frame = m_image_decoder->frame(0);
|
||||
m_timer->set_interval(first_frame.duration);
|
||||
m_timer->on_timeout = [this] { animate(); };
|
||||
m_timer->start();
|
||||
}
|
||||
if (m_image_decoder->is_animated() && m_image_decoder->frame_count() > 1) {
|
||||
const auto& first_frame = m_image_decoder->frame(0);
|
||||
m_timer->set_interval(first_frame.duration);
|
||||
m_timer->on_timeout = [this] { animate(); };
|
||||
m_timer->start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue