-
Notifications
You must be signed in to change notification settings - Fork 39
/
MyImage.h
110 lines (82 loc) · 1.86 KB
/
MyImage.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#pragma once
#include <stdint.h>
enum PADDING_MODE {
PADDING_MODE_CONSTANT,
PADDING_MODE_EDGE,
PADDING_MODE_REFLECT
};
struct PixelRGB
{
uint8_t B = 0;
uint8_t G = 0;
uint8_t R = 0;
};
struct PixelYUV
{
uint8_t Y = 0;
uint8_t U = 0;
uint8_t V = 0;
};
class ImageRaw
{
private:
uint16_t* data = nullptr;
int width = 0;
int height = 0;
public:
ImageRaw();
ImageRaw(int height, int width);
ImageRaw(uint16_t* src, int height, int width);
ImageRaw(const ImageRaw& img);
~ImageRaw();
uint16_t& at(int h, int w);
void clip(uint16_t min = 0, uint16_t max = 1024);
void padding(int round, PADDING_MODE mode = PADDING_MODE_CONSTANT, uint16_t value = 0);
const int getHeight();
const int getWidth();
const uint16_t* getData();
void print();
void operator=(const ImageRaw& src);
};
class ImageRGB
{
private:
PixelRGB* data = nullptr;
int width = 0;
int height = 0;
public:
ImageRGB();
ImageRGB(int height, int width);
ImageRGB(PixelRGB* src, int height, int width);
ImageRGB(const ImageRGB& img);
~ImageRGB();
PixelRGB& at(int h, int w);
void clip(uint8_t min = 0, uint8_t max = 255);
void padding(int round, PADDING_MODE mode = PADDING_MODE_CONSTANT, PixelRGB value = PixelRGB());
const int getHeight();
const int getWidth();
const PixelRGB* getData();
void print();
void operator=(const ImageRGB& src);
};
class ImageYUV
{
private:
PixelYUV* data = nullptr;
int width = 0;
int height = 0;
public:
ImageYUV();
ImageYUV(int height, int width);
ImageYUV(PixelYUV* src, int height, int width);
ImageYUV(const ImageYUV& img);
~ImageYUV();
PixelYUV& at(int h, int w);
void clip(uint8_t min = 0, uint8_t max = 255);
void padding(int round, PADDING_MODE mode = PADDING_MODE_CONSTANT, PixelYUV value = PixelYUV());
const int getHeight();
const int getWidth();
const PixelYUV* getData();
void print();
void operator=(const ImageYUV& src);
};