summary refs log tree commit diff
path: root/src/GFX/Image/RawImage.hpp
blob: 916671bd04f2dda197e8132e068002292923d9b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include <cstdint>
#include <cstddef>
#include <vector>

namespace MC::GFX::Image {

class RawImage {
public:
    RawImage() : m_pixels(), m_width(0), m_height(0), m_channels(0) {};

    explicit RawImage(size_t pixel_count, uint32_t width, uint32_t height, uint8_t channels)
        : m_pixels(), m_width(width), m_height(height), m_channels(channels) {
        m_pixels.reserve(pixel_count);
    }

    struct Pixel {
        uint8_t r, g, b;
    };

    void add(Pixel pixel);

    size_t size() const;
    uint8_t* raw() const;

    uint32_t width() const;
    uint32_t height() const;
    uint8_t channels() const;
private:
    std::vector<Pixel> m_pixels;

    uint32_t m_width, m_height;
    uint8_t m_channels;
};

}