blob: dd8dd92d96a746ec879733720f7d98ce6e90686e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* BitmapBrush.h
*
* Created on: Nov 18, 2012
* Author: Simon Robertshaw
*/
#ifndef BTIMAPBRUSH_H_
#define BTIMAPBRUSH_H_
#include <vector>
#include <cmath>
#include "Brush.h"
class BitmapBrush: public Brush
{
public:
BitmapBrush(std::vector<unsigned char> newBitmap, ui::Point rectSize_):
Brush(ui::Point(0, 0))
{
ui::Point newSize = rectSize_;
//Ensure the rect has odd dimentions so we can pull an integer radius with a 1x1 centre
if(!(newSize.X % 2))
newSize.X += 1;
if(!(newSize.Y % 2))
newSize.Y += 1;
radius = (newSize-ui::Point(1, 1))/2;
size = newSize;
if(bitmap)
delete[] bitmap;
bitmap = new unsigned char[size.X*size.Y];
std::fill(bitmap, bitmap+(size.X*size.Y), 0);
for(int y = 0; y < rectSize_.Y; y++)
{
for(int x = 0; x < rectSize_.X; x++)
{
bitmap[(y*size.X)+x] = newBitmap[(y*rectSize_.X)+x];
}
}
updateOutline();
};
virtual void SetRadius(ui::Point radius)
{
//Do nothing... this brush is a fixed size
}
virtual void GenerateBitmap()
{
//Do nothing
}
};
#endif /* BTIMAPBRUSH_H_ */
|