summary refs log tree commit diff
path: root/src/GFX/Image/RawImage.hpp
blob: 8a837e61c3a059ee7ada3840591ed53c28c06008 (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
38
39
40
41
42
43
#pragma once

#include <cstdint>
#include <cstddef>
#include <string>
#include <vector>
#include "../../Util/Sampler.hpp"

namespace MC::GFX::Image {

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

    RawImage(uint32_t width, uint32_t height)
        : m_pixels(), m_width(width), m_height(height) {
        m_pixels.reserve(width * height);
    }

    RawImage(Util::Sampler<2, float>& sampler, uint32_t width, uint32_t height);

    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;

    std::string string() const;
private:
    std::vector<Pixel> m_pixels;

    uint32_t m_width, m_height;
    uint8_t m_channels = 3;
};

}