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