diff --git a/lib/mask.cpp b/lib/mask.cpp new file mode 100644 index 0000000..bcb0c9b --- /dev/null +++ b/lib/mask.cpp @@ -0,0 +1,24 @@ +#include "mask.h" +#include + +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 - x/2, 2) + pow(y - y/2, 2)) < size / 2) + ? 255 : 0; + } + } + return newMask; + } + +} diff --git a/lib/mask.h b/lib/mask.h new file mode 100644 index 0000000..bcb4013 --- /dev/null +++ b/lib/mask.h @@ -0,0 +1,17 @@ +#ifndef _MASK_H_ +#define _MASK_H_ + +#include + +namespace Mask +{ + struct mask + { + int size; + uint8_t *mask; + }; + + mask * createCircleMask(int size, bool gradient = false); +} + +#endif /* ifndef _MASK_H_ */