CharacterBitmap.h 853 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include "Size.h"
  8. #include <AK/RefCounted.h>
  9. #include <AK/RefPtr.h>
  10. namespace Gfx {
  11. class CharacterBitmap : public RefCounted<CharacterBitmap> {
  12. public:
  13. static NonnullRefPtr<CharacterBitmap> create_from_ascii(const char* asciiData, unsigned width, unsigned height);
  14. ~CharacterBitmap();
  15. bool bit_at(unsigned x, unsigned y) const { return m_bits[y * width() + x] == '#'; }
  16. const char* bits() const { return m_bits; }
  17. IntSize size() const { return m_size; }
  18. unsigned width() const { return m_size.width(); }
  19. unsigned height() const { return m_size.height(); }
  20. private:
  21. CharacterBitmap(const char* b, unsigned w, unsigned h);
  22. const char* m_bits { nullptr };
  23. IntSize m_size;
  24. };
  25. }