-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage.h
More file actions
30 lines (26 loc) · 853 Bytes
/
image.h
File metadata and controls
30 lines (26 loc) · 853 Bytes
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
#pragma once
#include <vector>
#include <unordered_map>
#include <cstdint>
#include <string>
struct RGB {
double blue{0};
double green{0};
double red{0};
void SetColors(std::array<unsigned char, 3> &rgb_colors); // convert colors to double and write to structure
void GetColors(std::array<unsigned char, 3> &rgb_colors) const; // read colors from structure and convert them to char
};
typedef std::vector<std::vector<RGB>> RGBMatrix;
class Image {
private:
RGBMatrix _matrix{};
int32_t _height{};
int32_t _width{};
public:
Image() = default;
Image(int32_t height, int32_t width);
[[nodiscard]] RGB GetPixel(int32_t row, int32_t idx) const;
void SetPixel(RGB pixel, int32_t row, int32_t idx);
void Resize(int32_t new_height, int32_t new_width);
[[nodiscard]] std::unordered_map<std::string, int32_t> GetSize() const;
};