haraldhv
/
aigo
Archived
1
0
Fork 0

Forgot to add mask

This commit is contained in:
Harald Hvaal 2007-03-01 13:18:56 +00:00
parent c5baa69dc5
commit 3a613c3903
2 changed files with 41 additions and 0 deletions

24
lib/mask.cpp Normal file
View File

@ -0,0 +1,24 @@
#include "mask.h"
#include <math.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 - x/2, 2) + pow(y - y/2, 2)) < size / 2)
? 255 : 0;
}
}
return newMask;
}
}

17
lib/mask.h Normal file
View File

@ -0,0 +1,17 @@
#ifndef _MASK_H_
#define _MASK_H_
#include <stdint.h>
namespace Mask
{
struct mask
{
int size;
uint8_t *mask;
};
mask * createCircleMask(int size, bool gradient = false);
}
#endif /* ifndef _MASK_H_ */