/* * Copyright (c) 2023, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace Web::HTML { // https://html.spec.whatwg.org/multipage/images.html#img-req-data class DecodedImageData final : public RefCounted { public: struct Frame { RefPtr bitmap; int duration { 0 }; }; static ErrorOr> create(Vector&&, size_t loop_count, bool animated); ~DecodedImageData(); RefPtr bitmap(size_t frame_index) const; int frame_duration(size_t frame_index) const; size_t frame_count() const { return m_frames.size(); } size_t loop_count() const { return m_loop_count; } bool is_animated() const { return m_animated; } Optional natural_width() const; Optional natural_height() const; private: DecodedImageData(Vector&&, size_t loop_count, bool animated); Vector m_frames; size_t m_loop_count { 0 }; bool m_animated { false }; }; }