2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2018-10-12 12:49:45 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Size.h"
|
2019-06-21 18:58:45 +02:00
|
|
|
#include <AK/RefCounted.h>
|
2020-02-06 11:56:38 +01:00
|
|
|
#include <AK/RefPtr.h>
|
|
|
|
|
|
|
|
|
|
namespace Gfx {
|
2018-10-12 12:49:45 +02:00
|
|
|
|
2019-06-21 15:29:31 +02:00
|
|
|
class CharacterBitmap : public RefCounted<CharacterBitmap> {
|
2018-10-12 12:49:45 +02:00
|
|
|
public:
|
2019-06-21 18:37:47 +02:00
|
|
|
static NonnullRefPtr<CharacterBitmap> create_from_ascii(const char* asciiData, unsigned width, unsigned height);
|
2019-01-10 05:41:49 +01:00
|
|
|
~CharacterBitmap();
|
2018-10-12 12:49:45 +02:00
|
|
|
|
2019-02-02 08:05:14 +01:00
|
|
|
bool bit_at(unsigned x, unsigned y) const { return m_bits[y * width() + x] == '#'; }
|
2018-10-12 12:49:45 +02:00
|
|
|
const char* bits() const { return m_bits; }
|
|
|
|
|
|
2020-06-10 10:57:59 +02:00
|
|
|
IntSize size() const { return m_size; }
|
2018-10-12 12:49:45 +02:00
|
|
|
unsigned width() const { return m_size.width(); }
|
|
|
|
|
unsigned height() const { return m_size.height(); }
|
|
|
|
|
|
|
|
|
|
private:
|
2019-01-10 05:41:49 +01:00
|
|
|
CharacterBitmap(const char* b, unsigned w, unsigned h);
|
2018-10-12 12:49:45 +02:00
|
|
|
|
|
|
|
|
const char* m_bits { nullptr };
|
2020-06-10 10:57:59 +02:00
|
|
|
IntSize m_size;
|
2018-10-12 12:49:45 +02:00
|
|
|
};
|
2020-02-06 11:56:38 +01:00
|
|
|
|
|
|
|
|
}
|