-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPicture.h
99 lines (76 loc) · 3.78 KB
/
Picture.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
#pragma once
const unsigned int COLOR_BITS = 8, COLOR_MASK = (1 << COLOR_BITS) - 1;
const std::string FORMAT_TYPE = "P2";
class Picture
{
public:
explicit Picture(const unsigned int height, const unsigned int width);
Picture(const Picture& arg);
Picture operator +(const Picture& arg) const; // mixture of pictures.
Picture operator -(const Picture& arg) const; // light out second picture in the first one.
Picture operator *(const Picture& arg) const; // usually selfmultiply, increases contrast.
Picture& operator +=(const Picture& arg);
Picture& operator -=(const Picture& arg);
Picture& operator *=(const Picture& arg);
Picture operator +(const int arg) const; // makes darker on constant.
Picture operator -(const int arg) const; // makes brighter on constant.
Picture operator *(const unsigned int arg) const; // makes darker in scale.
Picture operator /(const unsigned int arg) const; // makes brighter in scale.
Picture operator %(const unsigned int arg) const; // shows colors lighter than arg.
Picture& operator +=(const int arg);
Picture& operator -=(const int arg);
Picture& operator *=(const unsigned int arg);
Picture& operator /=(const unsigned int arg);
Picture& operator %=(const unsigned int arg);
Picture& operator ~(); //color inversion.
Picture operator ^(const Picture& arg) const; // inversion according to arg's colors.
Picture operator &(const Picture& arg) const; // common colors only.
Picture operator |(const Picture& arg) const; // all colors of both pictures.
Picture& operator ^=(const Picture& arg);
Picture& operator &=(const Picture& arg);
Picture& operator |=(const Picture& arg);
Picture operator ^(const int arg) const; // inversion relative to arg color.
Picture operator &(const int arg) const; // arg color filter.
Picture operator |(const int arg) const; // adds arg color to picture.
Picture operator >>(const unsigned int arg) const; // contrast decrease.
Picture operator <<(const unsigned int arg) const; // contrast increase.
Picture& operator ^=(const int arg);
Picture& operator &=(const int arg);
Picture& operator |=(const int arg);
Picture& operator >>=(const unsigned int arg);
Picture& operator <<=(const unsigned int arg);
bool operator <(const Picture& r) const;
bool operator <=(const Picture& r) const;
bool operator >(const Picture& r) const;
bool operator >=(const Picture& r) const;
bool operator ==(const Picture& r) const;
bool operator !=(const Picture& r) const;
Picture& operator +(); // clockwise rotation.
Picture& operator -(); // anti-clockwise rotation.
//increments are used to equal height before panorama.
void operator ++(); // pre, adds top raw.
void operator --(); // pre, removes top raw.
void operator ++(const int); // post, adds bottom raw.
void operator --(const int); // post, removes bottom raw.
explicit operator bool() const;
operator !() const;
bool operator &&(const Picture& r) const;
bool operator ||(const Picture& r) const;
Picture& operator =(const Picture& arg);
Picture operator ,(const Picture& arg) const; //makes panorama (needs same height).
void operator ->*(const std::string fileName) const; // save to file.
void get(const std::string fileName); // gets from file.
std::vector <int>& operator [](const unsigned int i);
const std::vector <int>& operator [](const unsigned int i) const;
unsigned int getHeight() const;
unsigned int getWidth() const;
void swap(Picture& arg);
~Picture();
private:
unsigned int mHeight;
unsigned int mWidth;
std::vector <std::vector <int>> mArray;
short cmp(const Picture& r) const; // compare resolution.
};
std::ostream& operator <<(std::ostream& out, const Picture& arg);
std::istream& operator >>(std::istream& in, Picture& arg);