-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStenciledImage.cpp
More file actions
35 lines (33 loc) · 1007 Bytes
/
StenciledImage.cpp
File metadata and controls
35 lines (33 loc) · 1007 Bytes
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
#include <iostream>
#include "StenciledImage.h"
using namespace std;
StenciledImage::StenciledImage(Image img,Image mask) : Image(img.getHeight(),img.getWidth())
{
if(img.getHeight() != mask.getHeight() || img.getWidth() != mask.getWidth())
{
cout << "Incompatable image and mask\n";
// ~StenciledImage();
}
else
{
Colour white(255,255,255);
Colour black(0,0,0);
for(int i = 0 ; i < mask.getHeight() ; i++)
{
for(int j = 0 ; j < mask.getWidth() ; j++)
{
if(mask.getColourAtPos(i,j) == white)
mask.fillColourAtPos(i,j,black);
else
mask.fillColourAtPos(i,j,white);
}
}
for(int i = 0 ; i < img.getHeight() ; i++)
{
for(int j = 0 ; j < img.getWidth() ; j++)
{
_my_arr[i][j].setColour(img.getColourAtPos(i,j) + mask.getColourAtPos(i,j));
}
}
}
}