38 lines
663 B
C++
38 lines
663 B
C++
#include "mask.h"
|
|
#include <math.h>
|
|
#include <stdio.h>
|
|
|
|
namespace Mask
|
|
{
|
|
mask * createCircleMask(int size, bool gradient)
|
|
{
|
|
mask * newMask = new mask;
|
|
newMask->size = size;
|
|
newMask->mask = new uint8_t[size*size];
|
|
for (int x = 0; x < size; ++x)
|
|
{
|
|
for (int y = 0; y < size; ++y)
|
|
{
|
|
newMask->mask[y*size+x] =
|
|
(sqrt( pow(x - size/2, 2) + pow(y - size/2, 2)) <= size / 2 )
|
|
? 255 : 0;
|
|
}
|
|
}
|
|
return newMask;
|
|
}
|
|
|
|
void printMask( mask * mask)
|
|
{
|
|
for (int i = 0; i < mask->size; ++i)
|
|
{
|
|
for (int j = 0; j < mask->size; ++j)
|
|
{
|
|
printf("%d\t", mask->mask[mask->size * i + j]);
|
|
}
|
|
printf("\n");
|
|
}
|
|
printf("\n");
|
|
}
|
|
|
|
}
|