BMPLoader.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGfx/ImageFormats/ICOLoader.h>
  8. #include <LibGfx/ImageFormats/ImageDecoder.h>
  9. namespace Gfx {
  10. struct BMPLoadingContext;
  11. class ICOImageDecoderPlugin;
  12. class BMPImageDecoderPlugin final : public ImageDecoderPlugin {
  13. public:
  14. static bool sniff(ReadonlyBytes);
  15. static ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> create(ReadonlyBytes);
  16. static ErrorOr<NonnullOwnPtr<BMPImageDecoderPlugin>> create_as_included_in_ico(Badge<ICOImageDecoderPlugin>, ReadonlyBytes);
  17. enum class IncludedInICO {
  18. Yes,
  19. No,
  20. };
  21. virtual ~BMPImageDecoderPlugin() override;
  22. virtual IntSize size() override;
  23. bool sniff_dib();
  24. virtual ErrorOr<ImageFrameDescriptor> frame(size_t index, Optional<IntSize> ideal_size = {}) override;
  25. virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() override;
  26. private:
  27. BMPImageDecoderPlugin(u8 const*, size_t, IncludedInICO included_in_ico = IncludedInICO::No);
  28. static ErrorOr<NonnullOwnPtr<BMPImageDecoderPlugin>> create_impl(ReadonlyBytes, IncludedInICO);
  29. OwnPtr<BMPLoadingContext> m_context;
  30. };
  31. }