ImageDecoding.h 740 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, Dex♪ <dexes.ttp@gmail.com>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/RefPtr.h>
  9. #include <AK/Vector.h>
  10. #include <LibGfx/Bitmap.h>
  11. namespace Web::ImageDecoding {
  12. struct Frame {
  13. RefPtr<Gfx::Bitmap> bitmap;
  14. size_t duration { 0 };
  15. };
  16. struct DecodedImage {
  17. bool is_animated { false };
  18. u32 loop_count { 0 };
  19. Vector<Frame> frames;
  20. };
  21. class Decoder : public RefCounted<Decoder> {
  22. public:
  23. virtual ~Decoder();
  24. static void initialize(RefPtr<Decoder>&&);
  25. static Decoder& the();
  26. virtual Optional<DecodedImage> decode_image(ReadonlyBytes) = 0;
  27. protected:
  28. explicit Decoder();
  29. };
  30. }