This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
2007-03-01 14:18:56 +01:00
|
|
|
#include "mask.h"
|
|
|
|
#include <math.h>
|
2007-03-01 14:42:32 +01:00
|
|
|
#include <stdio.h>
|
2007-03-01 14:18:56 +01:00
|
|
|
|
|
|
|
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] =
|
2007-03-01 18:07:54 +01:00
|
|
|
(sqrt( pow(x - size/2, 2) + pow(y - size/2, 2)) <= size / 2 )
|
2007-03-01 14:18:56 +01:00
|
|
|
? 255 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return newMask;
|
|
|
|
}
|
|
|
|
|
2007-03-01 14:42:32 +01:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2007-03-01 14:18:56 +01:00
|
|
|
}
|