-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.h
98 lines (81 loc) · 1.94 KB
/
image.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
#ifndef IMAGE_H
#define IMAGE_H
#include <iostream>
#include <tiffio.h>
#include "plot.h"
#include "color.h"
using namespace std;
class Window;
class Image
{
public:
class ColorRef
{
private:
class Component
{
unsigned char* ptr = nullptr;
bool first = true;
public:
Component(){}
Component(unsigned char& value);
unsigned char operator =(unsigned char& value);
float operator =(const float& value);
Component& operator =(const Component& component);
operator float();
};
public:
Component R;
Component G;
Component B;
Component A;
ColorRef(){}
ColorRef(Color& color);
ColorRef& operator =(const Color& color);
ColorRef& operator =(const ColorRef& cr);
operator Color();
};
private:
unsigned char* _data = nullptr;
int n_rows = 0;
int n_cols = 0;
int n_channels = 0;
unsigned char trash = 255;
string _name;
void read_tiff(const string& filename);
public:
int window_array_index = -1;
public:
Image() : _name("Memory Image") {}
Image(int rows, int cols, int channels = 3, const string& Name = "Memory Image");
Image(const string& filename);
Image(const Image& image);
Image(Image&& image);
virtual ~Image();
Image& operator =(const Image& image);
Image& operator =(Image&& image);
unsigned char& operator ()(int i, int j, int channel);
unsigned char operator ()(int i, int j, int channel)const;
ColorRef operator ()(int i, int j);
Color operator ()(int i, int j)const;
operator GLFWimage ();
void read(const string& filename);
void write(const string& filename);
void show();
void wait();
unsigned char* data();
int width()const;
int height()const;
int rows()const;
int cols()const;
int channels()const;
int size()const;
string name()const;
Image flip_y()const;
Image flip_x()const;
Image flip_xy()const;
void splitRGBA(Matrix<float>& R, Matrix<float>& G, Matrix<float>& B, Matrix<float>& A);
};
extern vector< unique_ptr<Window> > __window_array;
void __wait_rest_images();
#endif