forked from satu0king/ImageProcessing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMirrorImage.cpp
More file actions
61 lines (58 loc) · 2.14 KB
/
MirrorImage.cpp
File metadata and controls
61 lines (58 loc) · 2.14 KB
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
#include "MirrorImage.h"
MirrorImage::MirrorImage(Image im):Image(im){
}
MirrorImage::~MirrorImage(){
}
void MirrorImage::MirrorX(Image im){
//this->set_size(im.width(),im.height());
//Pixel **p;
//p=im.get_pixel();
for (int i = 0; i < im.height()/2; i++) {
for (int j = 0; j < im.width(); j++) {
//this->get_pixel()[i][j].set_x(i);
//this->get_pixel()[i][j].set_y(j);
Color c(im.color(i,j).red(),im.color(i,j).green(),im.color(i,j).blue());
set_color(i,j,c);
//this->get_pixel()[i][j].set_color();
}
}
int k=0;
for (int i = im.height()/2; i < im.height(); i++) {
for (int j = 0; j < im.width(); j++) {
//this->get_pixel()[i][j].set_x(i);
//this->get_pixel()[i][j].set_y(j);
Color c1(color(im.height()/2-k,j).red(),color(im.height()/2-k,j).green(),color(im.height()/2-k,j).blue());
//this->get_pixel()[i][j].set_color(p[i][im.height()/2-k].color().red(),p[i][im.height()/2-k].color().green(),p[i][im.height()/2-k].color().blue());
set_color(i,j,c1);
}
k++;
}
//k=0;
}
void MirrorImage::MirrorY(Image im){
//this->set_size(im.width(),im.height());
//Pixel **p;
//p=im.get_pixel();
for (int i = 0; i < im.height(); i++) {
for (int j = 0; j < im.width()/2; j++) {
//this->get_pixel()[i][j].set_x(i);
//this->get_pixel()[i][j].set_y(j);
Color c2(im.color(i,j).red(),im.color(i,j).green(),im.color(i,j).blue());
//this->get_pixel()[i][j].set_color(p[i][j].color().red(),p[i][j].color().green(),p[i][j].color().blue());
set_color(i,j,c2);
}
}
int k=0;
for (int i = 0; i < im.height(); i++) {
for (int j = im.width()/2; j < im.width(); j++) {
//cout<<i<<" "<<j<<" "<<im.width()<<" "<<im.height()<<" "<<(im.width()/2-k)<<endl;
//this->get_pixel()[i][j].set_x(i);
//this->get_pixel()[i][j].set_y(j);
Color c3(im.color(i,im.width()/2-k).red(),im.color(i,im.width()/2-k).green(),im.color(i,im.width()/2-k).blue());
set_color(i,j,c3);
//this->get_pixel()[i][j].set_color(p[im.width()/2-k][j].color().red(),p[im.width()/2-k][j].color().green(),p[im.width()/2-k][j].color().blue());
k++;
}
k=0;
}
}