-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.cpp
executable file
·53 lines (40 loc) · 892 Bytes
/
image.cpp
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
#include "image.hpp"
//------------------------------------------[Image Class]-------------------------------------------
image::image(){
rows = 0;
cols = 0;
}
image::image(int r, int c):rows(r), cols(c){
data.resize(rows);
for(int i = 0; i < rows; i++){
data[i].resize(c);
}
}
image::image(std::vector<std::vector<pixel> > v){
data = v;
rows = v.size();
cols = v[0].size();
}
image::image(const image& other){
rows = other.rows;
cols = other.cols;
data = other.data;
}
void image::set_format(std::string f){
format = f;
}
std::string image::get_format() const {
return format;
}
int image::r() const {
return rows;
}
int image::c() const {
return cols;
}
const std::vector<pixel>& image::operator[](size_t i) const {
return data[i];
}
std::vector<pixel>& image::operator[](size_t i){
return data[i];
}