summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/drawpad/filltool.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/noncore/graphics/drawpad/filltool.cpp b/noncore/graphics/drawpad/filltool.cpp
index 2a39d04..b47aa60 100644
--- a/noncore/graphics/drawpad/filltool.cpp
+++ b/noncore/graphics/drawpad/filltool.cpp
@@ -1,86 +1,91 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * DrawPad - a drawing program for Opie Environment * 3 * DrawPad - a drawing program for Opie Environment *
4 * * 4 * *
5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> * 5 * (C) 2002 by S. Prud'homme <prudhomme@laposte.net> *
6 * * 6 * *
7 * This program is free software; you can redistribute it and/or modify * 7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by * 8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or * 9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. * 10 * (at your option) any later version. *
11 * * 11 * *
12 ***************************************************************************/ 12 ***************************************************************************/
13 13
14#include "filltool.h" 14#include "filltool.h"
15 15
16#include "drawpad.h" 16#include "drawpad.h"
17#include "drawpadcanvas.h" 17#include "drawpadcanvas.h"
18#include "page.h" 18#include "page.h"
19 19
20#include <qimage.h> 20#include <qimage.h>
21 21
22const int FILL_THRESHOLD = 65536; 22const int FILL_THRESHOLD = 65536;
23 23
24FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas) 24FillTool::FillTool(DrawPad* drawPad, DrawPadCanvas* drawPadCanvas)
25 : Tool(drawPad, drawPadCanvas) 25 : Tool(drawPad, drawPadCanvas)
26{ 26{
27} 27}
28 28
29FillTool::~FillTool() 29FillTool::~FillTool()
30{ 30{
31} 31}
32 32
33void FillTool::mousePressEvent(QMouseEvent* e) 33void FillTool::mousePressEvent(QMouseEvent* e)
34{ 34{
35 int x = e->x(); 35 int x = e->x();
36 int y = e->y(); 36 int y = e->y();
37 37
38 m_image = m_pDrawPadCanvas->currentPage()->pixmap()->convertToImage(); 38 m_image = m_pDrawPadCanvas->currentPage()->pixmap()->convertToImage();
39
40 if (m_image.depth() <= 8) {
41 m_image = m_image.convertDepth(32);
42 }
43
39 m_fillRgb = m_pDrawPad->brush().color().rgb(); 44 m_fillRgb = m_pDrawPad->brush().color().rgb();
40 m_oldRgb = m_image.pixel(x, y); 45 m_oldRgb = m_image.pixel(x, y);
41 46
42 if (m_oldRgb != m_fillRgb) { 47 if (m_oldRgb != m_fillRgb) {
43 m_pDrawPadCanvas->backupPage(); 48 m_pDrawPadCanvas->backupPage();
44 49
45 if (m_pDrawPad->antiAliasing()) { 50 if (m_pDrawPad->antiAliasing()) {
46 m_mask.create(m_image.width(), m_image.height(), 8, 2); 51 m_mask.create(m_image.width(), m_image.height(), 8, 2);
47 m_mask.fill(0); 52 m_mask.fill(0);
48 53
49 fillMaskLine(x, y); 54 fillMaskLine(x, y);
50 55
51 for (int i = 0; i < m_image.width(); i++) { 56 for (int i = 0; i < m_image.width(); i++) {
52 for (int j = 0; j < m_image.height(); j++) { 57 for (int j = 0; j < m_image.height(); j++) {
53 if (m_mask.pixelIndex(i, j) == 1) { 58 if (m_mask.pixelIndex(i, j) == 1) {
54 setInterpolatedPixel(i, j); 59 setInterpolatedPixel(i, j);
55 } 60 }
56 } 61 }
57 } 62 }
58 63
59 } else { 64 } else {
60 fillLine(x, y); 65 fillLine(x, y);
61 } 66 }
62 67
63 m_pDrawPadCanvas->currentPage()->pixmap()->convertFromImage(m_image); 68 m_pDrawPadCanvas->currentPage()->pixmap()->convertFromImage(m_image);
64 m_pDrawPadCanvas->viewport()->update(); 69 m_pDrawPadCanvas->viewport()->update();
65 } 70 }
66} 71}
67 72
68void FillTool::mouseReleaseEvent(QMouseEvent* e) 73void FillTool::mouseReleaseEvent(QMouseEvent* e)
69{ 74{
70 Q_UNUSED(e) 75 Q_UNUSED(e)
71} 76}
72 77
73void FillTool::mouseMoveEvent(QMouseEvent* e) 78void FillTool::mouseMoveEvent(QMouseEvent* e)
74{ 79{
75 Q_UNUSED(e) 80 Q_UNUSED(e)
76} 81}
77 82
78void FillTool::fillLine(int x, int y) 83void FillTool::fillLine(int x, int y)
79{ 84{
80 if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) { 85 if ((x >= 0) && (x < m_image.width()) && (y >= 0) && (y < m_image.height())) {
81 if (m_image.pixel(x, y) == m_oldRgb) { 86 if (m_image.pixel(x, y) == m_oldRgb) {
82 int x1, x2; 87 int x1, x2;
83 88
84 x1 = x - 1; 89 x1 = x - 1;
85 x2 = x + 1; 90 x2 = x + 1;
86 91