-
Notifications
You must be signed in to change notification settings - Fork 3
/
Image.h
114 lines (69 loc) · 2.42 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifndef IMAGE_H
#define IMAGE_H
#include <memory>
#include <string>
#include <iostream>
#include "Matrix.h"
using namespace std;
namespace MSHIMA001{
class Image{
private:
int width, height;
unique_ptr<unsigned char[]> data;
public:
friend ostream& operator<<(ostream& head, const Image& N );
friend istream& operator>>( istream& file, Image& N );
bool operator==(const Image& N);
Image(int w, int h, unsigned char* buffer); // default constructor - define in .cpp
Image( string fileName);
~Image(); // destructor - define in .cpp file
//copy constructor
Image(const Image& N);
//move constructor
Image(Image&& N);
//assignment operator
Image& operator=(const Image& N );
//move assignment operator.
Image& operator=(Image&& N);
//method to read input files
Image operator!();
bool load(std::string fileName);
void save(std::string fileName );
class Iterator{
private:
unsigned char *ptr;
// grant private access to Image class functions
friend class Image;
// construct only via Image class (begin/end)
Iterator(unsigned char *p);
public:
//copy construct is public
Iterator(const Iterator& N);
// define overloaded ops: *, ++, --, =
//destructor
~Iterator();
//move constructor
Iterator(Iterator&& N);
//assignment operator
Iterator& operator=(const Iterator& N );
//move assignment operator.
Iterator& operator=(Iterator&& N);
//++ operator
const Iterator& operator ++();
const Iterator& operator --();
unsigned char& operator *();
bool operator !=( const Iterator& N);
Iterator& operator+=(int n);
//Iterator& operator=(int&& N );
// other methods for Iterator
};
Image::Iterator begin(void) const; // etc
Image::Iterator end(void) const;
Image operator+(const Image& N );
Image operator-(const Image& N );
Image operator/(const Image& N );
Image operator*(int f );
Image operator%(MSHIMA001::Matrix g );
};
}
#endif