Diffstat (limited to 'noncore/graphics/drawpad/filltool.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/graphics/drawpad/filltool.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp index 3297d21..004da02 100644 --- a/noncore/graphics/drawpad/filltool.cpp +++ b/noncore/graphics/drawpad/filltool.cpp | |||
@@ -21,48 +21,50 @@ | |||
21 | 21 | ||
22 | FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) | 22 | FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) |
23 | : Tool(drawPad, drawPadCanvas) | 23 | : Tool(drawPad, drawPadCanvas) |
24 | { | 24 | { |
25 | } | 25 | } |
26 | 26 | ||
27 | FillTool::~FillTool() | 27 | FillTool::~FillTool() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | void FillTool::mousePressEvent(QMouseEvent* e) | 31 | void FillTool::mousePressEvent(QMouseEvent* e) |
32 | { | 32 | { |
33 | int x = e->x(); | 33 | int x = e->x(); |
34 | int y = e->y(); | 34 | int y = e->y(); |
35 | 35 | ||
36 | m_image = m_pDrawPadCanvas->currentPage()->convertToImage(); | 36 | m_image = m_pDrawPadCanvas->currentPage()->convertToImage(); |
37 | m_fillRgb = m_pDrawPad->brush().color().rgb(); | 37 | m_fillRgb = m_pDrawPad->brush().color().rgb(); |
38 | m_oldRgb = m_image.pixel(x, y); | 38 | m_oldRgb = m_image.pixel(x, y); |
39 | 39 | ||
40 | if (m_oldRgb != m_fillRgb) { | 40 | if (m_oldRgb != m_fillRgb) { |
41 | fillLine(x, y); | 41 | fillLine(x, y); |
42 | 42 | ||
43 | m_pDrawPadCanvas->currentPage()->convertFromImage(m_image); | 43 | m_pDrawPadCanvas->currentPage()->convertFromImage(m_image); |
44 | m_pDrawPadCanvas->viewport()->update(); | 44 | m_pDrawPadCanvas->viewport()->update(); |
45 | |||
46 | m_pDrawPadCanvas->backupPage(); | ||
45 | } | 47 | } |
46 | } | 48 | } |
47 | 49 | ||
48 | void FillTool::mouseReleaseEvent(QMouseEvent* e) | 50 | void FillTool::mouseReleaseEvent(QMouseEvent* e) |
49 | { | 51 | { |
50 | Q_UNUSED(e) | 52 | Q_UNUSED(e) |
51 | } | 53 | } |
52 | 54 | ||
53 | void FillTool::mouseMoveEvent(QMouseEvent* e) | 55 | void FillTool::mouseMoveEvent(QMouseEvent* e) |
54 | { | 56 | { |
55 | Q_UNUSED(e) | 57 | Q_UNUSED(e) |
56 | } | 58 | } |
57 | 59 | ||
58 | void FillTool::fillLine(int x, int y) | 60 | void FillTool::fillLine(int x, int y) |
59 | { | 61 | { |
60 | if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { | 62 | if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { |
61 | if (m_image.pixel(x, y) == m_oldRgb) { | 63 | if (m_image.pixel(x, y) == m_oldRgb) { |
62 | int x1, x2; | 64 | int x1, x2; |
63 | 65 | ||
64 | x1 = x - 1; | 66 | x1 = x - 1; |
65 | x2 = x + 1; | 67 | x2 = x + 1; |
66 | 68 | ||
67 | while ((x1 >= 0) && (m_image.pixel(x1, y) == m_oldRgb)) { | 69 | while ((x1 >= 0) && (m_image.pixel(x1, y) == m_oldRgb)) { |
68 | x1--; | 70 | x1--; |