-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompositeImage.cpp
More file actions
36 lines (32 loc) · 1.04 KB
/
CompositeImage.cpp
File metadata and controls
36 lines (32 loc) · 1.04 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
#include <iostream>
#include "CompositeImage.h"
#include "Image.h"
using namespace std;
CompositeImage::CompositeImage(Image i1,Image i2,float alpha) : Image(i1.getHeight(),i1.getWidth())
{
if(i1.getHeight() != i2.getHeight() || i1.getWidth() != i2.getWidth())
{
cout << "Can't compose images\n";
// ~Image();
}
else
{
this->reCompose(i1,i2,alpha);
}
}
void CompositeImage::reCompose(Image i1,Image i2,float alpha)
{
_alpha = alpha;
float r,b,g;
for(int i = 0 ; i < _height ; i++)//_height will be height of the composite image
{
for(int j = 0 ; j < _width ; j++)
{
r = ((1-_alpha)*(i1.getColourAtPos(i,j).getRed())) + ((_alpha)*(i2.getColourAtPos(i,j).getRed()));
b = (1-_alpha)*(i1.getColourAtPos(i,j).getBlue()) + (_alpha)*(i2.getColourAtPos(i,j).getBlue());
g = (1-_alpha)*(i1.getColourAtPos(i,j).getGreen()) + (_alpha)*(i2.getColourAtPos(i,j).getGreen());
Colour c(r,g,b);
_my_arr[i][j].setColour(c);
}
}
}