From 3a613c39034e4d319aaa057ae04196b36c52bbcd Mon Sep 17 00:00:00 2001 From: haraldhv Date: Thu, 1 Mar 2007 13:18:56 +0000 Subject: [PATCH] Forgot to add mask --- lib/mask.cpp | 24 ++++++++++++++++++++++++ lib/mask.h | 17 +++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 lib/mask.cpp create mode 100644 lib/mask.h 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_ */