/src/serenity/Userland/Libraries/LibGfx/GrayscaleBitmap.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2023, MacDue <macdue@dueutil.tech> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include "Size.h" |
10 | | #include <AK/RefCounted.h> |
11 | | #include <AK/RefPtr.h> |
12 | | #include <AK/StringView.h> |
13 | | |
14 | | namespace Gfx { |
15 | | |
16 | | class GrayscaleBitmap { |
17 | | public: |
18 | | GrayscaleBitmap() = delete; |
19 | | constexpr GrayscaleBitmap(ReadonlyBytes data, unsigned width, unsigned height) |
20 | | : m_data(data) |
21 | | , m_size(width, height) |
22 | 0 | { |
23 | 0 | VERIFY(width * height == data.size()); |
24 | 0 | } |
25 | | |
26 | 0 | constexpr u8 pixel_at(unsigned x, unsigned y) const { return m_data[y * width() + x]; } |
27 | 0 | constexpr ReadonlyBytes data() const { return m_data; } |
28 | | |
29 | 0 | constexpr IntSize size() const { return m_size; } |
30 | 0 | constexpr unsigned width() const { return m_size.width(); } |
31 | 0 | constexpr unsigned height() const { return m_size.height(); } |
32 | | |
33 | | private: |
34 | | ReadonlyBytes m_data {}; |
35 | | IntSize m_size {}; |
36 | | }; |
37 | | |
38 | | } |